diff options
author | Dave Airlie <airlied@redhat.com> | 2018-05-24 20:28:14 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2018-05-24 20:28:33 -0400 |
commit | dd41fb8547c2422f3a3a75e7226525e8bba9381c (patch) | |
tree | 0e94d33f1fc940999d7b05d5e383fb6e13625ac8 | |
parent | ce234ccc03cfee004e168a1ae4b9d0cfb1974a32 (diff) | |
parent | b8f3439fa5358ac84d29fa2f4afa115500dec74c (diff) |
Merge branch 'drm-next-4.18' of git://people.freedesktop.org/~agd5f/linux into drm-next
Last feature request for 4.18. Mostly vega20 support.
- Vega20 support
- clock and powergating for VCN
- misc bug fixes
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180524152427.32713-1-alexander.deucher@amd.com
139 files changed, 6965 insertions, 2829 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 68e9f584c570..a51c5a960750 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile | |||
@@ -62,11 +62,13 @@ 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 emu_soc.o mxgpu_ai.o nbio_v7_0.o vega10_reg_init.o | 65 | vi.o mxgpu_vi.o nbio_v6_1.o soc15.o emu_soc.o mxgpu_ai.o nbio_v7_0.o vega10_reg_init.o \ |
66 | vega20_reg_init.o | ||
66 | 67 | ||
67 | # add DF block | 68 | # add DF block |
68 | amdgpu-y += \ | 69 | amdgpu-y += \ |
69 | df_v1_7.o | 70 | df_v1_7.o \ |
71 | df_v3_6.o | ||
70 | 72 | ||
71 | # add GMC block | 73 | # add GMC block |
72 | amdgpu-y += \ | 74 | amdgpu-y += \ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 03a2c0be0bf2..a59c07590cee 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1401,6 +1401,8 @@ struct amdgpu_df_funcs { | |||
1401 | bool enable); | 1401 | bool enable); |
1402 | void (*get_clockgating_state)(struct amdgpu_device *adev, | 1402 | void (*get_clockgating_state)(struct amdgpu_device *adev, |
1403 | u32 *flags); | 1403 | u32 *flags); |
1404 | void (*enable_ecc_force_par_wr_rmw)(struct amdgpu_device *adev, | ||
1405 | bool enable); | ||
1404 | }; | 1406 | }; |
1405 | /* Define the HW IP blocks will be used in driver , add more if necessary */ | 1407 | /* Define the HW IP blocks will be used in driver , add more if necessary */ |
1406 | enum amd_hw_ip_block_type { | 1408 | enum amd_hw_ip_block_type { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c index a0f48cb9b8f0..236915849cfe 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | |||
@@ -322,3 +322,47 @@ int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev) | |||
322 | 322 | ||
323 | return ret; | 323 | return ret; |
324 | } | 324 | } |
325 | |||
326 | union gfx_info { | ||
327 | struct atom_gfx_info_v2_4 v24; | ||
328 | }; | ||
329 | |||
330 | int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device *adev) | ||
331 | { | ||
332 | struct amdgpu_mode_info *mode_info = &adev->mode_info; | ||
333 | int index; | ||
334 | uint8_t frev, crev; | ||
335 | uint16_t data_offset; | ||
336 | |||
337 | index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
338 | gfx_info); | ||
339 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
340 | &frev, &crev, &data_offset)) { | ||
341 | union gfx_info *gfx_info = (union gfx_info *) | ||
342 | (mode_info->atom_context->bios + data_offset); | ||
343 | switch (crev) { | ||
344 | case 4: | ||
345 | adev->gfx.config.max_shader_engines = gfx_info->v24.gc_num_se; | ||
346 | adev->gfx.config.max_cu_per_sh = gfx_info->v24.gc_num_cu_per_sh; | ||
347 | adev->gfx.config.max_sh_per_se = gfx_info->v24.gc_num_sh_per_se; | ||
348 | adev->gfx.config.max_backends_per_se = gfx_info->v24.gc_num_rb_per_se; | ||
349 | adev->gfx.config.max_texture_channel_caches = gfx_info->v24.gc_num_tccs; | ||
350 | adev->gfx.config.max_gprs = le16_to_cpu(gfx_info->v24.gc_num_gprs); | ||
351 | adev->gfx.config.max_gs_threads = gfx_info->v24.gc_num_max_gs_thds; | ||
352 | adev->gfx.config.gs_vgt_table_depth = gfx_info->v24.gc_gs_table_depth; | ||
353 | adev->gfx.config.gs_prim_buffer_depth = | ||
354 | le16_to_cpu(gfx_info->v24.gc_gsprim_buff_depth); | ||
355 | adev->gfx.config.double_offchip_lds_buf = | ||
356 | gfx_info->v24.gc_double_offchip_lds_buffer; | ||
357 | adev->gfx.cu_info.wave_front_size = le16_to_cpu(gfx_info->v24.gc_wave_size); | ||
358 | adev->gfx.cu_info.max_waves_per_simd = le16_to_cpu(gfx_info->v24.gc_max_waves_per_simd); | ||
359 | adev->gfx.cu_info.max_scratch_slots_per_cu = gfx_info->v24.gc_max_scratch_slots_per_cu; | ||
360 | adev->gfx.cu_info.lds_size = le16_to_cpu(gfx_info->v24.gc_lds_size); | ||
361 | return 0; | ||
362 | default: | ||
363 | return -EINVAL; | ||
364 | } | ||
365 | |||
366 | } | ||
367 | return -EINVAL; | ||
368 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h index 7689c961c4ef..20f158fd3b76 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h | |||
@@ -30,5 +30,6 @@ int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev); | |||
30 | int amdgpu_atomfirmware_get_vram_width(struct amdgpu_device *adev); | 30 | int amdgpu_atomfirmware_get_vram_width(struct amdgpu_device *adev); |
31 | int amdgpu_atomfirmware_get_vram_type(struct amdgpu_device *adev); | 31 | int amdgpu_atomfirmware_get_vram_type(struct amdgpu_device *adev); |
32 | int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev); | 32 | int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev); |
33 | int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device *adev); | ||
33 | 34 | ||
34 | #endif | 35 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index 5b3d3bf5b599..e950730f1933 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | |||
@@ -400,6 +400,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, | |||
400 | case CHIP_VEGA12: | 400 | case CHIP_VEGA12: |
401 | strcpy(fw_name, "amdgpu/vega12_smc.bin"); | 401 | strcpy(fw_name, "amdgpu/vega12_smc.bin"); |
402 | break; | 402 | break; |
403 | case CHIP_VEGA20: | ||
404 | strcpy(fw_name, "amdgpu/vega20_smc.bin"); | ||
405 | break; | ||
403 | default: | 406 | default: |
404 | DRM_ERROR("SMC firmware not supported\n"); | 407 | DRM_ERROR("SMC firmware not supported\n"); |
405 | return -EINVAL; | 408 | return -EINVAL; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index a8e531d604fa..c5bb36275e93 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | |||
@@ -173,9 +173,14 @@ static void amdgpu_ctx_do_release(struct kref *ref) | |||
173 | 173 | ||
174 | ctx = container_of(ref, struct amdgpu_ctx, refcount); | 174 | ctx = container_of(ref, struct amdgpu_ctx, refcount); |
175 | 175 | ||
176 | for (i = 0; i < ctx->adev->num_rings; i++) | 176 | for (i = 0; i < ctx->adev->num_rings; i++) { |
177 | |||
178 | if (ctx->adev->rings[i] == &ctx->adev->gfx.kiq.ring) | ||
179 | continue; | ||
180 | |||
177 | drm_sched_entity_fini(&ctx->adev->rings[i]->sched, | 181 | drm_sched_entity_fini(&ctx->adev->rings[i]->sched, |
178 | &ctx->rings[i].entity); | 182 | &ctx->rings[i].entity); |
183 | } | ||
179 | 184 | ||
180 | amdgpu_ctx_fini(ref); | 185 | amdgpu_ctx_fini(ref); |
181 | } | 186 | } |
@@ -452,12 +457,17 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr) | |||
452 | if (!ctx->adev) | 457 | if (!ctx->adev) |
453 | return; | 458 | return; |
454 | 459 | ||
455 | for (i = 0; i < ctx->adev->num_rings; i++) | 460 | for (i = 0; i < ctx->adev->num_rings; i++) { |
461 | |||
462 | if (ctx->adev->rings[i] == &ctx->adev->gfx.kiq.ring) | ||
463 | continue; | ||
464 | |||
456 | if (kref_read(&ctx->refcount) == 1) | 465 | if (kref_read(&ctx->refcount) == 1) |
457 | drm_sched_entity_do_release(&ctx->adev->rings[i]->sched, | 466 | drm_sched_entity_do_release(&ctx->adev->rings[i]->sched, |
458 | &ctx->rings[i].entity); | 467 | &ctx->rings[i].entity); |
459 | else | 468 | else |
460 | DRM_ERROR("ctx %p is still alive\n", ctx); | 469 | DRM_ERROR("ctx %p is still alive\n", ctx); |
470 | } | ||
461 | } | 471 | } |
462 | } | 472 | } |
463 | 473 | ||
@@ -474,12 +484,17 @@ void amdgpu_ctx_mgr_entity_cleanup(struct amdgpu_ctx_mgr *mgr) | |||
474 | if (!ctx->adev) | 484 | if (!ctx->adev) |
475 | return; | 485 | return; |
476 | 486 | ||
477 | for (i = 0; i < ctx->adev->num_rings; i++) | 487 | for (i = 0; i < ctx->adev->num_rings; i++) { |
488 | |||
489 | if (ctx->adev->rings[i] == &ctx->adev->gfx.kiq.ring) | ||
490 | continue; | ||
491 | |||
478 | if (kref_read(&ctx->refcount) == 1) | 492 | if (kref_read(&ctx->refcount) == 1) |
479 | drm_sched_entity_cleanup(&ctx->adev->rings[i]->sched, | 493 | drm_sched_entity_cleanup(&ctx->adev->rings[i]->sched, |
480 | &ctx->rings[i].entity); | 494 | &ctx->rings[i].entity); |
481 | else | 495 | else |
482 | DRM_ERROR("ctx %p is still alive\n", ctx); | 496 | DRM_ERROR("ctx %p is still alive\n", ctx); |
497 | } | ||
483 | } | 498 | } |
484 | } | 499 | } |
485 | 500 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 9fb20a53d5b2..290e279abf0d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -86,6 +86,7 @@ static const char *amdgpu_asic_name[] = { | |||
86 | "VEGAM", | 86 | "VEGAM", |
87 | "VEGA10", | 87 | "VEGA10", |
88 | "VEGA12", | 88 | "VEGA12", |
89 | "VEGA20", | ||
89 | "RAVEN", | 90 | "RAVEN", |
90 | "LAST", | 91 | "LAST", |
91 | }; | 92 | }; |
@@ -1387,6 +1388,7 @@ static int amdgpu_device_parse_gpu_info_fw(struct amdgpu_device *adev) | |||
1387 | case CHIP_KABINI: | 1388 | case CHIP_KABINI: |
1388 | case CHIP_MULLINS: | 1389 | case CHIP_MULLINS: |
1389 | #endif | 1390 | #endif |
1391 | case CHIP_VEGA20: | ||
1390 | default: | 1392 | default: |
1391 | return 0; | 1393 | return 0; |
1392 | case CHIP_VEGA10: | 1394 | case CHIP_VEGA10: |
@@ -1521,6 +1523,7 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) | |||
1521 | #endif | 1523 | #endif |
1522 | case CHIP_VEGA10: | 1524 | case CHIP_VEGA10: |
1523 | case CHIP_VEGA12: | 1525 | case CHIP_VEGA12: |
1526 | case CHIP_VEGA20: | ||
1524 | case CHIP_RAVEN: | 1527 | case CHIP_RAVEN: |
1525 | if (adev->asic_type == CHIP_RAVEN) | 1528 | if (adev->asic_type == CHIP_RAVEN) |
1526 | adev->family = AMDGPU_FAMILY_RV; | 1529 | adev->family = AMDGPU_FAMILY_RV; |
@@ -1715,6 +1718,7 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev) | |||
1715 | /* skip CG for VCE/UVD, it's handled specially */ | 1718 | /* skip CG for VCE/UVD, it's handled specially */ |
1716 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && | 1719 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && |
1717 | adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCE && | 1720 | adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCE && |
1721 | adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCN && | ||
1718 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { | 1722 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { |
1719 | /* enable clockgating to save power */ | 1723 | /* enable clockgating to save power */ |
1720 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, | 1724 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, |
@@ -1814,6 +1818,7 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) | |||
1814 | 1818 | ||
1815 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && | 1819 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && |
1816 | adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCE && | 1820 | adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCE && |
1821 | adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCN && | ||
1817 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { | 1822 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { |
1818 | /* ungate blocks before hw fini so that we can shutdown the blocks safely */ | 1823 | /* ungate blocks before hw fini so that we can shutdown the blocks safely */ |
1819 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, | 1824 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, |
@@ -2155,6 +2160,7 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type) | |||
2155 | case CHIP_FIJI: | 2160 | case CHIP_FIJI: |
2156 | case CHIP_VEGA10: | 2161 | case CHIP_VEGA10: |
2157 | case CHIP_VEGA12: | 2162 | case CHIP_VEGA12: |
2163 | case CHIP_VEGA20: | ||
2158 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | 2164 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) |
2159 | case CHIP_RAVEN: | 2165 | case CHIP_RAVEN: |
2160 | #endif | 2166 | #endif |
@@ -3172,7 +3178,6 @@ error: | |||
3172 | int amdgpu_device_gpu_recover(struct amdgpu_device *adev, | 3178 | int amdgpu_device_gpu_recover(struct amdgpu_device *adev, |
3173 | struct amdgpu_job *job, bool force) | 3179 | struct amdgpu_job *job, bool force) |
3174 | { | 3180 | { |
3175 | struct drm_atomic_state *state = NULL; | ||
3176 | int i, r, resched; | 3181 | int i, r, resched; |
3177 | 3182 | ||
3178 | if (!force && !amdgpu_device_ip_check_soft_reset(adev)) { | 3183 | if (!force && !amdgpu_device_ip_check_soft_reset(adev)) { |
@@ -3195,10 +3200,6 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, | |||
3195 | /* block TTM */ | 3200 | /* block TTM */ |
3196 | resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev); | 3201 | resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev); |
3197 | 3202 | ||
3198 | /* store modesetting */ | ||
3199 | if (amdgpu_device_has_dc_support(adev)) | ||
3200 | state = drm_atomic_helper_suspend(adev->ddev); | ||
3201 | |||
3202 | /* block all schedulers and reset given job's ring */ | 3203 | /* block all schedulers and reset given job's ring */ |
3203 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { | 3204 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { |
3204 | struct amdgpu_ring *ring = adev->rings[i]; | 3205 | struct amdgpu_ring *ring = adev->rings[i]; |
@@ -3238,10 +3239,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, | |||
3238 | kthread_unpark(ring->sched.thread); | 3239 | kthread_unpark(ring->sched.thread); |
3239 | } | 3240 | } |
3240 | 3241 | ||
3241 | if (amdgpu_device_has_dc_support(adev)) { | 3242 | if (!amdgpu_device_has_dc_support(adev)) { |
3242 | if (drm_atomic_helper_resume(adev->ddev, state)) | ||
3243 | dev_info(adev->dev, "drm resume failed:%d\n", r); | ||
3244 | } else { | ||
3245 | drm_helper_resume_force_mode(adev->ddev); | 3243 | drm_helper_resume_force_mode(adev->ddev); |
3246 | } | 3244 | } |
3247 | 3245 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 739e7e09c8b0..b0bf2f24da48 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | |||
@@ -560,6 +560,13 @@ static const struct pci_device_id pciidlist[] = { | |||
560 | {0x1002, 0x69A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12}, | 560 | {0x1002, 0x69A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12}, |
561 | {0x1002, 0x69A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12}, | 561 | {0x1002, 0x69A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12}, |
562 | {0x1002, 0x69AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12}, | 562 | {0x1002, 0x69AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12}, |
563 | /* Vega 20 */ | ||
564 | {0x1002, 0x66A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT}, | ||
565 | {0x1002, 0x66A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT}, | ||
566 | {0x1002, 0x66A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT}, | ||
567 | {0x1002, 0x66A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT}, | ||
568 | {0x1002, 0x66A7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT}, | ||
569 | {0x1002, 0x66AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT}, | ||
563 | /* Raven */ | 570 | /* Raven */ |
564 | {0x1002, 0x15dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RAVEN|AMD_IS_APU}, | 571 | {0x1002, 0x15dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RAVEN|AMD_IS_APU}, |
565 | 572 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index d09fcab2398f..39ec6b8890a1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | |||
@@ -376,14 +376,14 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring, | |||
376 | struct amdgpu_device *adev = ring->adev; | 376 | struct amdgpu_device *adev = ring->adev; |
377 | uint64_t index; | 377 | uint64_t index; |
378 | 378 | ||
379 | if (ring != &adev->uvd.ring) { | 379 | if (ring != &adev->uvd.inst[ring->me].ring) { |
380 | ring->fence_drv.cpu_addr = &adev->wb.wb[ring->fence_offs]; | 380 | ring->fence_drv.cpu_addr = &adev->wb.wb[ring->fence_offs]; |
381 | ring->fence_drv.gpu_addr = adev->wb.gpu_addr + (ring->fence_offs * 4); | 381 | ring->fence_drv.gpu_addr = adev->wb.gpu_addr + (ring->fence_offs * 4); |
382 | } else { | 382 | } else { |
383 | /* put fence directly behind firmware */ | 383 | /* put fence directly behind firmware */ |
384 | index = ALIGN(adev->uvd.fw->size, 8); | 384 | index = ALIGN(adev->uvd.fw->size, 8); |
385 | ring->fence_drv.cpu_addr = adev->uvd.cpu_addr + index; | 385 | ring->fence_drv.cpu_addr = adev->uvd.inst[ring->me].cpu_addr + index; |
386 | ring->fence_drv.gpu_addr = adev->uvd.gpu_addr + index; | 386 | ring->fence_drv.gpu_addr = adev->uvd.inst[ring->me].gpu_addr + index; |
387 | } | 387 | } |
388 | amdgpu_fence_write(ring, atomic_read(&ring->fence_drv.last_seq)); | 388 | amdgpu_fence_write(ring, atomic_read(&ring->fence_drv.last_seq)); |
389 | amdgpu_irq_get(adev, irq_src, irq_type); | 389 | amdgpu_irq_get(adev, irq_src, irq_type); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index eb4785e51573..91517b166a3b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -286,7 +286,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
286 | struct drm_crtc *crtc; | 286 | struct drm_crtc *crtc; |
287 | uint32_t ui32 = 0; | 287 | uint32_t ui32 = 0; |
288 | uint64_t ui64 = 0; | 288 | uint64_t ui64 = 0; |
289 | int i, found; | 289 | int i, j, found; |
290 | int ui32_size = sizeof(ui32); | 290 | int ui32_size = sizeof(ui32); |
291 | 291 | ||
292 | if (!info->return_size || !info->return_pointer) | 292 | if (!info->return_size || !info->return_pointer) |
@@ -348,7 +348,8 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
348 | break; | 348 | break; |
349 | case AMDGPU_HW_IP_UVD: | 349 | case AMDGPU_HW_IP_UVD: |
350 | type = AMD_IP_BLOCK_TYPE_UVD; | 350 | type = AMD_IP_BLOCK_TYPE_UVD; |
351 | ring_mask = adev->uvd.ring.ready ? 1 : 0; | 351 | for (i = 0; i < adev->uvd.num_uvd_inst; i++) |
352 | ring_mask |= ((adev->uvd.inst[i].ring.ready ? 1 : 0) << i); | ||
352 | ib_start_alignment = AMDGPU_GPU_PAGE_SIZE; | 353 | ib_start_alignment = AMDGPU_GPU_PAGE_SIZE; |
353 | ib_size_alignment = 16; | 354 | ib_size_alignment = 16; |
354 | break; | 355 | break; |
@@ -361,8 +362,11 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
361 | break; | 362 | break; |
362 | case AMDGPU_HW_IP_UVD_ENC: | 363 | case AMDGPU_HW_IP_UVD_ENC: |
363 | type = AMD_IP_BLOCK_TYPE_UVD; | 364 | type = AMD_IP_BLOCK_TYPE_UVD; |
364 | for (i = 0; i < adev->uvd.num_enc_rings; i++) | 365 | for (i = 0; i < adev->uvd.num_uvd_inst; i++) |
365 | ring_mask |= ((adev->uvd.ring_enc[i].ready ? 1 : 0) << i); | 366 | for (j = 0; j < adev->uvd.num_enc_rings; j++) |
367 | ring_mask |= | ||
368 | ((adev->uvd.inst[i].ring_enc[j].ready ? 1 : 0) << | ||
369 | (j + i * adev->uvd.num_enc_rings)); | ||
366 | ib_start_alignment = AMDGPU_GPU_PAGE_SIZE; | 370 | ib_start_alignment = AMDGPU_GPU_PAGE_SIZE; |
367 | ib_size_alignment = 1; | 371 | ib_size_alignment = 1; |
368 | break; | 372 | break; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index c7d43e064fc7..9f1a5bd39ae8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | |||
@@ -52,6 +52,7 @@ static int psp_sw_init(void *handle) | |||
52 | switch (adev->asic_type) { | 52 | switch (adev->asic_type) { |
53 | case CHIP_VEGA10: | 53 | case CHIP_VEGA10: |
54 | case CHIP_VEGA12: | 54 | case CHIP_VEGA12: |
55 | case CHIP_VEGA20: | ||
55 | psp_v3_1_set_psp_funcs(psp); | 56 | psp_v3_1_set_psp_funcs(psp); |
56 | break; | 57 | break; |
57 | case CHIP_RAVEN: | 58 | case CHIP_RAVEN: |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c index 262c1267249e..8af16e81c7d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_queue_mgr.c | |||
@@ -66,6 +66,8 @@ static int amdgpu_identity_map(struct amdgpu_device *adev, | |||
66 | u32 ring, | 66 | u32 ring, |
67 | struct amdgpu_ring **out_ring) | 67 | struct amdgpu_ring **out_ring) |
68 | { | 68 | { |
69 | u32 instance; | ||
70 | |||
69 | switch (mapper->hw_ip) { | 71 | switch (mapper->hw_ip) { |
70 | case AMDGPU_HW_IP_GFX: | 72 | case AMDGPU_HW_IP_GFX: |
71 | *out_ring = &adev->gfx.gfx_ring[ring]; | 73 | *out_ring = &adev->gfx.gfx_ring[ring]; |
@@ -77,13 +79,16 @@ static int amdgpu_identity_map(struct amdgpu_device *adev, | |||
77 | *out_ring = &adev->sdma.instance[ring].ring; | 79 | *out_ring = &adev->sdma.instance[ring].ring; |
78 | break; | 80 | break; |
79 | case AMDGPU_HW_IP_UVD: | 81 | case AMDGPU_HW_IP_UVD: |
80 | *out_ring = &adev->uvd.ring; | 82 | instance = ring; |
83 | *out_ring = &adev->uvd.inst[instance].ring; | ||
81 | break; | 84 | break; |
82 | case AMDGPU_HW_IP_VCE: | 85 | case AMDGPU_HW_IP_VCE: |
83 | *out_ring = &adev->vce.ring[ring]; | 86 | *out_ring = &adev->vce.ring[ring]; |
84 | break; | 87 | break; |
85 | case AMDGPU_HW_IP_UVD_ENC: | 88 | case AMDGPU_HW_IP_UVD_ENC: |
86 | *out_ring = &adev->uvd.ring_enc[ring]; | 89 | instance = ring / adev->uvd.num_enc_rings; |
90 | *out_ring = | ||
91 | &adev->uvd.inst[instance].ring_enc[ring%adev->uvd.num_enc_rings]; | ||
87 | break; | 92 | break; |
88 | case AMDGPU_HW_IP_VCN_DEC: | 93 | case AMDGPU_HW_IP_VCN_DEC: |
89 | *out_ring = &adev->vcn.ring_dec; | 94 | *out_ring = &adev->vcn.ring_dec; |
@@ -240,13 +245,14 @@ int amdgpu_queue_mgr_map(struct amdgpu_device *adev, | |||
240 | ip_num_rings = adev->sdma.num_instances; | 245 | ip_num_rings = adev->sdma.num_instances; |
241 | break; | 246 | break; |
242 | case AMDGPU_HW_IP_UVD: | 247 | case AMDGPU_HW_IP_UVD: |
243 | ip_num_rings = 1; | 248 | ip_num_rings = adev->uvd.num_uvd_inst; |
244 | break; | 249 | break; |
245 | case AMDGPU_HW_IP_VCE: | 250 | case AMDGPU_HW_IP_VCE: |
246 | ip_num_rings = adev->vce.num_rings; | 251 | ip_num_rings = adev->vce.num_rings; |
247 | break; | 252 | break; |
248 | case AMDGPU_HW_IP_UVD_ENC: | 253 | case AMDGPU_HW_IP_UVD_ENC: |
249 | ip_num_rings = adev->uvd.num_enc_rings; | 254 | ip_num_rings = |
255 | adev->uvd.num_enc_rings * adev->uvd.num_uvd_inst; | ||
250 | break; | 256 | break; |
251 | case AMDGPU_HW_IP_VCN_DEC: | 257 | case AMDGPU_HW_IP_VCN_DEC: |
252 | ip_num_rings = 1; | 258 | ip_num_rings = 1; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index 49cad08b5c16..c6850b629d0e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | |||
@@ -362,6 +362,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) | |||
362 | 362 | ||
363 | dma_fence_put(ring->vmid_wait); | 363 | dma_fence_put(ring->vmid_wait); |
364 | ring->vmid_wait = NULL; | 364 | ring->vmid_wait = NULL; |
365 | ring->me = 0; | ||
365 | 366 | ||
366 | ring->adev->rings[ring->idx] = NULL; | 367 | ring->adev->rings[ring->idx] = NULL; |
367 | } | 368 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index 4f8dac2d36a5..1513124c5659 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <drm/drm_print.h> | 29 | #include <drm/drm_print.h> |
30 | 30 | ||
31 | /* max number of rings */ | 31 | /* max number of rings */ |
32 | #define AMDGPU_MAX_RINGS 18 | 32 | #define AMDGPU_MAX_RINGS 21 |
33 | #define AMDGPU_MAX_GFX_RINGS 1 | 33 | #define AMDGPU_MAX_GFX_RINGS 1 |
34 | #define AMDGPU_MAX_COMPUTE_RINGS 8 | 34 | #define AMDGPU_MAX_COMPUTE_RINGS 8 |
35 | #define AMDGPU_MAX_VCE_RINGS 3 | 35 | #define AMDGPU_MAX_VCE_RINGS 3 |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 69a2b25b3696..e93a0a237dc3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -63,16 +63,44 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev); | |||
63 | /* | 63 | /* |
64 | * Global memory. | 64 | * Global memory. |
65 | */ | 65 | */ |
66 | |||
67 | /** | ||
68 | * amdgpu_ttm_mem_global_init - Initialize and acquire reference to | ||
69 | * memory object | ||
70 | * | ||
71 | * @ref: Object for initialization. | ||
72 | * | ||
73 | * This is called by drm_global_item_ref() when an object is being | ||
74 | * initialized. | ||
75 | */ | ||
66 | static int amdgpu_ttm_mem_global_init(struct drm_global_reference *ref) | 76 | static int amdgpu_ttm_mem_global_init(struct drm_global_reference *ref) |
67 | { | 77 | { |
68 | return ttm_mem_global_init(ref->object); | 78 | return ttm_mem_global_init(ref->object); |
69 | } | 79 | } |
70 | 80 | ||
81 | /** | ||
82 | * amdgpu_ttm_mem_global_release - Drop reference to a memory object | ||
83 | * | ||
84 | * @ref: Object being removed | ||
85 | * | ||
86 | * This is called by drm_global_item_unref() when an object is being | ||
87 | * released. | ||
88 | */ | ||
71 | static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref) | 89 | static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref) |
72 | { | 90 | { |
73 | ttm_mem_global_release(ref->object); | 91 | ttm_mem_global_release(ref->object); |
74 | } | 92 | } |
75 | 93 | ||
94 | /** | ||
95 | * amdgpu_ttm_global_init - Initialize global TTM memory reference | ||
96 | * structures. | ||
97 | * | ||
98 | * @adev: AMDGPU device for which the global structures need to be | ||
99 | * registered. | ||
100 | * | ||
101 | * This is called as part of the AMDGPU ttm init from amdgpu_ttm_init() | ||
102 | * during bring up. | ||
103 | */ | ||
76 | static int amdgpu_ttm_global_init(struct amdgpu_device *adev) | 104 | static int amdgpu_ttm_global_init(struct amdgpu_device *adev) |
77 | { | 105 | { |
78 | struct drm_global_reference *global_ref; | 106 | struct drm_global_reference *global_ref; |
@@ -80,7 +108,9 @@ static int amdgpu_ttm_global_init(struct amdgpu_device *adev) | |||
80 | struct drm_sched_rq *rq; | 108 | struct drm_sched_rq *rq; |
81 | int r; | 109 | int r; |
82 | 110 | ||
111 | /* ensure reference is false in case init fails */ | ||
83 | adev->mman.mem_global_referenced = false; | 112 | adev->mman.mem_global_referenced = false; |
113 | |||
84 | global_ref = &adev->mman.mem_global_ref; | 114 | global_ref = &adev->mman.mem_global_ref; |
85 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; | 115 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; |
86 | global_ref->size = sizeof(struct ttm_mem_global); | 116 | global_ref->size = sizeof(struct ttm_mem_global); |
@@ -146,6 +176,18 @@ static int amdgpu_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags) | |||
146 | return 0; | 176 | return 0; |
147 | } | 177 | } |
148 | 178 | ||
179 | /** | ||
180 | * amdgpu_init_mem_type - Initialize a memory manager for a specific | ||
181 | * type of memory request. | ||
182 | * | ||
183 | * @bdev: The TTM BO device object (contains a reference to | ||
184 | * amdgpu_device) | ||
185 | * @type: The type of memory requested | ||
186 | * @man: | ||
187 | * | ||
188 | * This is called by ttm_bo_init_mm() when a buffer object is being | ||
189 | * initialized. | ||
190 | */ | ||
149 | static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, | 191 | static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, |
150 | struct ttm_mem_type_manager *man) | 192 | struct ttm_mem_type_manager *man) |
151 | { | 193 | { |
@@ -161,6 +203,7 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, | |||
161 | man->default_caching = TTM_PL_FLAG_CACHED; | 203 | man->default_caching = TTM_PL_FLAG_CACHED; |
162 | break; | 204 | break; |
163 | case TTM_PL_TT: | 205 | case TTM_PL_TT: |
206 | /* GTT memory */ | ||
164 | man->func = &amdgpu_gtt_mgr_func; | 207 | man->func = &amdgpu_gtt_mgr_func; |
165 | man->gpu_offset = adev->gmc.gart_start; | 208 | man->gpu_offset = adev->gmc.gart_start; |
166 | man->available_caching = TTM_PL_MASK_CACHING; | 209 | man->available_caching = TTM_PL_MASK_CACHING; |
@@ -193,6 +236,14 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, | |||
193 | return 0; | 236 | return 0; |
194 | } | 237 | } |
195 | 238 | ||
239 | /** | ||
240 | * amdgpu_evict_flags - Compute placement flags | ||
241 | * | ||
242 | * @bo: The buffer object to evict | ||
243 | * @placement: Possible destination(s) for evicted BO | ||
244 | * | ||
245 | * Fill in placement data when ttm_bo_evict() is called | ||
246 | */ | ||
196 | static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | 247 | static void amdgpu_evict_flags(struct ttm_buffer_object *bo, |
197 | struct ttm_placement *placement) | 248 | struct ttm_placement *placement) |
198 | { | 249 | { |
@@ -204,12 +255,14 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
204 | .flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM | 255 | .flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM |
205 | }; | 256 | }; |
206 | 257 | ||
258 | /* Don't handle scatter gather BOs */ | ||
207 | if (bo->type == ttm_bo_type_sg) { | 259 | if (bo->type == ttm_bo_type_sg) { |
208 | placement->num_placement = 0; | 260 | placement->num_placement = 0; |
209 | placement->num_busy_placement = 0; | 261 | placement->num_busy_placement = 0; |
210 | return; | 262 | return; |
211 | } | 263 | } |
212 | 264 | ||
265 | /* Object isn't an AMDGPU object so ignore */ | ||
213 | if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) { | 266 | if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) { |
214 | placement->placement = &placements; | 267 | placement->placement = &placements; |
215 | placement->busy_placement = &placements; | 268 | placement->busy_placement = &placements; |
@@ -217,10 +270,12 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
217 | placement->num_busy_placement = 1; | 270 | placement->num_busy_placement = 1; |
218 | return; | 271 | return; |
219 | } | 272 | } |
273 | |||
220 | abo = ttm_to_amdgpu_bo(bo); | 274 | abo = ttm_to_amdgpu_bo(bo); |
221 | switch (bo->mem.mem_type) { | 275 | switch (bo->mem.mem_type) { |
222 | case TTM_PL_VRAM: | 276 | case TTM_PL_VRAM: |
223 | if (!adev->mman.buffer_funcs_enabled) { | 277 | if (!adev->mman.buffer_funcs_enabled) { |
278 | /* Move to system memory */ | ||
224 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU); | 279 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU); |
225 | } else if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && | 280 | } else if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && |
226 | !(abo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) && | 281 | !(abo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) && |
@@ -238,6 +293,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
238 | abo->placement.busy_placement = &abo->placements[1]; | 293 | abo->placement.busy_placement = &abo->placements[1]; |
239 | abo->placement.num_busy_placement = 1; | 294 | abo->placement.num_busy_placement = 1; |
240 | } else { | 295 | } else { |
296 | /* Move to GTT memory */ | ||
241 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); | 297 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); |
242 | } | 298 | } |
243 | break; | 299 | break; |
@@ -248,6 +304,15 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
248 | *placement = abo->placement; | 304 | *placement = abo->placement; |
249 | } | 305 | } |
250 | 306 | ||
307 | /** | ||
308 | * amdgpu_verify_access - Verify access for a mmap call | ||
309 | * | ||
310 | * @bo: The buffer object to map | ||
311 | * @filp: The file pointer from the process performing the mmap | ||
312 | * | ||
313 | * This is called by ttm_bo_mmap() to verify whether a process | ||
314 | * has the right to mmap a BO to their process space. | ||
315 | */ | ||
251 | static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp) | 316 | static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp) |
252 | { | 317 | { |
253 | struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo); | 318 | struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo); |
@@ -265,6 +330,15 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp) | |||
265 | filp->private_data); | 330 | filp->private_data); |
266 | } | 331 | } |
267 | 332 | ||
333 | /** | ||
334 | * amdgpu_move_null - Register memory for a buffer object | ||
335 | * | ||
336 | * @bo: The bo to assign the memory to | ||
337 | * @new_mem: The memory to be assigned. | ||
338 | * | ||
339 | * Assign the memory from new_mem to the memory of the buffer object | ||
340 | * bo. | ||
341 | */ | ||
268 | static void amdgpu_move_null(struct ttm_buffer_object *bo, | 342 | static void amdgpu_move_null(struct ttm_buffer_object *bo, |
269 | struct ttm_mem_reg *new_mem) | 343 | struct ttm_mem_reg *new_mem) |
270 | { | 344 | { |
@@ -275,6 +349,10 @@ static void amdgpu_move_null(struct ttm_buffer_object *bo, | |||
275 | new_mem->mm_node = NULL; | 349 | new_mem->mm_node = NULL; |
276 | } | 350 | } |
277 | 351 | ||
352 | /** | ||
353 | * amdgpu_mm_node_addr - Compute the GPU relative offset of a GTT | ||
354 | * buffer. | ||
355 | */ | ||
278 | static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, | 356 | static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, |
279 | struct drm_mm_node *mm_node, | 357 | struct drm_mm_node *mm_node, |
280 | struct ttm_mem_reg *mem) | 358 | struct ttm_mem_reg *mem) |
@@ -289,9 +367,10 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, | |||
289 | } | 367 | } |
290 | 368 | ||
291 | /** | 369 | /** |
292 | * amdgpu_find_mm_node - Helper function finds the drm_mm_node | 370 | * amdgpu_find_mm_node - Helper function finds the drm_mm_node |
293 | * corresponding to @offset. It also modifies the offset to be | 371 | * corresponding to @offset. It also modifies |
294 | * within the drm_mm_node returned | 372 | * the offset to be within the drm_mm_node |
373 | * returned | ||
295 | */ | 374 | */ |
296 | static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem, | 375 | static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem, |
297 | unsigned long *offset) | 376 | unsigned long *offset) |
@@ -430,7 +509,12 @@ error: | |||
430 | return r; | 509 | return r; |
431 | } | 510 | } |
432 | 511 | ||
433 | 512 | /** | |
513 | * amdgpu_move_blit - Copy an entire buffer to another buffer | ||
514 | * | ||
515 | * This is a helper called by amdgpu_bo_move() and | ||
516 | * amdgpu_move_vram_ram() to help move buffers to and from VRAM. | ||
517 | */ | ||
434 | static int amdgpu_move_blit(struct ttm_buffer_object *bo, | 518 | static int amdgpu_move_blit(struct ttm_buffer_object *bo, |
435 | bool evict, bool no_wait_gpu, | 519 | bool evict, bool no_wait_gpu, |
436 | struct ttm_mem_reg *new_mem, | 520 | struct ttm_mem_reg *new_mem, |
@@ -465,6 +549,11 @@ error: | |||
465 | return r; | 549 | return r; |
466 | } | 550 | } |
467 | 551 | ||
552 | /** | ||
553 | * amdgpu_move_vram_ram - Copy VRAM buffer to RAM buffer | ||
554 | * | ||
555 | * Called by amdgpu_bo_move(). | ||
556 | */ | ||
468 | static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict, | 557 | static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict, |
469 | struct ttm_operation_ctx *ctx, | 558 | struct ttm_operation_ctx *ctx, |
470 | struct ttm_mem_reg *new_mem) | 559 | struct ttm_mem_reg *new_mem) |
@@ -477,6 +566,8 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict, | |||
477 | int r; | 566 | int r; |
478 | 567 | ||
479 | adev = amdgpu_ttm_adev(bo->bdev); | 568 | adev = amdgpu_ttm_adev(bo->bdev); |
569 | |||
570 | /* create space/pages for new_mem in GTT space */ | ||
480 | tmp_mem = *new_mem; | 571 | tmp_mem = *new_mem; |
481 | tmp_mem.mm_node = NULL; | 572 | tmp_mem.mm_node = NULL; |
482 | placement.num_placement = 1; | 573 | placement.num_placement = 1; |
@@ -491,25 +582,36 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict, | |||
491 | return r; | 582 | return r; |
492 | } | 583 | } |
493 | 584 | ||
585 | /* set caching flags */ | ||
494 | r = ttm_tt_set_placement_caching(bo->ttm, tmp_mem.placement); | 586 | r = ttm_tt_set_placement_caching(bo->ttm, tmp_mem.placement); |
495 | if (unlikely(r)) { | 587 | if (unlikely(r)) { |
496 | goto out_cleanup; | 588 | goto out_cleanup; |
497 | } | 589 | } |
498 | 590 | ||
591 | /* Bind the memory to the GTT space */ | ||
499 | r = ttm_tt_bind(bo->ttm, &tmp_mem, ctx); | 592 | r = ttm_tt_bind(bo->ttm, &tmp_mem, ctx); |
500 | if (unlikely(r)) { | 593 | if (unlikely(r)) { |
501 | goto out_cleanup; | 594 | goto out_cleanup; |
502 | } | 595 | } |
596 | |||
597 | /* blit VRAM to GTT */ | ||
503 | r = amdgpu_move_blit(bo, true, ctx->no_wait_gpu, &tmp_mem, old_mem); | 598 | r = amdgpu_move_blit(bo, true, ctx->no_wait_gpu, &tmp_mem, old_mem); |
504 | if (unlikely(r)) { | 599 | if (unlikely(r)) { |
505 | goto out_cleanup; | 600 | goto out_cleanup; |
506 | } | 601 | } |
602 | |||
603 | /* move BO (in tmp_mem) to new_mem */ | ||
507 | r = ttm_bo_move_ttm(bo, ctx, new_mem); | 604 | r = ttm_bo_move_ttm(bo, ctx, new_mem); |
508 | out_cleanup: | 605 | out_cleanup: |
509 | ttm_bo_mem_put(bo, &tmp_mem); | 606 | ttm_bo_mem_put(bo, &tmp_mem); |
510 | return r; | 607 | return r; |
511 | } | 608 | } |
512 | 609 | ||
610 | /** | ||
611 | * amdgpu_move_ram_vram - Copy buffer from RAM to VRAM | ||
612 | * | ||
613 | * Called by amdgpu_bo_move(). | ||
614 | */ | ||
513 | static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict, | 615 | static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict, |
514 | struct ttm_operation_ctx *ctx, | 616 | struct ttm_operation_ctx *ctx, |
515 | struct ttm_mem_reg *new_mem) | 617 | struct ttm_mem_reg *new_mem) |
@@ -522,6 +624,8 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict, | |||
522 | int r; | 624 | int r; |
523 | 625 | ||
524 | adev = amdgpu_ttm_adev(bo->bdev); | 626 | adev = amdgpu_ttm_adev(bo->bdev); |
627 | |||
628 | /* make space in GTT for old_mem buffer */ | ||
525 | tmp_mem = *new_mem; | 629 | tmp_mem = *new_mem; |
526 | tmp_mem.mm_node = NULL; | 630 | tmp_mem.mm_node = NULL; |
527 | placement.num_placement = 1; | 631 | placement.num_placement = 1; |
@@ -535,10 +639,14 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict, | |||
535 | if (unlikely(r)) { | 639 | if (unlikely(r)) { |
536 | return r; | 640 | return r; |
537 | } | 641 | } |
642 | |||
643 | /* move/bind old memory to GTT space */ | ||
538 | r = ttm_bo_move_ttm(bo, ctx, &tmp_mem); | 644 | r = ttm_bo_move_ttm(bo, ctx, &tmp_mem); |
539 | if (unlikely(r)) { | 645 | if (unlikely(r)) { |
540 | goto out_cleanup; | 646 | goto out_cleanup; |
541 | } | 647 | } |
648 | |||
649 | /* copy to VRAM */ | ||
542 | r = amdgpu_move_blit(bo, true, ctx->no_wait_gpu, new_mem, old_mem); | 650 | r = amdgpu_move_blit(bo, true, ctx->no_wait_gpu, new_mem, old_mem); |
543 | if (unlikely(r)) { | 651 | if (unlikely(r)) { |
544 | goto out_cleanup; | 652 | goto out_cleanup; |
@@ -548,6 +656,11 @@ out_cleanup: | |||
548 | return r; | 656 | return r; |
549 | } | 657 | } |
550 | 658 | ||
659 | /** | ||
660 | * amdgpu_bo_move - Move a buffer object to a new memory location | ||
661 | * | ||
662 | * Called by ttm_bo_handle_move_mem() | ||
663 | */ | ||
551 | static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, | 664 | static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, |
552 | struct ttm_operation_ctx *ctx, | 665 | struct ttm_operation_ctx *ctx, |
553 | struct ttm_mem_reg *new_mem) | 666 | struct ttm_mem_reg *new_mem) |
@@ -613,6 +726,11 @@ memcpy: | |||
613 | return 0; | 726 | return 0; |
614 | } | 727 | } |
615 | 728 | ||
729 | /** | ||
730 | * amdgpu_ttm_io_mem_reserve - Reserve a block of memory during a fault | ||
731 | * | ||
732 | * Called by ttm_mem_io_reserve() ultimately via ttm_bo_vm_fault() | ||
733 | */ | ||
616 | static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) | 734 | static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) |
617 | { | 735 | { |
618 | struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; | 736 | struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; |
@@ -690,6 +808,14 @@ struct amdgpu_ttm_tt { | |||
690 | uint32_t last_set_pages; | 808 | uint32_t last_set_pages; |
691 | }; | 809 | }; |
692 | 810 | ||
811 | /** | ||
812 | * amdgpu_ttm_tt_get_user_pages - Pin pages of memory pointed to | ||
813 | * by a USERPTR pointer to memory | ||
814 | * | ||
815 | * Called by amdgpu_gem_userptr_ioctl() and amdgpu_cs_parser_bos(). | ||
816 | * This provides a wrapper around the get_user_pages() call to provide | ||
817 | * device accessible pages that back user memory. | ||
818 | */ | ||
693 | int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages) | 819 | int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages) |
694 | { | 820 | { |
695 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 821 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
@@ -719,6 +845,7 @@ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages) | |||
719 | } | 845 | } |
720 | } | 846 | } |
721 | 847 | ||
848 | /* loop enough times using contiguous pages of memory */ | ||
722 | do { | 849 | do { |
723 | unsigned num_pages = ttm->num_pages - pinned; | 850 | unsigned num_pages = ttm->num_pages - pinned; |
724 | uint64_t userptr = gtt->userptr + pinned * PAGE_SIZE; | 851 | uint64_t userptr = gtt->userptr + pinned * PAGE_SIZE; |
@@ -757,6 +884,14 @@ release_pages: | |||
757 | return r; | 884 | return r; |
758 | } | 885 | } |
759 | 886 | ||
887 | /** | ||
888 | * amdgpu_ttm_tt_set_user_pages - Copy pages in, putting old pages | ||
889 | * as necessary. | ||
890 | * | ||
891 | * Called by amdgpu_cs_list_validate(). This creates the page list | ||
892 | * that backs user memory and will ultimately be mapped into the device | ||
893 | * address space. | ||
894 | */ | ||
760 | void amdgpu_ttm_tt_set_user_pages(struct ttm_tt *ttm, struct page **pages) | 895 | void amdgpu_ttm_tt_set_user_pages(struct ttm_tt *ttm, struct page **pages) |
761 | { | 896 | { |
762 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 897 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
@@ -771,6 +906,11 @@ void amdgpu_ttm_tt_set_user_pages(struct ttm_tt *ttm, struct page **pages) | |||
771 | } | 906 | } |
772 | } | 907 | } |
773 | 908 | ||
909 | /** | ||
910 | * amdgpu_ttm_tt_mark_user_page - Mark pages as dirty | ||
911 | * | ||
912 | * Called while unpinning userptr pages | ||
913 | */ | ||
774 | void amdgpu_ttm_tt_mark_user_pages(struct ttm_tt *ttm) | 914 | void amdgpu_ttm_tt_mark_user_pages(struct ttm_tt *ttm) |
775 | { | 915 | { |
776 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 916 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
@@ -789,7 +929,12 @@ void amdgpu_ttm_tt_mark_user_pages(struct ttm_tt *ttm) | |||
789 | } | 929 | } |
790 | } | 930 | } |
791 | 931 | ||
792 | /* prepare the sg table with the user pages */ | 932 | /** |
933 | * amdgpu_ttm_tt_pin_userptr - prepare the sg table with the | ||
934 | * user pages | ||
935 | * | ||
936 | * Called by amdgpu_ttm_backend_bind() | ||
937 | **/ | ||
793 | static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm) | 938 | static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm) |
794 | { | 939 | { |
795 | struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); | 940 | struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); |
@@ -801,17 +946,20 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm) | |||
801 | enum dma_data_direction direction = write ? | 946 | enum dma_data_direction direction = write ? |
802 | DMA_BIDIRECTIONAL : DMA_TO_DEVICE; | 947 | DMA_BIDIRECTIONAL : DMA_TO_DEVICE; |
803 | 948 | ||
949 | /* Allocate an SG array and squash pages into it */ | ||
804 | r = sg_alloc_table_from_pages(ttm->sg, ttm->pages, ttm->num_pages, 0, | 950 | r = sg_alloc_table_from_pages(ttm->sg, ttm->pages, ttm->num_pages, 0, |
805 | ttm->num_pages << PAGE_SHIFT, | 951 | ttm->num_pages << PAGE_SHIFT, |
806 | GFP_KERNEL); | 952 | GFP_KERNEL); |
807 | if (r) | 953 | if (r) |
808 | goto release_sg; | 954 | goto release_sg; |
809 | 955 | ||
956 | /* Map SG to device */ | ||
810 | r = -ENOMEM; | 957 | r = -ENOMEM; |
811 | nents = dma_map_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, direction); | 958 | nents = dma_map_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, direction); |
812 | if (nents != ttm->sg->nents) | 959 | if (nents != ttm->sg->nents) |
813 | goto release_sg; | 960 | goto release_sg; |
814 | 961 | ||
962 | /* convert SG to linear array of pages and dma addresses */ | ||
815 | drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages, | 963 | drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages, |
816 | gtt->ttm.dma_address, ttm->num_pages); | 964 | gtt->ttm.dma_address, ttm->num_pages); |
817 | 965 | ||
@@ -822,6 +970,9 @@ release_sg: | |||
822 | return r; | 970 | return r; |
823 | } | 971 | } |
824 | 972 | ||
973 | /** | ||
974 | * amdgpu_ttm_tt_unpin_userptr - Unpin and unmap userptr pages | ||
975 | */ | ||
825 | static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm) | 976 | static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm) |
826 | { | 977 | { |
827 | struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); | 978 | struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); |
@@ -835,9 +986,10 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm) | |||
835 | if (!ttm->sg->sgl) | 986 | if (!ttm->sg->sgl) |
836 | return; | 987 | return; |
837 | 988 | ||
838 | /* free the sg table and pages again */ | 989 | /* unmap the pages mapped to the device */ |
839 | dma_unmap_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, direction); | 990 | dma_unmap_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, direction); |
840 | 991 | ||
992 | /* mark the pages as dirty */ | ||
841 | amdgpu_ttm_tt_mark_user_pages(ttm); | 993 | amdgpu_ttm_tt_mark_user_pages(ttm); |
842 | 994 | ||
843 | sg_free_table(ttm->sg); | 995 | sg_free_table(ttm->sg); |
@@ -882,6 +1034,12 @@ gart_bind_fail: | |||
882 | return r; | 1034 | return r; |
883 | } | 1035 | } |
884 | 1036 | ||
1037 | /** | ||
1038 | * amdgpu_ttm_backend_bind - Bind GTT memory | ||
1039 | * | ||
1040 | * Called by ttm_tt_bind() on behalf of ttm_bo_handle_move_mem(). | ||
1041 | * This handles binding GTT memory to the device address space. | ||
1042 | */ | ||
885 | static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | 1043 | static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, |
886 | struct ttm_mem_reg *bo_mem) | 1044 | struct ttm_mem_reg *bo_mem) |
887 | { | 1045 | { |
@@ -912,7 +1070,10 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | |||
912 | return 0; | 1070 | return 0; |
913 | } | 1071 | } |
914 | 1072 | ||
1073 | /* compute PTE flags relevant to this BO memory */ | ||
915 | flags = amdgpu_ttm_tt_pte_flags(adev, ttm, bo_mem); | 1074 | flags = amdgpu_ttm_tt_pte_flags(adev, ttm, bo_mem); |
1075 | |||
1076 | /* bind pages into GART page tables */ | ||
916 | gtt->offset = (u64)bo_mem->start << PAGE_SHIFT; | 1077 | gtt->offset = (u64)bo_mem->start << PAGE_SHIFT; |
917 | r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages, | 1078 | r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages, |
918 | ttm->pages, gtt->ttm.dma_address, flags); | 1079 | ttm->pages, gtt->ttm.dma_address, flags); |
@@ -923,6 +1084,9 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | |||
923 | return r; | 1084 | return r; |
924 | } | 1085 | } |
925 | 1086 | ||
1087 | /** | ||
1088 | * amdgpu_ttm_alloc_gart - Allocate GART memory for buffer object | ||
1089 | */ | ||
926 | int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) | 1090 | int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) |
927 | { | 1091 | { |
928 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); | 1092 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); |
@@ -938,6 +1102,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) | |||
938 | amdgpu_gtt_mgr_has_gart_addr(&bo->mem)) | 1102 | amdgpu_gtt_mgr_has_gart_addr(&bo->mem)) |
939 | return 0; | 1103 | return 0; |
940 | 1104 | ||
1105 | /* allocate GTT space */ | ||
941 | tmp = bo->mem; | 1106 | tmp = bo->mem; |
942 | tmp.mm_node = NULL; | 1107 | tmp.mm_node = NULL; |
943 | placement.num_placement = 1; | 1108 | placement.num_placement = 1; |
@@ -953,7 +1118,10 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) | |||
953 | if (unlikely(r)) | 1118 | if (unlikely(r)) |
954 | return r; | 1119 | return r; |
955 | 1120 | ||
1121 | /* compute PTE flags for this buffer object */ | ||
956 | flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp); | 1122 | flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp); |
1123 | |||
1124 | /* Bind pages */ | ||
957 | gtt->offset = (u64)tmp.start << PAGE_SHIFT; | 1125 | gtt->offset = (u64)tmp.start << PAGE_SHIFT; |
958 | r = amdgpu_ttm_gart_bind(adev, bo, flags); | 1126 | r = amdgpu_ttm_gart_bind(adev, bo, flags); |
959 | if (unlikely(r)) { | 1127 | if (unlikely(r)) { |
@@ -969,6 +1137,12 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) | |||
969 | return 0; | 1137 | return 0; |
970 | } | 1138 | } |
971 | 1139 | ||
1140 | /** | ||
1141 | * amdgpu_ttm_recover_gart - Rebind GTT pages | ||
1142 | * | ||
1143 | * Called by amdgpu_gtt_mgr_recover() from amdgpu_device_reset() to | ||
1144 | * rebind GTT pages during a GPU reset. | ||
1145 | */ | ||
972 | int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo) | 1146 | int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo) |
973 | { | 1147 | { |
974 | struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); | 1148 | struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); |
@@ -984,12 +1158,19 @@ int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo) | |||
984 | return r; | 1158 | return r; |
985 | } | 1159 | } |
986 | 1160 | ||
1161 | /** | ||
1162 | * amdgpu_ttm_backend_unbind - Unbind GTT mapped pages | ||
1163 | * | ||
1164 | * Called by ttm_tt_unbind() on behalf of ttm_bo_move_ttm() and | ||
1165 | * ttm_tt_destroy(). | ||
1166 | */ | ||
987 | static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm) | 1167 | static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm) |
988 | { | 1168 | { |
989 | struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); | 1169 | struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); |
990 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 1170 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
991 | int r; | 1171 | int r; |
992 | 1172 | ||
1173 | /* if the pages have userptr pinning then clear that first */ | ||
993 | if (gtt->userptr) | 1174 | if (gtt->userptr) |
994 | amdgpu_ttm_tt_unpin_userptr(ttm); | 1175 | amdgpu_ttm_tt_unpin_userptr(ttm); |
995 | 1176 | ||
@@ -1021,6 +1202,13 @@ static struct ttm_backend_func amdgpu_backend_func = { | |||
1021 | .destroy = &amdgpu_ttm_backend_destroy, | 1202 | .destroy = &amdgpu_ttm_backend_destroy, |
1022 | }; | 1203 | }; |
1023 | 1204 | ||
1205 | /** | ||
1206 | * amdgpu_ttm_tt_create - Create a ttm_tt object for a given BO | ||
1207 | * | ||
1208 | * @bo: The buffer object to create a GTT ttm_tt object around | ||
1209 | * | ||
1210 | * Called by ttm_tt_create(). | ||
1211 | */ | ||
1024 | static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo, | 1212 | static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo, |
1025 | uint32_t page_flags) | 1213 | uint32_t page_flags) |
1026 | { | 1214 | { |
@@ -1034,6 +1222,8 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo, | |||
1034 | return NULL; | 1222 | return NULL; |
1035 | } | 1223 | } |
1036 | gtt->ttm.ttm.func = &amdgpu_backend_func; | 1224 | gtt->ttm.ttm.func = &amdgpu_backend_func; |
1225 | |||
1226 | /* allocate space for the uninitialized page entries */ | ||
1037 | if (ttm_sg_tt_init(>t->ttm, bo, page_flags)) { | 1227 | if (ttm_sg_tt_init(>t->ttm, bo, page_flags)) { |
1038 | kfree(gtt); | 1228 | kfree(gtt); |
1039 | return NULL; | 1229 | return NULL; |
@@ -1041,6 +1231,12 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo, | |||
1041 | return >t->ttm.ttm; | 1231 | return >t->ttm.ttm; |
1042 | } | 1232 | } |
1043 | 1233 | ||
1234 | /** | ||
1235 | * amdgpu_ttm_tt_populate - Map GTT pages visible to the device | ||
1236 | * | ||
1237 | * Map the pages of a ttm_tt object to an address space visible | ||
1238 | * to the underlying device. | ||
1239 | */ | ||
1044 | static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, | 1240 | static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, |
1045 | struct ttm_operation_ctx *ctx) | 1241 | struct ttm_operation_ctx *ctx) |
1046 | { | 1242 | { |
@@ -1048,6 +1244,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, | |||
1048 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 1244 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
1049 | bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); | 1245 | bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); |
1050 | 1246 | ||
1247 | /* user pages are bound by amdgpu_ttm_tt_pin_userptr() */ | ||
1051 | if (gtt && gtt->userptr) { | 1248 | if (gtt && gtt->userptr) { |
1052 | ttm->sg = kzalloc(sizeof(struct sg_table), GFP_KERNEL); | 1249 | ttm->sg = kzalloc(sizeof(struct sg_table), GFP_KERNEL); |
1053 | if (!ttm->sg) | 1250 | if (!ttm->sg) |
@@ -1072,9 +1269,17 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, | |||
1072 | } | 1269 | } |
1073 | #endif | 1270 | #endif |
1074 | 1271 | ||
1272 | /* fall back to generic helper to populate the page array | ||
1273 | * and map them to the device */ | ||
1075 | return ttm_populate_and_map_pages(adev->dev, >t->ttm, ctx); | 1274 | return ttm_populate_and_map_pages(adev->dev, >t->ttm, ctx); |
1076 | } | 1275 | } |
1077 | 1276 | ||
1277 | /** | ||
1278 | * amdgpu_ttm_tt_unpopulate - unmap GTT pages and unpopulate page arrays | ||
1279 | * | ||
1280 | * Unmaps pages of a ttm_tt object from the device address space and | ||
1281 | * unpopulates the page array backing it. | ||
1282 | */ | ||
1078 | static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) | 1283 | static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) |
1079 | { | 1284 | { |
1080 | struct amdgpu_device *adev; | 1285 | struct amdgpu_device *adev; |
@@ -1100,9 +1305,21 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) | |||
1100 | } | 1305 | } |
1101 | #endif | 1306 | #endif |
1102 | 1307 | ||
1308 | /* fall back to generic helper to unmap and unpopulate array */ | ||
1103 | ttm_unmap_and_unpopulate_pages(adev->dev, >t->ttm); | 1309 | ttm_unmap_and_unpopulate_pages(adev->dev, >t->ttm); |
1104 | } | 1310 | } |
1105 | 1311 | ||
1312 | /** | ||
1313 | * amdgpu_ttm_tt_set_userptr - Initialize userptr GTT ttm_tt | ||
1314 | * for the current task | ||
1315 | * | ||
1316 | * @ttm: The ttm_tt object to bind this userptr object to | ||
1317 | * @addr: The address in the current tasks VM space to use | ||
1318 | * @flags: Requirements of userptr object. | ||
1319 | * | ||
1320 | * Called by amdgpu_gem_userptr_ioctl() to bind userptr pages | ||
1321 | * to current task | ||
1322 | */ | ||
1106 | int amdgpu_ttm_tt_set_userptr(struct ttm_tt *ttm, uint64_t addr, | 1323 | int amdgpu_ttm_tt_set_userptr(struct ttm_tt *ttm, uint64_t addr, |
1107 | uint32_t flags) | 1324 | uint32_t flags) |
1108 | { | 1325 | { |
@@ -1127,6 +1344,9 @@ int amdgpu_ttm_tt_set_userptr(struct ttm_tt *ttm, uint64_t addr, | |||
1127 | return 0; | 1344 | return 0; |
1128 | } | 1345 | } |
1129 | 1346 | ||
1347 | /** | ||
1348 | * amdgpu_ttm_tt_get_usermm - Return memory manager for ttm_tt object | ||
1349 | */ | ||
1130 | struct mm_struct *amdgpu_ttm_tt_get_usermm(struct ttm_tt *ttm) | 1350 | struct mm_struct *amdgpu_ttm_tt_get_usermm(struct ttm_tt *ttm) |
1131 | { | 1351 | { |
1132 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 1352 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
@@ -1140,6 +1360,12 @@ struct mm_struct *amdgpu_ttm_tt_get_usermm(struct ttm_tt *ttm) | |||
1140 | return gtt->usertask->mm; | 1360 | return gtt->usertask->mm; |
1141 | } | 1361 | } |
1142 | 1362 | ||
1363 | /** | ||
1364 | * amdgpu_ttm_tt_affect_userptr - Determine if a ttm_tt object lays | ||
1365 | * inside an address range for the | ||
1366 | * current task. | ||
1367 | * | ||
1368 | */ | ||
1143 | bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start, | 1369 | bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start, |
1144 | unsigned long end) | 1370 | unsigned long end) |
1145 | { | 1371 | { |
@@ -1150,10 +1376,16 @@ bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start, | |||
1150 | if (gtt == NULL || !gtt->userptr) | 1376 | if (gtt == NULL || !gtt->userptr) |
1151 | return false; | 1377 | return false; |
1152 | 1378 | ||
1379 | /* Return false if no part of the ttm_tt object lies within | ||
1380 | * the range | ||
1381 | */ | ||
1153 | size = (unsigned long)gtt->ttm.ttm.num_pages * PAGE_SIZE; | 1382 | size = (unsigned long)gtt->ttm.ttm.num_pages * PAGE_SIZE; |
1154 | if (gtt->userptr > end || gtt->userptr + size <= start) | 1383 | if (gtt->userptr > end || gtt->userptr + size <= start) |
1155 | return false; | 1384 | return false; |
1156 | 1385 | ||
1386 | /* Search the lists of tasks that hold this mapping and see | ||
1387 | * if current is one of them. If it is return false. | ||
1388 | */ | ||
1157 | spin_lock(>t->guptasklock); | 1389 | spin_lock(>t->guptasklock); |
1158 | list_for_each_entry(entry, >t->guptasks, list) { | 1390 | list_for_each_entry(entry, >t->guptasks, list) { |
1159 | if (entry->task == current) { | 1391 | if (entry->task == current) { |
@@ -1168,6 +1400,10 @@ bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start, | |||
1168 | return true; | 1400 | return true; |
1169 | } | 1401 | } |
1170 | 1402 | ||
1403 | /** | ||
1404 | * amdgpu_ttm_tt_userptr_invalidated - Has the ttm_tt object been | ||
1405 | * invalidated? | ||
1406 | */ | ||
1171 | bool amdgpu_ttm_tt_userptr_invalidated(struct ttm_tt *ttm, | 1407 | bool amdgpu_ttm_tt_userptr_invalidated(struct ttm_tt *ttm, |
1172 | int *last_invalidated) | 1408 | int *last_invalidated) |
1173 | { | 1409 | { |
@@ -1178,6 +1414,12 @@ bool amdgpu_ttm_tt_userptr_invalidated(struct ttm_tt *ttm, | |||
1178 | return prev_invalidated != *last_invalidated; | 1414 | return prev_invalidated != *last_invalidated; |
1179 | } | 1415 | } |
1180 | 1416 | ||
1417 | /** | ||
1418 | * amdgpu_ttm_tt_userptr_needs_pages - Have the pages backing this | ||
1419 | * ttm_tt object been invalidated | ||
1420 | * since the last time they've | ||
1421 | * been set? | ||
1422 | */ | ||
1181 | bool amdgpu_ttm_tt_userptr_needs_pages(struct ttm_tt *ttm) | 1423 | bool amdgpu_ttm_tt_userptr_needs_pages(struct ttm_tt *ttm) |
1182 | { | 1424 | { |
1183 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 1425 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
@@ -1188,6 +1430,9 @@ bool amdgpu_ttm_tt_userptr_needs_pages(struct ttm_tt *ttm) | |||
1188 | return atomic_read(>t->mmu_invalidations) != gtt->last_set_pages; | 1430 | return atomic_read(>t->mmu_invalidations) != gtt->last_set_pages; |
1189 | } | 1431 | } |
1190 | 1432 | ||
1433 | /** | ||
1434 | * amdgpu_ttm_tt_is_readonly - Is the ttm_tt object read only? | ||
1435 | */ | ||
1191 | bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm) | 1436 | bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm) |
1192 | { | 1437 | { |
1193 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | 1438 | struct amdgpu_ttm_tt *gtt = (void *)ttm; |
@@ -1198,6 +1443,12 @@ bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm) | |||
1198 | return !!(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY); | 1443 | return !!(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY); |
1199 | } | 1444 | } |
1200 | 1445 | ||
1446 | /** | ||
1447 | * amdgpu_ttm_tt_pte_flags - Compute PTE flags for ttm_tt object | ||
1448 | * | ||
1449 | * @ttm: The ttm_tt object to compute the flags for | ||
1450 | * @mem: The memory registry backing this ttm_tt object | ||
1451 | */ | ||
1201 | uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, | 1452 | uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, |
1202 | struct ttm_mem_reg *mem) | 1453 | struct ttm_mem_reg *mem) |
1203 | { | 1454 | { |
@@ -1222,6 +1473,16 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, | |||
1222 | return flags; | 1473 | return flags; |
1223 | } | 1474 | } |
1224 | 1475 | ||
1476 | /** | ||
1477 | * amdgpu_ttm_bo_eviction_valuable - Check to see if we can evict | ||
1478 | * a buffer object. | ||
1479 | * | ||
1480 | * Return true if eviction is sensible. Called by | ||
1481 | * ttm_mem_evict_first() on behalf of ttm_bo_mem_force_space() | ||
1482 | * which tries to evict buffer objects until it can find space | ||
1483 | * for a new object and by ttm_bo_force_list_clean() which is | ||
1484 | * used to clean out a memory space. | ||
1485 | */ | ||
1225 | static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, | 1486 | static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, |
1226 | const struct ttm_place *place) | 1487 | const struct ttm_place *place) |
1227 | { | 1488 | { |
@@ -1268,6 +1529,19 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, | |||
1268 | return ttm_bo_eviction_valuable(bo, place); | 1529 | return ttm_bo_eviction_valuable(bo, place); |
1269 | } | 1530 | } |
1270 | 1531 | ||
1532 | /** | ||
1533 | * amdgpu_ttm_access_memory - Read or Write memory that backs a | ||
1534 | * buffer object. | ||
1535 | * | ||
1536 | * @bo: The buffer object to read/write | ||
1537 | * @offset: Offset into buffer object | ||
1538 | * @buf: Secondary buffer to write/read from | ||
1539 | * @len: Length in bytes of access | ||
1540 | * @write: true if writing | ||
1541 | * | ||
1542 | * This is used to access VRAM that backs a buffer object via MMIO | ||
1543 | * access for debugging purposes. | ||
1544 | */ | ||
1271 | static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo, | 1545 | static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo, |
1272 | unsigned long offset, | 1546 | unsigned long offset, |
1273 | void *buf, int len, int write) | 1547 | void *buf, int len, int write) |
@@ -1444,13 +1718,22 @@ error_create: | |||
1444 | adev->fw_vram_usage.reserved_bo = NULL; | 1718 | adev->fw_vram_usage.reserved_bo = NULL; |
1445 | return r; | 1719 | return r; |
1446 | } | 1720 | } |
1447 | 1721 | /** | |
1722 | * amdgpu_ttm_init - Init the memory management (ttm) as well as | ||
1723 | * various gtt/vram related fields. | ||
1724 | * | ||
1725 | * This initializes all of the memory space pools that the TTM layer | ||
1726 | * will need such as the GTT space (system memory mapped to the device), | ||
1727 | * VRAM (on-board memory), and on-chip memories (GDS, GWS, OA) which | ||
1728 | * can be mapped per VMID. | ||
1729 | */ | ||
1448 | int amdgpu_ttm_init(struct amdgpu_device *adev) | 1730 | int amdgpu_ttm_init(struct amdgpu_device *adev) |
1449 | { | 1731 | { |
1450 | uint64_t gtt_size; | 1732 | uint64_t gtt_size; |
1451 | int r; | 1733 | int r; |
1452 | u64 vis_vram_limit; | 1734 | u64 vis_vram_limit; |
1453 | 1735 | ||
1736 | /* initialize global references for vram/gtt */ | ||
1454 | r = amdgpu_ttm_global_init(adev); | 1737 | r = amdgpu_ttm_global_init(adev); |
1455 | if (r) { | 1738 | if (r) { |
1456 | return r; | 1739 | return r; |
@@ -1471,6 +1754,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1471 | /* We opt to avoid OOM on system pages allocations */ | 1754 | /* We opt to avoid OOM on system pages allocations */ |
1472 | adev->mman.bdev.no_retry = true; | 1755 | adev->mman.bdev.no_retry = true; |
1473 | 1756 | ||
1757 | /* Initialize VRAM pool with all of VRAM divided into pages */ | ||
1474 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, | 1758 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, |
1475 | adev->gmc.real_vram_size >> PAGE_SHIFT); | 1759 | adev->gmc.real_vram_size >> PAGE_SHIFT); |
1476 | if (r) { | 1760 | if (r) { |
@@ -1500,6 +1784,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1500 | return r; | 1784 | return r; |
1501 | } | 1785 | } |
1502 | 1786 | ||
1787 | /* allocate memory as required for VGA | ||
1788 | * This is used for VGA emulation and pre-OS scanout buffers to | ||
1789 | * avoid display artifacts while transitioning between pre-OS | ||
1790 | * and driver. */ | ||
1503 | if (adev->gmc.stolen_size) { | 1791 | if (adev->gmc.stolen_size) { |
1504 | r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE, | 1792 | r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE, |
1505 | AMDGPU_GEM_DOMAIN_VRAM, | 1793 | AMDGPU_GEM_DOMAIN_VRAM, |
@@ -1511,6 +1799,8 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1511 | DRM_INFO("amdgpu: %uM of VRAM memory ready\n", | 1799 | DRM_INFO("amdgpu: %uM of VRAM memory ready\n", |
1512 | (unsigned) (adev->gmc.real_vram_size / (1024 * 1024))); | 1800 | (unsigned) (adev->gmc.real_vram_size / (1024 * 1024))); |
1513 | 1801 | ||
1802 | /* Compute GTT size, either bsaed on 3/4th the size of RAM size | ||
1803 | * or whatever the user passed on module init */ | ||
1514 | if (amdgpu_gtt_size == -1) { | 1804 | if (amdgpu_gtt_size == -1) { |
1515 | struct sysinfo si; | 1805 | struct sysinfo si; |
1516 | 1806 | ||
@@ -1521,6 +1811,8 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1521 | } | 1811 | } |
1522 | else | 1812 | else |
1523 | gtt_size = (uint64_t)amdgpu_gtt_size << 20; | 1813 | gtt_size = (uint64_t)amdgpu_gtt_size << 20; |
1814 | |||
1815 | /* Initialize GTT memory pool */ | ||
1524 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >> PAGE_SHIFT); | 1816 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >> PAGE_SHIFT); |
1525 | if (r) { | 1817 | if (r) { |
1526 | DRM_ERROR("Failed initializing GTT heap.\n"); | 1818 | DRM_ERROR("Failed initializing GTT heap.\n"); |
@@ -1529,6 +1821,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1529 | DRM_INFO("amdgpu: %uM of GTT memory ready.\n", | 1821 | DRM_INFO("amdgpu: %uM of GTT memory ready.\n", |
1530 | (unsigned)(gtt_size / (1024 * 1024))); | 1822 | (unsigned)(gtt_size / (1024 * 1024))); |
1531 | 1823 | ||
1824 | /* Initialize various on-chip memory pools */ | ||
1532 | adev->gds.mem.total_size = adev->gds.mem.total_size << AMDGPU_GDS_SHIFT; | 1825 | adev->gds.mem.total_size = adev->gds.mem.total_size << AMDGPU_GDS_SHIFT; |
1533 | adev->gds.mem.gfx_partition_size = adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT; | 1826 | adev->gds.mem.gfx_partition_size = adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT; |
1534 | adev->gds.mem.cs_partition_size = adev->gds.mem.cs_partition_size << AMDGPU_GDS_SHIFT; | 1827 | adev->gds.mem.cs_partition_size = adev->gds.mem.cs_partition_size << AMDGPU_GDS_SHIFT; |
@@ -1568,6 +1861,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1568 | } | 1861 | } |
1569 | } | 1862 | } |
1570 | 1863 | ||
1864 | /* Register debugfs entries for amdgpu_ttm */ | ||
1571 | r = amdgpu_ttm_debugfs_init(adev); | 1865 | r = amdgpu_ttm_debugfs_init(adev); |
1572 | if (r) { | 1866 | if (r) { |
1573 | DRM_ERROR("Failed to init debugfs\n"); | 1867 | DRM_ERROR("Failed to init debugfs\n"); |
@@ -1576,11 +1870,19 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1576 | return 0; | 1870 | return 0; |
1577 | } | 1871 | } |
1578 | 1872 | ||
1873 | /** | ||
1874 | * amdgpu_ttm_late_init - Handle any late initialization for | ||
1875 | * amdgpu_ttm | ||
1876 | */ | ||
1579 | void amdgpu_ttm_late_init(struct amdgpu_device *adev) | 1877 | void amdgpu_ttm_late_init(struct amdgpu_device *adev) |
1580 | { | 1878 | { |
1879 | /* return the VGA stolen memory (if any) back to VRAM */ | ||
1581 | amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL); | 1880 | amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL); |
1582 | } | 1881 | } |
1583 | 1882 | ||
1883 | /** | ||
1884 | * amdgpu_ttm_fini - De-initialize the TTM memory pools | ||
1885 | */ | ||
1584 | void amdgpu_ttm_fini(struct amdgpu_device *adev) | 1886 | void amdgpu_ttm_fini(struct amdgpu_device *adev) |
1585 | { | 1887 | { |
1586 | if (!adev->mman.initialized) | 1888 | if (!adev->mman.initialized) |
@@ -1908,6 +2210,11 @@ static const struct drm_info_list amdgpu_ttm_debugfs_list[] = { | |||
1908 | #endif | 2210 | #endif |
1909 | }; | 2211 | }; |
1910 | 2212 | ||
2213 | /** | ||
2214 | * amdgpu_ttm_vram_read - Linear read access to VRAM | ||
2215 | * | ||
2216 | * Accesses VRAM via MMIO for debugging purposes. | ||
2217 | */ | ||
1911 | static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf, | 2218 | static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf, |
1912 | size_t size, loff_t *pos) | 2219 | size_t size, loff_t *pos) |
1913 | { | 2220 | { |
@@ -1947,6 +2254,11 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf, | |||
1947 | return result; | 2254 | return result; |
1948 | } | 2255 | } |
1949 | 2256 | ||
2257 | /** | ||
2258 | * amdgpu_ttm_vram_write - Linear write access to VRAM | ||
2259 | * | ||
2260 | * Accesses VRAM via MMIO for debugging purposes. | ||
2261 | */ | ||
1950 | static ssize_t amdgpu_ttm_vram_write(struct file *f, const char __user *buf, | 2262 | static ssize_t amdgpu_ttm_vram_write(struct file *f, const char __user *buf, |
1951 | size_t size, loff_t *pos) | 2263 | size_t size, loff_t *pos) |
1952 | { | 2264 | { |
@@ -1995,6 +2307,9 @@ static const struct file_operations amdgpu_ttm_vram_fops = { | |||
1995 | 2307 | ||
1996 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS | 2308 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS |
1997 | 2309 | ||
2310 | /** | ||
2311 | * amdgpu_ttm_gtt_read - Linear read access to GTT memory | ||
2312 | */ | ||
1998 | static ssize_t amdgpu_ttm_gtt_read(struct file *f, char __user *buf, | 2313 | static ssize_t amdgpu_ttm_gtt_read(struct file *f, char __user *buf, |
1999 | size_t size, loff_t *pos) | 2314 | size_t size, loff_t *pos) |
2000 | { | 2315 | { |
@@ -2042,6 +2357,13 @@ static const struct file_operations amdgpu_ttm_gtt_fops = { | |||
2042 | 2357 | ||
2043 | #endif | 2358 | #endif |
2044 | 2359 | ||
2360 | /** | ||
2361 | * amdgpu_iomem_read - Virtual read access to GPU mapped memory | ||
2362 | * | ||
2363 | * This function is used to read memory that has been mapped to the | ||
2364 | * GPU and the known addresses are not physical addresses but instead | ||
2365 | * bus addresses (e.g., what you'd put in an IB or ring buffer). | ||
2366 | */ | ||
2045 | static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf, | 2367 | static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf, |
2046 | size_t size, loff_t *pos) | 2368 | size_t size, loff_t *pos) |
2047 | { | 2369 | { |
@@ -2050,6 +2372,7 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf, | |||
2050 | ssize_t result = 0; | 2372 | ssize_t result = 0; |
2051 | int r; | 2373 | int r; |
2052 | 2374 | ||
2375 | /* retrieve the IOMMU domain if any for this device */ | ||
2053 | dom = iommu_get_domain_for_dev(adev->dev); | 2376 | dom = iommu_get_domain_for_dev(adev->dev); |
2054 | 2377 | ||
2055 | while (size) { | 2378 | while (size) { |
@@ -2062,6 +2385,10 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf, | |||
2062 | 2385 | ||
2063 | bytes = bytes < size ? bytes : size; | 2386 | bytes = bytes < size ? bytes : size; |
2064 | 2387 | ||
2388 | /* Translate the bus address to a physical address. If | ||
2389 | * the domain is NULL it means there is no IOMMU active | ||
2390 | * and the address translation is the identity | ||
2391 | */ | ||
2065 | addr = dom ? iommu_iova_to_phys(dom, addr) : addr; | 2392 | addr = dom ? iommu_iova_to_phys(dom, addr) : addr; |
2066 | 2393 | ||
2067 | pfn = addr >> PAGE_SHIFT; | 2394 | pfn = addr >> PAGE_SHIFT; |
@@ -2086,6 +2413,13 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf, | |||
2086 | return result; | 2413 | return result; |
2087 | } | 2414 | } |
2088 | 2415 | ||
2416 | /** | ||
2417 | * amdgpu_iomem_write - Virtual write access to GPU mapped memory | ||
2418 | * | ||
2419 | * This function is used to write memory that has been mapped to the | ||
2420 | * GPU and the known addresses are not physical addresses but instead | ||
2421 | * bus addresses (e.g., what you'd put in an IB or ring buffer). | ||
2422 | */ | ||
2089 | static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf, | 2423 | static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf, |
2090 | size_t size, loff_t *pos) | 2424 | size_t size, loff_t *pos) |
2091 | { | 2425 | { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c index 75592bd04d6a..f55f72a37ca8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | |||
@@ -307,6 +307,8 @@ amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type) | |||
307 | return AMDGPU_FW_LOAD_DIRECT; | 307 | return AMDGPU_FW_LOAD_DIRECT; |
308 | else | 308 | else |
309 | return AMDGPU_FW_LOAD_PSP; | 309 | return AMDGPU_FW_LOAD_PSP; |
310 | case CHIP_VEGA20: | ||
311 | return AMDGPU_FW_LOAD_DIRECT; | ||
310 | default: | 312 | default: |
311 | DRM_ERROR("Unknown firmware load type\n"); | 313 | DRM_ERROR("Unknown firmware load type\n"); |
312 | } | 314 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c index de4d77af02ae..bcf68f80bbf0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | |||
@@ -70,12 +70,14 @@ | |||
70 | 70 | ||
71 | #define FIRMWARE_VEGA10 "amdgpu/vega10_uvd.bin" | 71 | #define FIRMWARE_VEGA10 "amdgpu/vega10_uvd.bin" |
72 | #define FIRMWARE_VEGA12 "amdgpu/vega12_uvd.bin" | 72 | #define FIRMWARE_VEGA12 "amdgpu/vega12_uvd.bin" |
73 | #define FIRMWARE_VEGA20 "amdgpu/vega20_uvd.bin" | ||
73 | 74 | ||
74 | #define mmUVD_GPCOM_VCPU_DATA0_VEGA10 (0x03c4 + 0x7e00) | 75 | /* These are common relative offsets for all asics, from uvd_7_0_offset.h, */ |
75 | #define mmUVD_GPCOM_VCPU_DATA1_VEGA10 (0x03c5 + 0x7e00) | 76 | #define UVD_GPCOM_VCPU_CMD 0x03c3 |
76 | #define mmUVD_GPCOM_VCPU_CMD_VEGA10 (0x03c3 + 0x7e00) | 77 | #define UVD_GPCOM_VCPU_DATA0 0x03c4 |
77 | #define mmUVD_NO_OP_VEGA10 (0x03ff + 0x7e00) | 78 | #define UVD_GPCOM_VCPU_DATA1 0x03c5 |
78 | #define mmUVD_ENGINE_CNTL_VEGA10 (0x03c6 + 0x7e00) | 79 | #define UVD_NO_OP 0x03ff |
80 | #define UVD_BASE_SI 0x3800 | ||
79 | 81 | ||
80 | /** | 82 | /** |
81 | * amdgpu_uvd_cs_ctx - Command submission parser context | 83 | * amdgpu_uvd_cs_ctx - Command submission parser context |
@@ -114,6 +116,7 @@ MODULE_FIRMWARE(FIRMWARE_VEGAM); | |||
114 | 116 | ||
115 | MODULE_FIRMWARE(FIRMWARE_VEGA10); | 117 | MODULE_FIRMWARE(FIRMWARE_VEGA10); |
116 | MODULE_FIRMWARE(FIRMWARE_VEGA12); | 118 | MODULE_FIRMWARE(FIRMWARE_VEGA12); |
119 | MODULE_FIRMWARE(FIRMWARE_VEGA20); | ||
117 | 120 | ||
118 | static void amdgpu_uvd_idle_work_handler(struct work_struct *work); | 121 | static void amdgpu_uvd_idle_work_handler(struct work_struct *work); |
119 | 122 | ||
@@ -125,9 +128,9 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | |||
125 | const char *fw_name; | 128 | const char *fw_name; |
126 | const struct common_firmware_header *hdr; | 129 | const struct common_firmware_header *hdr; |
127 | unsigned version_major, version_minor, family_id; | 130 | unsigned version_major, version_minor, family_id; |
128 | int i, r; | 131 | int i, j, r; |
129 | 132 | ||
130 | INIT_DELAYED_WORK(&adev->uvd.idle_work, amdgpu_uvd_idle_work_handler); | 133 | INIT_DELAYED_WORK(&adev->uvd.inst->idle_work, amdgpu_uvd_idle_work_handler); |
131 | 134 | ||
132 | switch (adev->asic_type) { | 135 | switch (adev->asic_type) { |
133 | #ifdef CONFIG_DRM_AMDGPU_CIK | 136 | #ifdef CONFIG_DRM_AMDGPU_CIK |
@@ -177,6 +180,9 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | |||
177 | case CHIP_VEGAM: | 180 | case CHIP_VEGAM: |
178 | fw_name = FIRMWARE_VEGAM; | 181 | fw_name = FIRMWARE_VEGAM; |
179 | break; | 182 | break; |
183 | case CHIP_VEGA20: | ||
184 | fw_name = FIRMWARE_VEGA20; | ||
185 | break; | ||
180 | default: | 186 | default: |
181 | return -EINVAL; | 187 | return -EINVAL; |
182 | } | 188 | } |
@@ -231,28 +237,30 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | |||
231 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) | 237 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) |
232 | bo_size += AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8); | 238 | bo_size += AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8); |
233 | 239 | ||
234 | r = amdgpu_bo_create_kernel(adev, bo_size, PAGE_SIZE, | 240 | for (j = 0; j < adev->uvd.num_uvd_inst; j++) { |
235 | AMDGPU_GEM_DOMAIN_VRAM, &adev->uvd.vcpu_bo, | ||
236 | &adev->uvd.gpu_addr, &adev->uvd.cpu_addr); | ||
237 | if (r) { | ||
238 | dev_err(adev->dev, "(%d) failed to allocate UVD bo\n", r); | ||
239 | return r; | ||
240 | } | ||
241 | 241 | ||
242 | ring = &adev->uvd.ring; | 242 | r = amdgpu_bo_create_kernel(adev, bo_size, PAGE_SIZE, |
243 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; | 243 | AMDGPU_GEM_DOMAIN_VRAM, &adev->uvd.inst[j].vcpu_bo, |
244 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.entity, | 244 | &adev->uvd.inst[j].gpu_addr, &adev->uvd.inst[j].cpu_addr); |
245 | rq, NULL); | 245 | if (r) { |
246 | if (r != 0) { | 246 | dev_err(adev->dev, "(%d) failed to allocate UVD bo\n", r); |
247 | DRM_ERROR("Failed setting up UVD run queue.\n"); | 247 | return r; |
248 | return r; | 248 | } |
249 | } | ||
250 | 249 | ||
251 | for (i = 0; i < adev->uvd.max_handles; ++i) { | 250 | ring = &adev->uvd.inst[j].ring; |
252 | atomic_set(&adev->uvd.handles[i], 0); | 251 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
253 | adev->uvd.filp[i] = NULL; | 252 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.inst[j].entity, |
254 | } | 253 | rq, NULL); |
254 | if (r != 0) { | ||
255 | DRM_ERROR("Failed setting up UVD(%d) run queue.\n", j); | ||
256 | return r; | ||
257 | } | ||
255 | 258 | ||
259 | for (i = 0; i < adev->uvd.max_handles; ++i) { | ||
260 | atomic_set(&adev->uvd.inst[j].handles[i], 0); | ||
261 | adev->uvd.inst[j].filp[i] = NULL; | ||
262 | } | ||
263 | } | ||
256 | /* from uvd v5.0 HW addressing capacity increased to 64 bits */ | 264 | /* from uvd v5.0 HW addressing capacity increased to 64 bits */ |
257 | if (!amdgpu_device_ip_block_version_cmp(adev, AMD_IP_BLOCK_TYPE_UVD, 5, 0)) | 265 | if (!amdgpu_device_ip_block_version_cmp(adev, AMD_IP_BLOCK_TYPE_UVD, 5, 0)) |
258 | adev->uvd.address_64_bit = true; | 266 | adev->uvd.address_64_bit = true; |
@@ -279,20 +287,22 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | |||
279 | 287 | ||
280 | int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) | 288 | int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) |
281 | { | 289 | { |
282 | int i; | 290 | int i, j; |
283 | kfree(adev->uvd.saved_bo); | ||
284 | 291 | ||
285 | drm_sched_entity_fini(&adev->uvd.ring.sched, &adev->uvd.entity); | 292 | for (j = 0; j < adev->uvd.num_uvd_inst; ++j) { |
293 | kfree(adev->uvd.inst[j].saved_bo); | ||
286 | 294 | ||
287 | amdgpu_bo_free_kernel(&adev->uvd.vcpu_bo, | 295 | drm_sched_entity_fini(&adev->uvd.inst[j].ring.sched, &adev->uvd.inst[j].entity); |
288 | &adev->uvd.gpu_addr, | ||
289 | (void **)&adev->uvd.cpu_addr); | ||
290 | 296 | ||
291 | amdgpu_ring_fini(&adev->uvd.ring); | 297 | amdgpu_bo_free_kernel(&adev->uvd.inst[j].vcpu_bo, |
298 | &adev->uvd.inst[j].gpu_addr, | ||
299 | (void **)&adev->uvd.inst[j].cpu_addr); | ||
292 | 300 | ||
293 | for (i = 0; i < AMDGPU_MAX_UVD_ENC_RINGS; ++i) | 301 | amdgpu_ring_fini(&adev->uvd.inst[j].ring); |
294 | amdgpu_ring_fini(&adev->uvd.ring_enc[i]); | ||
295 | 302 | ||
303 | for (i = 0; i < AMDGPU_MAX_UVD_ENC_RINGS; ++i) | ||
304 | amdgpu_ring_fini(&adev->uvd.inst[j].ring_enc[i]); | ||
305 | } | ||
296 | release_firmware(adev->uvd.fw); | 306 | release_firmware(adev->uvd.fw); |
297 | 307 | ||
298 | return 0; | 308 | return 0; |
@@ -302,32 +312,33 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev) | |||
302 | { | 312 | { |
303 | unsigned size; | 313 | unsigned size; |
304 | void *ptr; | 314 | void *ptr; |
305 | int i; | 315 | int i, j; |
306 | |||
307 | if (adev->uvd.vcpu_bo == NULL) | ||
308 | return 0; | ||
309 | 316 | ||
310 | cancel_delayed_work_sync(&adev->uvd.idle_work); | 317 | for (j = 0; j < adev->uvd.num_uvd_inst; ++j) { |
318 | if (adev->uvd.inst[j].vcpu_bo == NULL) | ||
319 | continue; | ||
311 | 320 | ||
312 | /* only valid for physical mode */ | 321 | cancel_delayed_work_sync(&adev->uvd.inst[j].idle_work); |
313 | if (adev->asic_type < CHIP_POLARIS10) { | ||
314 | for (i = 0; i < adev->uvd.max_handles; ++i) | ||
315 | if (atomic_read(&adev->uvd.handles[i])) | ||
316 | break; | ||
317 | 322 | ||
318 | if (i == adev->uvd.max_handles) | 323 | /* only valid for physical mode */ |
319 | return 0; | 324 | if (adev->asic_type < CHIP_POLARIS10) { |
320 | } | 325 | for (i = 0; i < adev->uvd.max_handles; ++i) |
326 | if (atomic_read(&adev->uvd.inst[j].handles[i])) | ||
327 | break; | ||
321 | 328 | ||
322 | size = amdgpu_bo_size(adev->uvd.vcpu_bo); | 329 | if (i == adev->uvd.max_handles) |
323 | ptr = adev->uvd.cpu_addr; | 330 | continue; |
331 | } | ||
324 | 332 | ||
325 | adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL); | 333 | size = amdgpu_bo_size(adev->uvd.inst[j].vcpu_bo); |
326 | if (!adev->uvd.saved_bo) | 334 | ptr = adev->uvd.inst[j].cpu_addr; |
327 | return -ENOMEM; | ||
328 | 335 | ||
329 | memcpy_fromio(adev->uvd.saved_bo, ptr, size); | 336 | adev->uvd.inst[j].saved_bo = kmalloc(size, GFP_KERNEL); |
337 | if (!adev->uvd.inst[j].saved_bo) | ||
338 | return -ENOMEM; | ||
330 | 339 | ||
340 | memcpy_fromio(adev->uvd.inst[j].saved_bo, ptr, size); | ||
341 | } | ||
331 | return 0; | 342 | return 0; |
332 | } | 343 | } |
333 | 344 | ||
@@ -335,59 +346,65 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev) | |||
335 | { | 346 | { |
336 | unsigned size; | 347 | unsigned size; |
337 | void *ptr; | 348 | void *ptr; |
349 | int i; | ||
338 | 350 | ||
339 | if (adev->uvd.vcpu_bo == NULL) | 351 | for (i = 0; i < adev->uvd.num_uvd_inst; i++) { |
340 | return -EINVAL; | 352 | if (adev->uvd.inst[i].vcpu_bo == NULL) |
353 | return -EINVAL; | ||
341 | 354 | ||
342 | size = amdgpu_bo_size(adev->uvd.vcpu_bo); | 355 | size = amdgpu_bo_size(adev->uvd.inst[i].vcpu_bo); |
343 | ptr = adev->uvd.cpu_addr; | 356 | ptr = adev->uvd.inst[i].cpu_addr; |
344 | 357 | ||
345 | if (adev->uvd.saved_bo != NULL) { | 358 | if (adev->uvd.inst[i].saved_bo != NULL) { |
346 | memcpy_toio(ptr, adev->uvd.saved_bo, size); | 359 | memcpy_toio(ptr, adev->uvd.inst[i].saved_bo, size); |
347 | kfree(adev->uvd.saved_bo); | 360 | kfree(adev->uvd.inst[i].saved_bo); |
348 | adev->uvd.saved_bo = NULL; | 361 | adev->uvd.inst[i].saved_bo = NULL; |
349 | } else { | 362 | } else { |
350 | const struct common_firmware_header *hdr; | 363 | const struct common_firmware_header *hdr; |
351 | unsigned offset; | 364 | unsigned offset; |
352 | 365 | ||
353 | hdr = (const struct common_firmware_header *)adev->uvd.fw->data; | 366 | hdr = (const struct common_firmware_header *)adev->uvd.fw->data; |
354 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) { | 367 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) { |
355 | offset = le32_to_cpu(hdr->ucode_array_offset_bytes); | 368 | offset = le32_to_cpu(hdr->ucode_array_offset_bytes); |
356 | memcpy_toio(adev->uvd.cpu_addr, adev->uvd.fw->data + offset, | 369 | memcpy_toio(adev->uvd.inst[i].cpu_addr, adev->uvd.fw->data + offset, |
357 | le32_to_cpu(hdr->ucode_size_bytes)); | 370 | le32_to_cpu(hdr->ucode_size_bytes)); |
358 | size -= le32_to_cpu(hdr->ucode_size_bytes); | 371 | size -= le32_to_cpu(hdr->ucode_size_bytes); |
359 | ptr += le32_to_cpu(hdr->ucode_size_bytes); | 372 | ptr += le32_to_cpu(hdr->ucode_size_bytes); |
373 | } | ||
374 | memset_io(ptr, 0, size); | ||
375 | /* to restore uvd fence seq */ | ||
376 | amdgpu_fence_driver_force_completion(&adev->uvd.inst[i].ring); | ||
360 | } | 377 | } |
361 | memset_io(ptr, 0, size); | ||
362 | /* to restore uvd fence seq */ | ||
363 | amdgpu_fence_driver_force_completion(&adev->uvd.ring); | ||
364 | } | 378 | } |
365 | |||
366 | return 0; | 379 | return 0; |
367 | } | 380 | } |
368 | 381 | ||
369 | void amdgpu_uvd_free_handles(struct amdgpu_device *adev, struct drm_file *filp) | 382 | void amdgpu_uvd_free_handles(struct amdgpu_device *adev, struct drm_file *filp) |
370 | { | 383 | { |
371 | struct amdgpu_ring *ring = &adev->uvd.ring; | 384 | struct amdgpu_ring *ring; |
372 | int i, r; | 385 | int i, j, r; |
373 | 386 | ||
374 | for (i = 0; i < adev->uvd.max_handles; ++i) { | 387 | for (j = 0; j < adev->uvd.num_uvd_inst; j++) { |
375 | uint32_t handle = atomic_read(&adev->uvd.handles[i]); | 388 | ring = &adev->uvd.inst[j].ring; |
376 | if (handle != 0 && adev->uvd.filp[i] == filp) { | 389 | |
377 | struct dma_fence *fence; | 390 | for (i = 0; i < adev->uvd.max_handles; ++i) { |
378 | 391 | uint32_t handle = atomic_read(&adev->uvd.inst[j].handles[i]); | |
379 | r = amdgpu_uvd_get_destroy_msg(ring, handle, | 392 | if (handle != 0 && adev->uvd.inst[j].filp[i] == filp) { |
380 | false, &fence); | 393 | struct dma_fence *fence; |
381 | if (r) { | 394 | |
382 | DRM_ERROR("Error destroying UVD (%d)!\n", r); | 395 | r = amdgpu_uvd_get_destroy_msg(ring, handle, |
383 | continue; | 396 | false, &fence); |
384 | } | 397 | if (r) { |
398 | DRM_ERROR("Error destroying UVD(%d) %d!\n", j, r); | ||
399 | continue; | ||
400 | } | ||
385 | 401 | ||
386 | dma_fence_wait(fence, false); | 402 | dma_fence_wait(fence, false); |
387 | dma_fence_put(fence); | 403 | dma_fence_put(fence); |
388 | 404 | ||
389 | adev->uvd.filp[i] = NULL; | 405 | adev->uvd.inst[j].filp[i] = NULL; |
390 | atomic_set(&adev->uvd.handles[i], 0); | 406 | atomic_set(&adev->uvd.inst[j].handles[i], 0); |
407 | } | ||
391 | } | 408 | } |
392 | } | 409 | } |
393 | } | 410 | } |
@@ -662,15 +679,16 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, | |||
662 | void *ptr; | 679 | void *ptr; |
663 | long r; | 680 | long r; |
664 | int i; | 681 | int i; |
682 | uint32_t ip_instance = ctx->parser->job->ring->me; | ||
665 | 683 | ||
666 | if (offset & 0x3F) { | 684 | if (offset & 0x3F) { |
667 | DRM_ERROR("UVD messages must be 64 byte aligned!\n"); | 685 | DRM_ERROR("UVD(%d) messages must be 64 byte aligned!\n", ip_instance); |
668 | return -EINVAL; | 686 | return -EINVAL; |
669 | } | 687 | } |
670 | 688 | ||
671 | r = amdgpu_bo_kmap(bo, &ptr); | 689 | r = amdgpu_bo_kmap(bo, &ptr); |
672 | if (r) { | 690 | if (r) { |
673 | DRM_ERROR("Failed mapping the UVD message (%ld)!\n", r); | 691 | DRM_ERROR("Failed mapping the UVD(%d) message (%ld)!\n", ip_instance, r); |
674 | return r; | 692 | return r; |
675 | } | 693 | } |
676 | 694 | ||
@@ -680,7 +698,7 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, | |||
680 | handle = msg[2]; | 698 | handle = msg[2]; |
681 | 699 | ||
682 | if (handle == 0) { | 700 | if (handle == 0) { |
683 | DRM_ERROR("Invalid UVD handle!\n"); | 701 | DRM_ERROR("Invalid UVD(%d) handle!\n", ip_instance); |
684 | return -EINVAL; | 702 | return -EINVAL; |
685 | } | 703 | } |
686 | 704 | ||
@@ -691,18 +709,18 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, | |||
691 | 709 | ||
692 | /* try to alloc a new handle */ | 710 | /* try to alloc a new handle */ |
693 | for (i = 0; i < adev->uvd.max_handles; ++i) { | 711 | for (i = 0; i < adev->uvd.max_handles; ++i) { |
694 | if (atomic_read(&adev->uvd.handles[i]) == handle) { | 712 | if (atomic_read(&adev->uvd.inst[ip_instance].handles[i]) == handle) { |
695 | DRM_ERROR("Handle 0x%x already in use!\n", handle); | 713 | DRM_ERROR("(%d)Handle 0x%x already in use!\n", ip_instance, handle); |
696 | return -EINVAL; | 714 | return -EINVAL; |
697 | } | 715 | } |
698 | 716 | ||
699 | if (!atomic_cmpxchg(&adev->uvd.handles[i], 0, handle)) { | 717 | if (!atomic_cmpxchg(&adev->uvd.inst[ip_instance].handles[i], 0, handle)) { |
700 | adev->uvd.filp[i] = ctx->parser->filp; | 718 | adev->uvd.inst[ip_instance].filp[i] = ctx->parser->filp; |
701 | return 0; | 719 | return 0; |
702 | } | 720 | } |
703 | } | 721 | } |
704 | 722 | ||
705 | DRM_ERROR("No more free UVD handles!\n"); | 723 | DRM_ERROR("No more free UVD(%d) handles!\n", ip_instance); |
706 | return -ENOSPC; | 724 | return -ENOSPC; |
707 | 725 | ||
708 | case 1: | 726 | case 1: |
@@ -714,27 +732,27 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx, | |||
714 | 732 | ||
715 | /* validate the handle */ | 733 | /* validate the handle */ |
716 | for (i = 0; i < adev->uvd.max_handles; ++i) { | 734 | for (i = 0; i < adev->uvd.max_handles; ++i) { |
717 | if (atomic_read(&adev->uvd.handles[i]) == handle) { | 735 | if (atomic_read(&adev->uvd.inst[ip_instance].handles[i]) == handle) { |
718 | if (adev->uvd.filp[i] != ctx->parser->filp) { | 736 | if (adev->uvd.inst[ip_instance].filp[i] != ctx->parser->filp) { |
719 | DRM_ERROR("UVD handle collision detected!\n"); | 737 | DRM_ERROR("UVD(%d) handle collision detected!\n", ip_instance); |
720 | return -EINVAL; | 738 | return -EINVAL; |
721 | } | 739 | } |
722 | return 0; | 740 | return 0; |
723 | } | 741 | } |
724 | } | 742 | } |
725 | 743 | ||
726 | DRM_ERROR("Invalid UVD handle 0x%x!\n", handle); | 744 | DRM_ERROR("Invalid UVD(%d) handle 0x%x!\n", ip_instance, handle); |
727 | return -ENOENT; | 745 | return -ENOENT; |
728 | 746 | ||
729 | case 2: | 747 | case 2: |
730 | /* it's a destroy msg, free the handle */ | 748 | /* it's a destroy msg, free the handle */ |
731 | for (i = 0; i < adev->uvd.max_handles; ++i) | 749 | for (i = 0; i < adev->uvd.max_handles; ++i) |
732 | atomic_cmpxchg(&adev->uvd.handles[i], handle, 0); | 750 | atomic_cmpxchg(&adev->uvd.inst[ip_instance].handles[i], handle, 0); |
733 | amdgpu_bo_kunmap(bo); | 751 | amdgpu_bo_kunmap(bo); |
734 | return 0; | 752 | return 0; |
735 | 753 | ||
736 | default: | 754 | default: |
737 | DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type); | 755 | DRM_ERROR("Illegal UVD(%d) message type (%d)!\n", ip_instance, msg_type); |
738 | return -EINVAL; | 756 | return -EINVAL; |
739 | } | 757 | } |
740 | BUG(); | 758 | BUG(); |
@@ -805,7 +823,7 @@ static int amdgpu_uvd_cs_pass2(struct amdgpu_uvd_cs_ctx *ctx) | |||
805 | } | 823 | } |
806 | 824 | ||
807 | if ((cmd == 0 || cmd == 0x3) && | 825 | if ((cmd == 0 || cmd == 0x3) && |
808 | (start >> 28) != (ctx->parser->adev->uvd.gpu_addr >> 28)) { | 826 | (start >> 28) != (ctx->parser->adev->uvd.inst->gpu_addr >> 28)) { |
809 | DRM_ERROR("msg/fb buffer %LX-%LX out of 256MB segment!\n", | 827 | DRM_ERROR("msg/fb buffer %LX-%LX out of 256MB segment!\n", |
810 | start, end); | 828 | start, end); |
811 | return -EINVAL; | 829 | return -EINVAL; |
@@ -973,6 +991,8 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo, | |||
973 | uint64_t addr; | 991 | uint64_t addr; |
974 | long r; | 992 | long r; |
975 | int i; | 993 | int i; |
994 | unsigned offset_idx = 0; | ||
995 | unsigned offset[3] = { UVD_BASE_SI, 0, 0 }; | ||
976 | 996 | ||
977 | amdgpu_bo_kunmap(bo); | 997 | amdgpu_bo_kunmap(bo); |
978 | amdgpu_bo_unpin(bo); | 998 | amdgpu_bo_unpin(bo); |
@@ -992,17 +1012,16 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo, | |||
992 | goto err; | 1012 | goto err; |
993 | 1013 | ||
994 | if (adev->asic_type >= CHIP_VEGA10) { | 1014 | if (adev->asic_type >= CHIP_VEGA10) { |
995 | data[0] = PACKET0(mmUVD_GPCOM_VCPU_DATA0_VEGA10, 0); | 1015 | offset_idx = 1 + ring->me; |
996 | data[1] = PACKET0(mmUVD_GPCOM_VCPU_DATA1_VEGA10, 0); | 1016 | offset[1] = adev->reg_offset[UVD_HWIP][0][1]; |
997 | data[2] = PACKET0(mmUVD_GPCOM_VCPU_CMD_VEGA10, 0); | 1017 | offset[2] = adev->reg_offset[UVD_HWIP][1][1]; |
998 | data[3] = PACKET0(mmUVD_NO_OP_VEGA10, 0); | ||
999 | } else { | ||
1000 | data[0] = PACKET0(mmUVD_GPCOM_VCPU_DATA0, 0); | ||
1001 | data[1] = PACKET0(mmUVD_GPCOM_VCPU_DATA1, 0); | ||
1002 | data[2] = PACKET0(mmUVD_GPCOM_VCPU_CMD, 0); | ||
1003 | data[3] = PACKET0(mmUVD_NO_OP, 0); | ||
1004 | } | 1018 | } |
1005 | 1019 | ||
1020 | data[0] = PACKET0(offset[offset_idx] + UVD_GPCOM_VCPU_DATA0, 0); | ||
1021 | data[1] = PACKET0(offset[offset_idx] + UVD_GPCOM_VCPU_DATA1, 0); | ||
1022 | data[2] = PACKET0(offset[offset_idx] + UVD_GPCOM_VCPU_CMD, 0); | ||
1023 | data[3] = PACKET0(offset[offset_idx] + UVD_NO_OP, 0); | ||
1024 | |||
1006 | ib = &job->ibs[0]; | 1025 | ib = &job->ibs[0]; |
1007 | addr = amdgpu_bo_gpu_offset(bo); | 1026 | addr = amdgpu_bo_gpu_offset(bo); |
1008 | ib->ptr[0] = data[0]; | 1027 | ib->ptr[0] = data[0]; |
@@ -1038,7 +1057,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo, | |||
1038 | if (r) | 1057 | if (r) |
1039 | goto err_free; | 1058 | goto err_free; |
1040 | 1059 | ||
1041 | r = amdgpu_job_submit(job, ring, &adev->uvd.entity, | 1060 | r = amdgpu_job_submit(job, ring, &adev->uvd.inst[ring->me].entity, |
1042 | AMDGPU_FENCE_OWNER_UNDEFINED, &f); | 1061 | AMDGPU_FENCE_OWNER_UNDEFINED, &f); |
1043 | if (r) | 1062 | if (r) |
1044 | goto err_free; | 1063 | goto err_free; |
@@ -1126,8 +1145,15 @@ int amdgpu_uvd_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, | |||
1126 | static void amdgpu_uvd_idle_work_handler(struct work_struct *work) | 1145 | static void amdgpu_uvd_idle_work_handler(struct work_struct *work) |
1127 | { | 1146 | { |
1128 | struct amdgpu_device *adev = | 1147 | struct amdgpu_device *adev = |
1129 | container_of(work, struct amdgpu_device, uvd.idle_work.work); | 1148 | container_of(work, struct amdgpu_device, uvd.inst->idle_work.work); |
1130 | unsigned fences = amdgpu_fence_count_emitted(&adev->uvd.ring); | 1149 | unsigned fences = 0, i, j; |
1150 | |||
1151 | for (i = 0; i < adev->uvd.num_uvd_inst; ++i) { | ||
1152 | fences += amdgpu_fence_count_emitted(&adev->uvd.inst[i].ring); | ||
1153 | for (j = 0; j < adev->uvd.num_enc_rings; ++j) { | ||
1154 | fences += amdgpu_fence_count_emitted(&adev->uvd.inst[i].ring_enc[j]); | ||
1155 | } | ||
1156 | } | ||
1131 | 1157 | ||
1132 | if (fences == 0) { | 1158 | if (fences == 0) { |
1133 | if (adev->pm.dpm_enabled) { | 1159 | if (adev->pm.dpm_enabled) { |
@@ -1141,7 +1167,7 @@ static void amdgpu_uvd_idle_work_handler(struct work_struct *work) | |||
1141 | AMD_CG_STATE_GATE); | 1167 | AMD_CG_STATE_GATE); |
1142 | } | 1168 | } |
1143 | } else { | 1169 | } else { |
1144 | schedule_delayed_work(&adev->uvd.idle_work, UVD_IDLE_TIMEOUT); | 1170 | schedule_delayed_work(&adev->uvd.inst->idle_work, UVD_IDLE_TIMEOUT); |
1145 | } | 1171 | } |
1146 | } | 1172 | } |
1147 | 1173 | ||
@@ -1153,7 +1179,7 @@ void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring) | |||
1153 | if (amdgpu_sriov_vf(adev)) | 1179 | if (amdgpu_sriov_vf(adev)) |
1154 | return; | 1180 | return; |
1155 | 1181 | ||
1156 | set_clocks = !cancel_delayed_work_sync(&adev->uvd.idle_work); | 1182 | set_clocks = !cancel_delayed_work_sync(&adev->uvd.inst->idle_work); |
1157 | if (set_clocks) { | 1183 | if (set_clocks) { |
1158 | if (adev->pm.dpm_enabled) { | 1184 | if (adev->pm.dpm_enabled) { |
1159 | amdgpu_dpm_enable_uvd(adev, true); | 1185 | amdgpu_dpm_enable_uvd(adev, true); |
@@ -1170,7 +1196,7 @@ void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring) | |||
1170 | void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring) | 1196 | void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring) |
1171 | { | 1197 | { |
1172 | if (!amdgpu_sriov_vf(ring->adev)) | 1198 | if (!amdgpu_sriov_vf(ring->adev)) |
1173 | schedule_delayed_work(&ring->adev->uvd.idle_work, UVD_IDLE_TIMEOUT); | 1199 | schedule_delayed_work(&ring->adev->uvd.inst->idle_work, UVD_IDLE_TIMEOUT); |
1174 | } | 1200 | } |
1175 | 1201 | ||
1176 | /** | 1202 | /** |
@@ -1184,27 +1210,28 @@ int amdgpu_uvd_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
1184 | { | 1210 | { |
1185 | struct dma_fence *fence; | 1211 | struct dma_fence *fence; |
1186 | long r; | 1212 | long r; |
1213 | uint32_t ip_instance = ring->me; | ||
1187 | 1214 | ||
1188 | r = amdgpu_uvd_get_create_msg(ring, 1, NULL); | 1215 | r = amdgpu_uvd_get_create_msg(ring, 1, NULL); |
1189 | if (r) { | 1216 | if (r) { |
1190 | DRM_ERROR("amdgpu: failed to get create msg (%ld).\n", r); | 1217 | DRM_ERROR("amdgpu: (%d)failed to get create msg (%ld).\n", ip_instance, r); |
1191 | goto error; | 1218 | goto error; |
1192 | } | 1219 | } |
1193 | 1220 | ||
1194 | r = amdgpu_uvd_get_destroy_msg(ring, 1, true, &fence); | 1221 | r = amdgpu_uvd_get_destroy_msg(ring, 1, true, &fence); |
1195 | if (r) { | 1222 | if (r) { |
1196 | DRM_ERROR("amdgpu: failed to get destroy ib (%ld).\n", r); | 1223 | DRM_ERROR("amdgpu: (%d)failed to get destroy ib (%ld).\n", ip_instance, r); |
1197 | goto error; | 1224 | goto error; |
1198 | } | 1225 | } |
1199 | 1226 | ||
1200 | r = dma_fence_wait_timeout(fence, false, timeout); | 1227 | r = dma_fence_wait_timeout(fence, false, timeout); |
1201 | if (r == 0) { | 1228 | if (r == 0) { |
1202 | DRM_ERROR("amdgpu: IB test timed out.\n"); | 1229 | DRM_ERROR("amdgpu: (%d)IB test timed out.\n", ip_instance); |
1203 | r = -ETIMEDOUT; | 1230 | r = -ETIMEDOUT; |
1204 | } else if (r < 0) { | 1231 | } else if (r < 0) { |
1205 | DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r); | 1232 | DRM_ERROR("amdgpu: (%d)fence wait failed (%ld).\n", ip_instance, r); |
1206 | } else { | 1233 | } else { |
1207 | DRM_DEBUG("ib test on ring %d succeeded\n", ring->idx); | 1234 | DRM_DEBUG("ib test on (%d)ring %d succeeded\n", ip_instance, ring->idx); |
1208 | r = 0; | 1235 | r = 0; |
1209 | } | 1236 | } |
1210 | 1237 | ||
@@ -1232,7 +1259,7 @@ uint32_t amdgpu_uvd_used_handles(struct amdgpu_device *adev) | |||
1232 | * necessarily linear. So we need to count | 1259 | * necessarily linear. So we need to count |
1233 | * all non-zero handles. | 1260 | * all non-zero handles. |
1234 | */ | 1261 | */ |
1235 | if (atomic_read(&adev->uvd.handles[i])) | 1262 | if (atomic_read(&adev->uvd.inst->handles[i])) |
1236 | used_handles++; | 1263 | used_handles++; |
1237 | } | 1264 | } |
1238 | 1265 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h index 32ea20b99e53..b1579fba134c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | |||
@@ -31,30 +31,37 @@ | |||
31 | #define AMDGPU_UVD_SESSION_SIZE (50*1024) | 31 | #define AMDGPU_UVD_SESSION_SIZE (50*1024) |
32 | #define AMDGPU_UVD_FIRMWARE_OFFSET 256 | 32 | #define AMDGPU_UVD_FIRMWARE_OFFSET 256 |
33 | 33 | ||
34 | #define AMDGPU_MAX_UVD_INSTANCES 2 | ||
35 | |||
34 | #define AMDGPU_UVD_FIRMWARE_SIZE(adev) \ | 36 | #define AMDGPU_UVD_FIRMWARE_SIZE(adev) \ |
35 | (AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(((const struct common_firmware_header *)(adev)->uvd.fw->data)->ucode_size_bytes) + \ | 37 | (AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(((const struct common_firmware_header *)(adev)->uvd.fw->data)->ucode_size_bytes) + \ |
36 | 8) - AMDGPU_UVD_FIRMWARE_OFFSET) | 38 | 8) - AMDGPU_UVD_FIRMWARE_OFFSET) |
37 | 39 | ||
38 | struct amdgpu_uvd { | 40 | struct amdgpu_uvd_inst { |
39 | struct amdgpu_bo *vcpu_bo; | 41 | struct amdgpu_bo *vcpu_bo; |
40 | void *cpu_addr; | 42 | void *cpu_addr; |
41 | uint64_t gpu_addr; | 43 | uint64_t gpu_addr; |
42 | unsigned fw_version; | ||
43 | void *saved_bo; | 44 | void *saved_bo; |
44 | unsigned max_handles; | ||
45 | atomic_t handles[AMDGPU_MAX_UVD_HANDLES]; | 45 | atomic_t handles[AMDGPU_MAX_UVD_HANDLES]; |
46 | struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES]; | 46 | struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES]; |
47 | struct delayed_work idle_work; | 47 | struct delayed_work idle_work; |
48 | const struct firmware *fw; /* UVD firmware */ | ||
49 | struct amdgpu_ring ring; | 48 | struct amdgpu_ring ring; |
50 | struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS]; | 49 | struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS]; |
51 | struct amdgpu_irq_src irq; | 50 | struct amdgpu_irq_src irq; |
52 | bool address_64_bit; | ||
53 | bool use_ctx_buf; | ||
54 | struct drm_sched_entity entity; | 51 | struct drm_sched_entity entity; |
55 | struct drm_sched_entity entity_enc; | 52 | struct drm_sched_entity entity_enc; |
56 | uint32_t srbm_soft_reset; | 53 | uint32_t srbm_soft_reset; |
54 | }; | ||
55 | |||
56 | struct amdgpu_uvd { | ||
57 | const struct firmware *fw; /* UVD firmware */ | ||
58 | unsigned fw_version; | ||
59 | unsigned max_handles; | ||
57 | unsigned num_enc_rings; | 60 | unsigned num_enc_rings; |
61 | uint8_t num_uvd_inst; | ||
62 | bool address_64_bit; | ||
63 | bool use_ctx_buf; | ||
64 | struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES]; | ||
58 | }; | 65 | }; |
59 | 66 | ||
60 | int amdgpu_uvd_sw_init(struct amdgpu_device *adev); | 67 | int amdgpu_uvd_sw_init(struct amdgpu_device *adev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c index a86322f5164f..23d960ec1cf2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | |||
@@ -57,6 +57,7 @@ | |||
57 | 57 | ||
58 | #define FIRMWARE_VEGA10 "amdgpu/vega10_vce.bin" | 58 | #define FIRMWARE_VEGA10 "amdgpu/vega10_vce.bin" |
59 | #define FIRMWARE_VEGA12 "amdgpu/vega12_vce.bin" | 59 | #define FIRMWARE_VEGA12 "amdgpu/vega12_vce.bin" |
60 | #define FIRMWARE_VEGA20 "amdgpu/vega20_vce.bin" | ||
60 | 61 | ||
61 | #ifdef CONFIG_DRM_AMDGPU_CIK | 62 | #ifdef CONFIG_DRM_AMDGPU_CIK |
62 | MODULE_FIRMWARE(FIRMWARE_BONAIRE); | 63 | MODULE_FIRMWARE(FIRMWARE_BONAIRE); |
@@ -76,6 +77,7 @@ MODULE_FIRMWARE(FIRMWARE_VEGAM); | |||
76 | 77 | ||
77 | MODULE_FIRMWARE(FIRMWARE_VEGA10); | 78 | MODULE_FIRMWARE(FIRMWARE_VEGA10); |
78 | MODULE_FIRMWARE(FIRMWARE_VEGA12); | 79 | MODULE_FIRMWARE(FIRMWARE_VEGA12); |
80 | MODULE_FIRMWARE(FIRMWARE_VEGA20); | ||
79 | 81 | ||
80 | static void amdgpu_vce_idle_work_handler(struct work_struct *work); | 82 | static void amdgpu_vce_idle_work_handler(struct work_struct *work); |
81 | 83 | ||
@@ -143,6 +145,9 @@ int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size) | |||
143 | case CHIP_VEGA12: | 145 | case CHIP_VEGA12: |
144 | fw_name = FIRMWARE_VEGA12; | 146 | fw_name = FIRMWARE_VEGA12; |
145 | break; | 147 | break; |
148 | case CHIP_VEGA20: | ||
149 | fw_name = FIRMWARE_VEGA20; | ||
150 | break; | ||
146 | 151 | ||
147 | default: | 152 | default: |
148 | return -EINVAL; | 153 | return -EINVAL; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c index e5d234cf804f..8851bcdfc260 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | |||
@@ -205,13 +205,18 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work) | |||
205 | struct amdgpu_device *adev = | 205 | struct amdgpu_device *adev = |
206 | container_of(work, struct amdgpu_device, vcn.idle_work.work); | 206 | container_of(work, struct amdgpu_device, vcn.idle_work.work); |
207 | unsigned fences = amdgpu_fence_count_emitted(&adev->vcn.ring_dec); | 207 | unsigned fences = amdgpu_fence_count_emitted(&adev->vcn.ring_dec); |
208 | unsigned i; | ||
209 | |||
210 | for (i = 0; i < adev->vcn.num_enc_rings; ++i) { | ||
211 | fences += amdgpu_fence_count_emitted(&adev->vcn.ring_enc[i]); | ||
212 | } | ||
208 | 213 | ||
209 | if (fences == 0) { | 214 | if (fences == 0) { |
210 | if (adev->pm.dpm_enabled) { | 215 | if (adev->pm.dpm_enabled) |
211 | /* might be used when with pg/cg | ||
212 | amdgpu_dpm_enable_uvd(adev, false); | 216 | amdgpu_dpm_enable_uvd(adev, false); |
213 | */ | 217 | else |
214 | } | 218 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, |
219 | AMD_PG_STATE_GATE); | ||
215 | } else { | 220 | } else { |
216 | schedule_delayed_work(&adev->vcn.idle_work, VCN_IDLE_TIMEOUT); | 221 | schedule_delayed_work(&adev->vcn.idle_work, VCN_IDLE_TIMEOUT); |
217 | } | 222 | } |
@@ -223,9 +228,11 @@ void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring) | |||
223 | bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work); | 228 | bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work); |
224 | 229 | ||
225 | if (set_clocks && adev->pm.dpm_enabled) { | 230 | if (set_clocks && adev->pm.dpm_enabled) { |
226 | /* might be used when with pg/cg | 231 | if (adev->pm.dpm_enabled) |
227 | amdgpu_dpm_enable_uvd(adev, true); | 232 | amdgpu_dpm_enable_uvd(adev, true); |
228 | */ | 233 | else |
234 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, | ||
235 | AMD_PG_STATE_UNGATE); | ||
229 | } | 236 | } |
230 | } | 237 | } |
231 | 238 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h index 2fd7db891689..181e6afa9847 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | |||
@@ -45,6 +45,17 @@ | |||
45 | #define VCN_ENC_CMD_REG_WRITE 0x0000000b | 45 | #define VCN_ENC_CMD_REG_WRITE 0x0000000b |
46 | #define VCN_ENC_CMD_REG_WAIT 0x0000000c | 46 | #define VCN_ENC_CMD_REG_WAIT 0x0000000c |
47 | 47 | ||
48 | enum engine_status_constants { | ||
49 | UVD_PGFSM_STATUS__UVDM_UVDU_PWR_ON = 0x2AAAA0, | ||
50 | UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON = 0x00000002, | ||
51 | UVD_STATUS__UVD_BUSY = 0x00000004, | ||
52 | GB_ADDR_CONFIG_DEFAULT = 0x26010011, | ||
53 | UVD_STATUS__IDLE = 0x2, | ||
54 | UVD_STATUS__BUSY = 0x5, | ||
55 | UVD_POWER_STATUS__UVD_POWER_STATUS_TILES_OFF = 0x1, | ||
56 | UVD_STATUS__RBC_BUSY = 0x1, | ||
57 | }; | ||
58 | |||
48 | struct amdgpu_vcn { | 59 | struct amdgpu_vcn { |
49 | struct amdgpu_bo *vcpu_bo; | 60 | struct amdgpu_bo *vcpu_bo; |
50 | void *cpu_addr; | 61 | void *cpu_addr; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 1a8f4e0dd023..ccba88cc8c54 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -119,9 +119,7 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base, | |||
119 | * is currently evicted. add the bo to the evicted list to make sure it | 119 | * is currently evicted. add the bo to the evicted list to make sure it |
120 | * is validated on next vm use to avoid fault. | 120 | * is validated on next vm use to avoid fault. |
121 | * */ | 121 | * */ |
122 | spin_lock(&vm->status_lock); | ||
123 | list_move_tail(&base->vm_status, &vm->evicted); | 122 | list_move_tail(&base->vm_status, &vm->evicted); |
124 | spin_unlock(&vm->status_lock); | ||
125 | } | 123 | } |
126 | 124 | ||
127 | /** | 125 | /** |
@@ -226,24 +224,16 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
226 | void *param) | 224 | void *param) |
227 | { | 225 | { |
228 | struct ttm_bo_global *glob = adev->mman.bdev.glob; | 226 | struct ttm_bo_global *glob = adev->mman.bdev.glob; |
229 | int r; | 227 | struct amdgpu_vm_bo_base *bo_base, *tmp; |
230 | 228 | int r = 0; | |
231 | spin_lock(&vm->status_lock); | ||
232 | while (!list_empty(&vm->evicted)) { | ||
233 | struct amdgpu_vm_bo_base *bo_base; | ||
234 | struct amdgpu_bo *bo; | ||
235 | 229 | ||
236 | bo_base = list_first_entry(&vm->evicted, | 230 | list_for_each_entry_safe(bo_base, tmp, &vm->evicted, vm_status) { |
237 | struct amdgpu_vm_bo_base, | 231 | struct amdgpu_bo *bo = bo_base->bo; |
238 | vm_status); | ||
239 | spin_unlock(&vm->status_lock); | ||
240 | 232 | ||
241 | bo = bo_base->bo; | ||
242 | BUG_ON(!bo); | ||
243 | if (bo->parent) { | 233 | if (bo->parent) { |
244 | r = validate(param, bo); | 234 | r = validate(param, bo); |
245 | if (r) | 235 | if (r) |
246 | return r; | 236 | break; |
247 | 237 | ||
248 | spin_lock(&glob->lru_lock); | 238 | spin_lock(&glob->lru_lock); |
249 | ttm_bo_move_to_lru_tail(&bo->tbo); | 239 | ttm_bo_move_to_lru_tail(&bo->tbo); |
@@ -252,22 +242,29 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
252 | spin_unlock(&glob->lru_lock); | 242 | spin_unlock(&glob->lru_lock); |
253 | } | 243 | } |
254 | 244 | ||
255 | if (bo->tbo.type == ttm_bo_type_kernel && | 245 | if (bo->tbo.type != ttm_bo_type_kernel) { |
256 | vm->use_cpu_for_update) { | 246 | spin_lock(&vm->moved_lock); |
257 | r = amdgpu_bo_kmap(bo, NULL); | ||
258 | if (r) | ||
259 | return r; | ||
260 | } | ||
261 | |||
262 | spin_lock(&vm->status_lock); | ||
263 | if (bo->tbo.type != ttm_bo_type_kernel) | ||
264 | list_move(&bo_base->vm_status, &vm->moved); | 247 | list_move(&bo_base->vm_status, &vm->moved); |
265 | else | 248 | spin_unlock(&vm->moved_lock); |
249 | } else { | ||
266 | list_move(&bo_base->vm_status, &vm->relocated); | 250 | list_move(&bo_base->vm_status, &vm->relocated); |
251 | } | ||
267 | } | 252 | } |
268 | spin_unlock(&vm->status_lock); | ||
269 | 253 | ||
270 | return 0; | 254 | spin_lock(&glob->lru_lock); |
255 | list_for_each_entry(bo_base, &vm->idle, vm_status) { | ||
256 | struct amdgpu_bo *bo = bo_base->bo; | ||
257 | |||
258 | if (!bo->parent) | ||
259 | continue; | ||
260 | |||
261 | ttm_bo_move_to_lru_tail(&bo->tbo); | ||
262 | if (bo->shadow) | ||
263 | ttm_bo_move_to_lru_tail(&bo->shadow->tbo); | ||
264 | } | ||
265 | spin_unlock(&glob->lru_lock); | ||
266 | |||
267 | return r; | ||
271 | } | 268 | } |
272 | 269 | ||
273 | /** | 270 | /** |
@@ -279,13 +276,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
279 | */ | 276 | */ |
280 | bool amdgpu_vm_ready(struct amdgpu_vm *vm) | 277 | bool amdgpu_vm_ready(struct amdgpu_vm *vm) |
281 | { | 278 | { |
282 | bool ready; | 279 | return list_empty(&vm->evicted); |
283 | |||
284 | spin_lock(&vm->status_lock); | ||
285 | ready = list_empty(&vm->evicted); | ||
286 | spin_unlock(&vm->status_lock); | ||
287 | |||
288 | return ready; | ||
289 | } | 280 | } |
290 | 281 | ||
291 | /** | 282 | /** |
@@ -477,9 +468,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, | |||
477 | pt->parent = amdgpu_bo_ref(parent->base.bo); | 468 | pt->parent = amdgpu_bo_ref(parent->base.bo); |
478 | 469 | ||
479 | amdgpu_vm_bo_base_init(&entry->base, vm, pt); | 470 | amdgpu_vm_bo_base_init(&entry->base, vm, pt); |
480 | spin_lock(&vm->status_lock); | ||
481 | list_move(&entry->base.vm_status, &vm->relocated); | 471 | list_move(&entry->base.vm_status, &vm->relocated); |
482 | spin_unlock(&vm->status_lock); | ||
483 | } | 472 | } |
484 | 473 | ||
485 | if (level < AMDGPU_VM_PTB) { | 474 | if (level < AMDGPU_VM_PTB) { |
@@ -926,10 +915,8 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_device *adev, | |||
926 | if (!entry->base.bo) | 915 | if (!entry->base.bo) |
927 | continue; | 916 | continue; |
928 | 917 | ||
929 | spin_lock(&vm->status_lock); | 918 | if (!entry->base.moved) |
930 | if (list_empty(&entry->base.vm_status)) | 919 | list_move(&entry->base.vm_status, &vm->relocated); |
931 | list_add(&entry->base.vm_status, &vm->relocated); | ||
932 | spin_unlock(&vm->status_lock); | ||
933 | amdgpu_vm_invalidate_level(adev, vm, entry, level + 1); | 920 | amdgpu_vm_invalidate_level(adev, vm, entry, level + 1); |
934 | } | 921 | } |
935 | } | 922 | } |
@@ -959,6 +946,14 @@ restart: | |||
959 | params.adev = adev; | 946 | params.adev = adev; |
960 | 947 | ||
961 | if (vm->use_cpu_for_update) { | 948 | if (vm->use_cpu_for_update) { |
949 | struct amdgpu_vm_bo_base *bo_base; | ||
950 | |||
951 | list_for_each_entry(bo_base, &vm->relocated, vm_status) { | ||
952 | r = amdgpu_bo_kmap(bo_base->bo, NULL); | ||
953 | if (unlikely(r)) | ||
954 | return r; | ||
955 | } | ||
956 | |||
962 | r = amdgpu_vm_wait_pd(adev, vm, AMDGPU_FENCE_OWNER_VM); | 957 | r = amdgpu_vm_wait_pd(adev, vm, AMDGPU_FENCE_OWNER_VM); |
963 | if (unlikely(r)) | 958 | if (unlikely(r)) |
964 | return r; | 959 | return r; |
@@ -974,7 +969,6 @@ restart: | |||
974 | params.func = amdgpu_vm_do_set_ptes; | 969 | params.func = amdgpu_vm_do_set_ptes; |
975 | } | 970 | } |
976 | 971 | ||
977 | spin_lock(&vm->status_lock); | ||
978 | while (!list_empty(&vm->relocated)) { | 972 | while (!list_empty(&vm->relocated)) { |
979 | struct amdgpu_vm_bo_base *bo_base, *parent; | 973 | struct amdgpu_vm_bo_base *bo_base, *parent; |
980 | struct amdgpu_vm_pt *pt, *entry; | 974 | struct amdgpu_vm_pt *pt, *entry; |
@@ -983,14 +977,12 @@ restart: | |||
983 | bo_base = list_first_entry(&vm->relocated, | 977 | bo_base = list_first_entry(&vm->relocated, |
984 | struct amdgpu_vm_bo_base, | 978 | struct amdgpu_vm_bo_base, |
985 | vm_status); | 979 | vm_status); |
986 | list_del_init(&bo_base->vm_status); | 980 | bo_base->moved = false; |
987 | spin_unlock(&vm->status_lock); | 981 | list_move(&bo_base->vm_status, &vm->idle); |
988 | 982 | ||
989 | bo = bo_base->bo->parent; | 983 | bo = bo_base->bo->parent; |
990 | if (!bo) { | 984 | if (!bo) |
991 | spin_lock(&vm->status_lock); | ||
992 | continue; | 985 | continue; |
993 | } | ||
994 | 986 | ||
995 | parent = list_first_entry(&bo->va, struct amdgpu_vm_bo_base, | 987 | parent = list_first_entry(&bo->va, struct amdgpu_vm_bo_base, |
996 | bo_list); | 988 | bo_list); |
@@ -999,12 +991,10 @@ restart: | |||
999 | 991 | ||
1000 | amdgpu_vm_update_pde(¶ms, vm, pt, entry); | 992 | amdgpu_vm_update_pde(¶ms, vm, pt, entry); |
1001 | 993 | ||
1002 | spin_lock(&vm->status_lock); | ||
1003 | if (!vm->use_cpu_for_update && | 994 | if (!vm->use_cpu_for_update && |
1004 | (ndw - params.ib->length_dw) < 32) | 995 | (ndw - params.ib->length_dw) < 32) |
1005 | break; | 996 | break; |
1006 | } | 997 | } |
1007 | spin_unlock(&vm->status_lock); | ||
1008 | 998 | ||
1009 | if (vm->use_cpu_for_update) { | 999 | if (vm->use_cpu_for_update) { |
1010 | /* Flush HDP */ | 1000 | /* Flush HDP */ |
@@ -1107,9 +1097,7 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p, | |||
1107 | if (entry->huge) { | 1097 | if (entry->huge) { |
1108 | /* Add the entry to the relocated list to update it. */ | 1098 | /* Add the entry to the relocated list to update it. */ |
1109 | entry->huge = false; | 1099 | entry->huge = false; |
1110 | spin_lock(&p->vm->status_lock); | ||
1111 | list_move(&entry->base.vm_status, &p->vm->relocated); | 1100 | list_move(&entry->base.vm_status, &p->vm->relocated); |
1112 | spin_unlock(&p->vm->status_lock); | ||
1113 | } | 1101 | } |
1114 | return; | 1102 | return; |
1115 | } | 1103 | } |
@@ -1588,18 +1576,22 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, | |||
1588 | amdgpu_asic_flush_hdp(adev, NULL); | 1576 | amdgpu_asic_flush_hdp(adev, NULL); |
1589 | } | 1577 | } |
1590 | 1578 | ||
1591 | spin_lock(&vm->status_lock); | 1579 | spin_lock(&vm->moved_lock); |
1592 | list_del_init(&bo_va->base.vm_status); | 1580 | list_del_init(&bo_va->base.vm_status); |
1581 | spin_unlock(&vm->moved_lock); | ||
1593 | 1582 | ||
1594 | /* If the BO is not in its preferred location add it back to | 1583 | /* If the BO is not in its preferred location add it back to |
1595 | * the evicted list so that it gets validated again on the | 1584 | * the evicted list so that it gets validated again on the |
1596 | * next command submission. | 1585 | * next command submission. |
1597 | */ | 1586 | */ |
1598 | if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv && | 1587 | if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv) { |
1599 | !(bo->preferred_domains & | 1588 | uint32_t mem_type = bo->tbo.mem.mem_type; |
1600 | amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type))) | 1589 | |
1601 | list_add_tail(&bo_va->base.vm_status, &vm->evicted); | 1590 | if (!(bo->preferred_domains & amdgpu_mem_type_to_domain(mem_type))) |
1602 | spin_unlock(&vm->status_lock); | 1591 | list_add_tail(&bo_va->base.vm_status, &vm->evicted); |
1592 | else | ||
1593 | list_add(&bo_va->base.vm_status, &vm->idle); | ||
1594 | } | ||
1603 | 1595 | ||
1604 | list_splice_init(&bo_va->invalids, &bo_va->valids); | 1596 | list_splice_init(&bo_va->invalids, &bo_va->valids); |
1605 | bo_va->cleared = clear; | 1597 | bo_va->cleared = clear; |
@@ -1808,19 +1800,18 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, | |||
1808 | int amdgpu_vm_handle_moved(struct amdgpu_device *adev, | 1800 | int amdgpu_vm_handle_moved(struct amdgpu_device *adev, |
1809 | struct amdgpu_vm *vm) | 1801 | struct amdgpu_vm *vm) |
1810 | { | 1802 | { |
1803 | struct amdgpu_bo_va *bo_va, *tmp; | ||
1804 | struct list_head moved; | ||
1811 | bool clear; | 1805 | bool clear; |
1812 | int r = 0; | 1806 | int r; |
1813 | |||
1814 | spin_lock(&vm->status_lock); | ||
1815 | while (!list_empty(&vm->moved)) { | ||
1816 | struct amdgpu_bo_va *bo_va; | ||
1817 | struct reservation_object *resv; | ||
1818 | 1807 | ||
1819 | bo_va = list_first_entry(&vm->moved, | 1808 | INIT_LIST_HEAD(&moved); |
1820 | struct amdgpu_bo_va, base.vm_status); | 1809 | spin_lock(&vm->moved_lock); |
1821 | spin_unlock(&vm->status_lock); | 1810 | list_splice_init(&vm->moved, &moved); |
1811 | spin_unlock(&vm->moved_lock); | ||
1822 | 1812 | ||
1823 | resv = bo_va->base.bo->tbo.resv; | 1813 | list_for_each_entry_safe(bo_va, tmp, &moved, base.vm_status) { |
1814 | struct reservation_object *resv = bo_va->base.bo->tbo.resv; | ||
1824 | 1815 | ||
1825 | /* Per VM BOs never need to bo cleared in the page tables */ | 1816 | /* Per VM BOs never need to bo cleared in the page tables */ |
1826 | if (resv == vm->root.base.bo->tbo.resv) | 1817 | if (resv == vm->root.base.bo->tbo.resv) |
@@ -1833,17 +1824,19 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev, | |||
1833 | clear = true; | 1824 | clear = true; |
1834 | 1825 | ||
1835 | r = amdgpu_vm_bo_update(adev, bo_va, clear); | 1826 | r = amdgpu_vm_bo_update(adev, bo_va, clear); |
1836 | if (r) | 1827 | if (r) { |
1828 | spin_lock(&vm->moved_lock); | ||
1829 | list_splice(&moved, &vm->moved); | ||
1830 | spin_unlock(&vm->moved_lock); | ||
1837 | return r; | 1831 | return r; |
1832 | } | ||
1838 | 1833 | ||
1839 | if (!clear && resv != vm->root.base.bo->tbo.resv) | 1834 | if (!clear && resv != vm->root.base.bo->tbo.resv) |
1840 | reservation_object_unlock(resv); | 1835 | reservation_object_unlock(resv); |
1841 | 1836 | ||
1842 | spin_lock(&vm->status_lock); | ||
1843 | } | 1837 | } |
1844 | spin_unlock(&vm->status_lock); | ||
1845 | 1838 | ||
1846 | return r; | 1839 | return 0; |
1847 | } | 1840 | } |
1848 | 1841 | ||
1849 | /** | 1842 | /** |
@@ -1902,11 +1895,11 @@ static void amdgpu_vm_bo_insert_map(struct amdgpu_device *adev, | |||
1902 | if (mapping->flags & AMDGPU_PTE_PRT) | 1895 | if (mapping->flags & AMDGPU_PTE_PRT) |
1903 | amdgpu_vm_prt_get(adev); | 1896 | amdgpu_vm_prt_get(adev); |
1904 | 1897 | ||
1905 | if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv) { | 1898 | if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv && |
1906 | spin_lock(&vm->status_lock); | 1899 | !bo_va->base.moved) { |
1907 | if (list_empty(&bo_va->base.vm_status)) | 1900 | spin_lock(&vm->moved_lock); |
1908 | list_add(&bo_va->base.vm_status, &vm->moved); | 1901 | list_move(&bo_va->base.vm_status, &vm->moved); |
1909 | spin_unlock(&vm->status_lock); | 1902 | spin_unlock(&vm->moved_lock); |
1910 | } | 1903 | } |
1911 | trace_amdgpu_vm_bo_map(bo_va, mapping); | 1904 | trace_amdgpu_vm_bo_map(bo_va, mapping); |
1912 | } | 1905 | } |
@@ -2216,9 +2209,9 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, | |||
2216 | 2209 | ||
2217 | list_del(&bo_va->base.bo_list); | 2210 | list_del(&bo_va->base.bo_list); |
2218 | 2211 | ||
2219 | spin_lock(&vm->status_lock); | 2212 | spin_lock(&vm->moved_lock); |
2220 | list_del(&bo_va->base.vm_status); | 2213 | list_del(&bo_va->base.vm_status); |
2221 | spin_unlock(&vm->status_lock); | 2214 | spin_unlock(&vm->moved_lock); |
2222 | 2215 | ||
2223 | list_for_each_entry_safe(mapping, next, &bo_va->valids, list) { | 2216 | list_for_each_entry_safe(mapping, next, &bo_va->valids, list) { |
2224 | list_del(&mapping->list); | 2217 | list_del(&mapping->list); |
@@ -2258,31 +2251,28 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev, | |||
2258 | 2251 | ||
2259 | list_for_each_entry(bo_base, &bo->va, bo_list) { | 2252 | list_for_each_entry(bo_base, &bo->va, bo_list) { |
2260 | struct amdgpu_vm *vm = bo_base->vm; | 2253 | struct amdgpu_vm *vm = bo_base->vm; |
2254 | bool was_moved = bo_base->moved; | ||
2261 | 2255 | ||
2262 | bo_base->moved = true; | 2256 | bo_base->moved = true; |
2263 | if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) { | 2257 | if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) { |
2264 | spin_lock(&bo_base->vm->status_lock); | ||
2265 | if (bo->tbo.type == ttm_bo_type_kernel) | 2258 | if (bo->tbo.type == ttm_bo_type_kernel) |
2266 | list_move(&bo_base->vm_status, &vm->evicted); | 2259 | list_move(&bo_base->vm_status, &vm->evicted); |
2267 | else | 2260 | else |
2268 | list_move_tail(&bo_base->vm_status, | 2261 | list_move_tail(&bo_base->vm_status, |
2269 | &vm->evicted); | 2262 | &vm->evicted); |
2270 | spin_unlock(&bo_base->vm->status_lock); | ||
2271 | continue; | 2263 | continue; |
2272 | } | 2264 | } |
2273 | 2265 | ||
2274 | if (bo->tbo.type == ttm_bo_type_kernel) { | 2266 | if (was_moved) |
2275 | spin_lock(&bo_base->vm->status_lock); | ||
2276 | if (list_empty(&bo_base->vm_status)) | ||
2277 | list_add(&bo_base->vm_status, &vm->relocated); | ||
2278 | spin_unlock(&bo_base->vm->status_lock); | ||
2279 | continue; | 2267 | continue; |
2280 | } | ||
2281 | 2268 | ||
2282 | spin_lock(&bo_base->vm->status_lock); | 2269 | if (bo->tbo.type == ttm_bo_type_kernel) { |
2283 | if (list_empty(&bo_base->vm_status)) | 2270 | list_move(&bo_base->vm_status, &vm->relocated); |
2284 | list_add(&bo_base->vm_status, &vm->moved); | 2271 | } else { |
2285 | spin_unlock(&bo_base->vm->status_lock); | 2272 | spin_lock(&bo_base->vm->moved_lock); |
2273 | list_move(&bo_base->vm_status, &vm->moved); | ||
2274 | spin_unlock(&bo_base->vm->moved_lock); | ||
2275 | } | ||
2286 | } | 2276 | } |
2287 | } | 2277 | } |
2288 | 2278 | ||
@@ -2391,10 +2381,11 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
2391 | vm->va = RB_ROOT_CACHED; | 2381 | vm->va = RB_ROOT_CACHED; |
2392 | for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) | 2382 | for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) |
2393 | vm->reserved_vmid[i] = NULL; | 2383 | vm->reserved_vmid[i] = NULL; |
2394 | spin_lock_init(&vm->status_lock); | ||
2395 | INIT_LIST_HEAD(&vm->evicted); | 2384 | INIT_LIST_HEAD(&vm->evicted); |
2396 | INIT_LIST_HEAD(&vm->relocated); | 2385 | INIT_LIST_HEAD(&vm->relocated); |
2386 | spin_lock_init(&vm->moved_lock); | ||
2397 | INIT_LIST_HEAD(&vm->moved); | 2387 | INIT_LIST_HEAD(&vm->moved); |
2388 | INIT_LIST_HEAD(&vm->idle); | ||
2398 | INIT_LIST_HEAD(&vm->freed); | 2389 | INIT_LIST_HEAD(&vm->freed); |
2399 | 2390 | ||
2400 | /* create scheduler entity for page table updates */ | 2391 | /* create scheduler entity for page table updates */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 4cf678684a12..061b99a18cb8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | |||
@@ -168,9 +168,6 @@ struct amdgpu_vm { | |||
168 | /* tree of virtual addresses mapped */ | 168 | /* tree of virtual addresses mapped */ |
169 | struct rb_root_cached va; | 169 | struct rb_root_cached va; |
170 | 170 | ||
171 | /* protecting invalidated */ | ||
172 | spinlock_t status_lock; | ||
173 | |||
174 | /* BOs who needs a validation */ | 171 | /* BOs who needs a validation */ |
175 | struct list_head evicted; | 172 | struct list_head evicted; |
176 | 173 | ||
@@ -179,6 +176,10 @@ struct amdgpu_vm { | |||
179 | 176 | ||
180 | /* BOs moved, but not yet updated in the PT */ | 177 | /* BOs moved, but not yet updated in the PT */ |
181 | struct list_head moved; | 178 | struct list_head moved; |
179 | spinlock_t moved_lock; | ||
180 | |||
181 | /* All BOs of this VM not currently in the state machine */ | ||
182 | struct list_head idle; | ||
182 | 183 | ||
183 | /* BO mappings freed, but not yet updated in the PT */ | 184 | /* BO mappings freed, but not yet updated in the PT */ |
184 | struct list_head freed; | 185 | struct list_head freed; |
@@ -187,9 +188,6 @@ struct amdgpu_vm { | |||
187 | struct amdgpu_vm_pt root; | 188 | struct amdgpu_vm_pt root; |
188 | struct dma_fence *last_update; | 189 | struct dma_fence *last_update; |
189 | 190 | ||
190 | /* protecting freed */ | ||
191 | spinlock_t freed_lock; | ||
192 | |||
193 | /* Scheduler entity for page table updates */ | 191 | /* Scheduler entity for page table updates */ |
194 | struct drm_sched_entity entity; | 192 | struct drm_sched_entity entity; |
195 | 193 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c index de7be3de0f41..dbf2ccd0c744 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c | |||
@@ -473,6 +473,7 @@ static int dce_virtual_hw_init(void *handle) | |||
473 | break; | 473 | break; |
474 | case CHIP_VEGA10: | 474 | case CHIP_VEGA10: |
475 | case CHIP_VEGA12: | 475 | case CHIP_VEGA12: |
476 | case CHIP_VEGA20: | ||
476 | break; | 477 | break; |
477 | default: | 478 | default: |
478 | DRM_ERROR("Virtual display unsupported ASIC type: 0x%X\n", adev->asic_type); | 479 | DRM_ERROR("Virtual display unsupported ASIC type: 0x%X\n", adev->asic_type); |
diff --git a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c index 4ffda996660f..9935371db7ce 100644 --- a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c +++ b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c | |||
@@ -102,6 +102,13 @@ static void df_v1_7_get_clockgating_state(struct amdgpu_device *adev, | |||
102 | *flags |= AMD_CG_SUPPORT_DF_MGCG; | 102 | *flags |= AMD_CG_SUPPORT_DF_MGCG; |
103 | } | 103 | } |
104 | 104 | ||
105 | static void df_v1_7_enable_ecc_force_par_wr_rmw(struct amdgpu_device *adev, | ||
106 | bool enable) | ||
107 | { | ||
108 | WREG32_FIELD15(DF, 0, DF_CS_AON0_CoherentSlaveModeCtrlA0, | ||
109 | ForceParWrRMW, enable); | ||
110 | } | ||
111 | |||
105 | const struct amdgpu_df_funcs df_v1_7_funcs = { | 112 | const struct amdgpu_df_funcs df_v1_7_funcs = { |
106 | .init = df_v1_7_init, | 113 | .init = df_v1_7_init, |
107 | .enable_broadcast_mode = df_v1_7_enable_broadcast_mode, | 114 | .enable_broadcast_mode = df_v1_7_enable_broadcast_mode, |
@@ -109,4 +116,5 @@ const struct amdgpu_df_funcs df_v1_7_funcs = { | |||
109 | .get_hbm_channel_number = df_v1_7_get_hbm_channel_number, | 116 | .get_hbm_channel_number = df_v1_7_get_hbm_channel_number, |
110 | .update_medium_grain_clock_gating = df_v1_7_update_medium_grain_clock_gating, | 117 | .update_medium_grain_clock_gating = df_v1_7_update_medium_grain_clock_gating, |
111 | .get_clockgating_state = df_v1_7_get_clockgating_state, | 118 | .get_clockgating_state = df_v1_7_get_clockgating_state, |
119 | .enable_ecc_force_par_wr_rmw = df_v1_7_enable_ecc_force_par_wr_rmw, | ||
112 | }; | 120 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c new file mode 100644 index 000000000000..60608b3df881 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * Copyright 2018 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 "df_v3_6.h" | ||
25 | |||
26 | #include "df/df_3_6_default.h" | ||
27 | #include "df/df_3_6_offset.h" | ||
28 | #include "df/df_3_6_sh_mask.h" | ||
29 | |||
30 | static u32 df_v3_6_channel_number[] = {1, 2, 0, 4, 0, 8, 0, | ||
31 | 16, 32, 0, 0, 0, 2, 4, 8}; | ||
32 | |||
33 | static void df_v3_6_init(struct amdgpu_device *adev) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | static void df_v3_6_enable_broadcast_mode(struct amdgpu_device *adev, | ||
38 | bool enable) | ||
39 | { | ||
40 | u32 tmp; | ||
41 | |||
42 | if (enable) { | ||
43 | tmp = RREG32_SOC15(DF, 0, mmFabricConfigAccessControl); | ||
44 | tmp &= ~FabricConfigAccessControl__CfgRegInstAccEn_MASK; | ||
45 | WREG32_SOC15(DF, 0, mmFabricConfigAccessControl, tmp); | ||
46 | } else | ||
47 | WREG32_SOC15(DF, 0, mmFabricConfigAccessControl, | ||
48 | mmFabricConfigAccessControl_DEFAULT); | ||
49 | } | ||
50 | |||
51 | static u32 df_v3_6_get_fb_channel_number(struct amdgpu_device *adev) | ||
52 | { | ||
53 | u32 tmp; | ||
54 | |||
55 | tmp = RREG32_SOC15(DF, 0, mmDF_CS_UMC_AON0_DramBaseAddress0); | ||
56 | tmp &= DF_CS_UMC_AON0_DramBaseAddress0__IntLvNumChan_MASK; | ||
57 | tmp >>= DF_CS_UMC_AON0_DramBaseAddress0__IntLvNumChan__SHIFT; | ||
58 | |||
59 | return tmp; | ||
60 | } | ||
61 | |||
62 | static u32 df_v3_6_get_hbm_channel_number(struct amdgpu_device *adev) | ||
63 | { | ||
64 | int fb_channel_number; | ||
65 | |||
66 | fb_channel_number = adev->df_funcs->get_fb_channel_number(adev); | ||
67 | if (fb_channel_number > ARRAY_SIZE(df_v3_6_channel_number)) | ||
68 | fb_channel_number = 0; | ||
69 | |||
70 | return df_v3_6_channel_number[fb_channel_number]; | ||
71 | } | ||
72 | |||
73 | static void df_v3_6_update_medium_grain_clock_gating(struct amdgpu_device *adev, | ||
74 | bool enable) | ||
75 | { | ||
76 | u32 tmp; | ||
77 | |||
78 | /* Put DF on broadcast mode */ | ||
79 | adev->df_funcs->enable_broadcast_mode(adev, true); | ||
80 | |||
81 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_DF_MGCG)) { | ||
82 | tmp = RREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater); | ||
83 | tmp &= ~DF_PIE_AON0_DfGlobalClkGater__MGCGMode_MASK; | ||
84 | tmp |= DF_V3_6_MGCG_ENABLE_15_CYCLE_DELAY; | ||
85 | WREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater, tmp); | ||
86 | } else { | ||
87 | tmp = RREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater); | ||
88 | tmp &= ~DF_PIE_AON0_DfGlobalClkGater__MGCGMode_MASK; | ||
89 | tmp |= DF_V3_6_MGCG_DISABLE; | ||
90 | WREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater, tmp); | ||
91 | } | ||
92 | |||
93 | /* Exit broadcast mode */ | ||
94 | adev->df_funcs->enable_broadcast_mode(adev, false); | ||
95 | } | ||
96 | |||
97 | static void df_v3_6_get_clockgating_state(struct amdgpu_device *adev, | ||
98 | u32 *flags) | ||
99 | { | ||
100 | u32 tmp; | ||
101 | |||
102 | /* AMD_CG_SUPPORT_DF_MGCG */ | ||
103 | tmp = RREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater); | ||
104 | if (tmp & DF_V3_6_MGCG_ENABLE_15_CYCLE_DELAY) | ||
105 | *flags |= AMD_CG_SUPPORT_DF_MGCG; | ||
106 | } | ||
107 | |||
108 | const struct amdgpu_df_funcs df_v3_6_funcs = { | ||
109 | .init = df_v3_6_init, | ||
110 | .enable_broadcast_mode = df_v3_6_enable_broadcast_mode, | ||
111 | .get_fb_channel_number = df_v3_6_get_fb_channel_number, | ||
112 | .get_hbm_channel_number = df_v3_6_get_hbm_channel_number, | ||
113 | .update_medium_grain_clock_gating = | ||
114 | df_v3_6_update_medium_grain_clock_gating, | ||
115 | .get_clockgating_state = df_v3_6_get_clockgating_state, | ||
116 | }; | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/df_v3_6.h b/drivers/gpu/drm/amd/amdgpu/df_v3_6.h new file mode 100644 index 000000000000..e79c58e5efcb --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/df_v3_6.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | * Copyright 2018 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 __DF_V3_6_H__ | ||
25 | #define __DF_V3_6_H__ | ||
26 | |||
27 | #include "soc15_common.h" | ||
28 | |||
29 | enum DF_V3_6_MGCG { | ||
30 | DF_V3_6_MGCG_DISABLE = 0, | ||
31 | DF_V3_6_MGCG_ENABLE_00_CYCLE_DELAY = 1, | ||
32 | DF_V3_6_MGCG_ENABLE_01_CYCLE_DELAY = 2, | ||
33 | DF_V3_6_MGCG_ENABLE_15_CYCLE_DELAY = 13, | ||
34 | DF_V3_6_MGCG_ENABLE_31_CYCLE_DELAY = 14, | ||
35 | DF_V3_6_MGCG_ENABLE_63_CYCLE_DELAY = 15 | ||
36 | }; | ||
37 | |||
38 | extern const struct amdgpu_df_funcs df_v3_6_funcs; | ||
39 | |||
40 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index fc1911834ab5..d7530fdfaad5 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "amdgpu_gfx.h" | 27 | #include "amdgpu_gfx.h" |
28 | #include "soc15.h" | 28 | #include "soc15.h" |
29 | #include "soc15d.h" | 29 | #include "soc15d.h" |
30 | #include "amdgpu_atomfirmware.h" | ||
30 | 31 | ||
31 | #include "gc/gc_9_0_offset.h" | 32 | #include "gc/gc_9_0_offset.h" |
32 | #include "gc/gc_9_0_sh_mask.h" | 33 | #include "gc/gc_9_0_sh_mask.h" |
@@ -63,6 +64,13 @@ MODULE_FIRMWARE("amdgpu/vega12_mec.bin"); | |||
63 | MODULE_FIRMWARE("amdgpu/vega12_mec2.bin"); | 64 | MODULE_FIRMWARE("amdgpu/vega12_mec2.bin"); |
64 | MODULE_FIRMWARE("amdgpu/vega12_rlc.bin"); | 65 | MODULE_FIRMWARE("amdgpu/vega12_rlc.bin"); |
65 | 66 | ||
67 | MODULE_FIRMWARE("amdgpu/vega20_ce.bin"); | ||
68 | MODULE_FIRMWARE("amdgpu/vega20_pfp.bin"); | ||
69 | MODULE_FIRMWARE("amdgpu/vega20_me.bin"); | ||
70 | MODULE_FIRMWARE("amdgpu/vega20_mec.bin"); | ||
71 | MODULE_FIRMWARE("amdgpu/vega20_mec2.bin"); | ||
72 | MODULE_FIRMWARE("amdgpu/vega20_rlc.bin"); | ||
73 | |||
66 | MODULE_FIRMWARE("amdgpu/raven_ce.bin"); | 74 | MODULE_FIRMWARE("amdgpu/raven_ce.bin"); |
67 | MODULE_FIRMWARE("amdgpu/raven_pfp.bin"); | 75 | MODULE_FIRMWARE("amdgpu/raven_pfp.bin"); |
68 | MODULE_FIRMWARE("amdgpu/raven_me.bin"); | 76 | MODULE_FIRMWARE("amdgpu/raven_me.bin"); |
@@ -72,29 +80,22 @@ MODULE_FIRMWARE("amdgpu/raven_rlc.bin"); | |||
72 | 80 | ||
73 | static const struct soc15_reg_golden golden_settings_gc_9_0[] = | 81 | static const struct soc15_reg_golden golden_settings_gc_9_0[] = |
74 | { | 82 | { |
75 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPC_UTCL1_CNTL, 0x08000000, 0x08000080), | ||
76 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPF_UTCL1_CNTL, 0x08000000, 0x08000080), | ||
77 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPG_UTCL1_CNTL, 0x08000000, 0x08000080), | ||
78 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0xf00fffff, 0x00000420), | 83 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0xf00fffff, 0x00000420), |
79 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_GPU_ID, 0x0000000f, 0x00000000), | 84 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_GPU_ID, 0x0000000f, 0x00000000), |
80 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmIA_UTCL1_CNTL, 0x08000000, 0x08000080), | ||
81 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3, 0x00000003, 0x82400024), | 85 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3, 0x00000003, 0x82400024), |
82 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fffffff, 0x00000001), | 86 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fffffff, 0x00000001), |
83 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000), | 87 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000), |
84 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_0, 0x08000000, 0x08000080), | ||
85 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_1, 0x08000000, 0x08000080), | ||
86 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_2, 0x08000000, 0x08000080), | ||
87 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_PREWALKER_UTCL1_CNTL, 0x08000000, 0x08000080), | ||
88 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_UTCL1_CNTL, 0x08000000, 0x08000080), | ||
89 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSH_MEM_CONFIG, 0x00001000, 0x00001000), | 88 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSH_MEM_CONFIG, 0x00001000, 0x00001000), |
90 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107), | 89 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_CU_0, 0x0007ffff, 0x00000800), |
90 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_CU_1, 0x0007ffff, 0x00000800), | ||
91 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_EN_CU_0, 0x01ffffff, 0x0000ff87), | ||
92 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_RESOURCE_RESERVE_EN_CU_1, 0x01ffffff, 0x0000ff8f), | ||
91 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQC_CONFIG, 0x03000000, 0x020a2000), | 93 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQC_CONFIG, 0x03000000, 0x020a2000), |
92 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfffffeef, 0x010b0000), | 94 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfffffeef, 0x010b0000), |
93 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x4a2c0e68), | 95 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x4a2c0e68), |
94 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0xb5d3f197), | 96 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0xb5d3f197), |
95 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000), | 97 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000), |
96 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff), | 98 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff) |
97 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080) | ||
98 | }; | 99 | }; |
99 | 100 | ||
100 | static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] = | 101 | static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] = |
@@ -108,6 +109,20 @@ static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] = | |||
108 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800) | 109 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800) |
109 | }; | 110 | }; |
110 | 111 | ||
112 | static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] = | ||
113 | { | ||
114 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_2, 0x0f000000, 0x0a000000), | ||
115 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_3, 0x30000000, 0x10000000), | ||
116 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xf3e777ff, 0x22014042), | ||
117 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG_READ, 0xf3e777ff, 0x22014042), | ||
118 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0x00003e00, 0x00000400), | ||
119 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0xff840000, 0x04040000), | ||
120 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00030000), | ||
121 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0xffff010f, 0x01000107), | ||
122 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0x000b0000, 0x000b0000), | ||
123 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01000000, 0x01000000) | ||
124 | }; | ||
125 | |||
111 | static const struct soc15_reg_golden golden_settings_gc_9_1[] = | 126 | static const struct soc15_reg_golden golden_settings_gc_9_1[] = |
112 | { | 127 | { |
113 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL, 0xfffdf3cf, 0x00014104), | 128 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL, 0xfffdf3cf, 0x00014104), |
@@ -241,6 +256,14 @@ static void gfx_v9_0_init_golden_registers(struct amdgpu_device *adev) | |||
241 | golden_settings_gc_9_2_1_vg12, | 256 | golden_settings_gc_9_2_1_vg12, |
242 | ARRAY_SIZE(golden_settings_gc_9_2_1_vg12)); | 257 | ARRAY_SIZE(golden_settings_gc_9_2_1_vg12)); |
243 | break; | 258 | break; |
259 | case CHIP_VEGA20: | ||
260 | soc15_program_register_sequence(adev, | ||
261 | golden_settings_gc_9_0, | ||
262 | ARRAY_SIZE(golden_settings_gc_9_0)); | ||
263 | soc15_program_register_sequence(adev, | ||
264 | golden_settings_gc_9_0_vg20, | ||
265 | ARRAY_SIZE(golden_settings_gc_9_0_vg20)); | ||
266 | break; | ||
244 | case CHIP_RAVEN: | 267 | case CHIP_RAVEN: |
245 | soc15_program_register_sequence(adev, | 268 | soc15_program_register_sequence(adev, |
246 | golden_settings_gc_9_1, | 269 | golden_settings_gc_9_1, |
@@ -468,6 +491,9 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev) | |||
468 | case CHIP_VEGA12: | 491 | case CHIP_VEGA12: |
469 | chip_name = "vega12"; | 492 | chip_name = "vega12"; |
470 | break; | 493 | break; |
494 | case CHIP_VEGA20: | ||
495 | chip_name = "vega20"; | ||
496 | break; | ||
471 | case CHIP_RAVEN: | 497 | case CHIP_RAVEN: |
472 | chip_name = "raven"; | 498 | chip_name = "raven"; |
473 | break; | 499 | break; |
@@ -1088,9 +1114,10 @@ static const struct amdgpu_gfx_funcs gfx_v9_0_gfx_funcs = { | |||
1088 | .select_me_pipe_q = &gfx_v9_0_select_me_pipe_q | 1114 | .select_me_pipe_q = &gfx_v9_0_select_me_pipe_q |
1089 | }; | 1115 | }; |
1090 | 1116 | ||
1091 | static void gfx_v9_0_gpu_early_init(struct amdgpu_device *adev) | 1117 | static int gfx_v9_0_gpu_early_init(struct amdgpu_device *adev) |
1092 | { | 1118 | { |
1093 | u32 gb_addr_config; | 1119 | u32 gb_addr_config; |
1120 | int err; | ||
1094 | 1121 | ||
1095 | adev->gfx.funcs = &gfx_v9_0_gfx_funcs; | 1122 | adev->gfx.funcs = &gfx_v9_0_gfx_funcs; |
1096 | 1123 | ||
@@ -1112,6 +1139,20 @@ static void gfx_v9_0_gpu_early_init(struct amdgpu_device *adev) | |||
1112 | gb_addr_config = VEGA12_GB_ADDR_CONFIG_GOLDEN; | 1139 | gb_addr_config = VEGA12_GB_ADDR_CONFIG_GOLDEN; |
1113 | DRM_INFO("fix gfx.config for vega12\n"); | 1140 | DRM_INFO("fix gfx.config for vega12\n"); |
1114 | break; | 1141 | break; |
1142 | case CHIP_VEGA20: | ||
1143 | adev->gfx.config.max_hw_contexts = 8; | ||
1144 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | ||
1145 | adev->gfx.config.sc_prim_fifo_size_backend = 0x100; | ||
1146 | adev->gfx.config.sc_hiz_tile_fifo_size = 0x30; | ||
1147 | adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0; | ||
1148 | gb_addr_config = RREG32_SOC15(GC, 0, mmGB_ADDR_CONFIG); | ||
1149 | gb_addr_config &= ~0xf3e777ff; | ||
1150 | gb_addr_config |= 0x22014042; | ||
1151 | /* check vbios table if gpu info is not available */ | ||
1152 | err = amdgpu_atomfirmware_get_gfx_info(adev); | ||
1153 | if (err) | ||
1154 | return err; | ||
1155 | break; | ||
1115 | case CHIP_RAVEN: | 1156 | case CHIP_RAVEN: |
1116 | adev->gfx.config.max_hw_contexts = 8; | 1157 | adev->gfx.config.max_hw_contexts = 8; |
1117 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; | 1158 | adev->gfx.config.sc_prim_fifo_size_frontend = 0x20; |
@@ -1161,6 +1202,8 @@ static void gfx_v9_0_gpu_early_init(struct amdgpu_device *adev) | |||
1161 | adev->gfx.config.gb_addr_config, | 1202 | adev->gfx.config.gb_addr_config, |
1162 | GB_ADDR_CONFIG, | 1203 | GB_ADDR_CONFIG, |
1163 | PIPE_INTERLEAVE_SIZE)); | 1204 | PIPE_INTERLEAVE_SIZE)); |
1205 | |||
1206 | return 0; | ||
1164 | } | 1207 | } |
1165 | 1208 | ||
1166 | static int gfx_v9_0_ngg_create_buf(struct amdgpu_device *adev, | 1209 | static int gfx_v9_0_ngg_create_buf(struct amdgpu_device *adev, |
@@ -1394,6 +1437,7 @@ static int gfx_v9_0_sw_init(void *handle) | |||
1394 | switch (adev->asic_type) { | 1437 | switch (adev->asic_type) { |
1395 | case CHIP_VEGA10: | 1438 | case CHIP_VEGA10: |
1396 | case CHIP_VEGA12: | 1439 | case CHIP_VEGA12: |
1440 | case CHIP_VEGA20: | ||
1397 | case CHIP_RAVEN: | 1441 | case CHIP_RAVEN: |
1398 | adev->gfx.mec.num_mec = 2; | 1442 | adev->gfx.mec.num_mec = 2; |
1399 | break; | 1443 | break; |
@@ -1521,7 +1565,9 @@ static int gfx_v9_0_sw_init(void *handle) | |||
1521 | 1565 | ||
1522 | adev->gfx.ce_ram_size = 0x8000; | 1566 | adev->gfx.ce_ram_size = 0x8000; |
1523 | 1567 | ||
1524 | gfx_v9_0_gpu_early_init(adev); | 1568 | r = gfx_v9_0_gpu_early_init(adev); |
1569 | if (r) | ||
1570 | return r; | ||
1525 | 1571 | ||
1526 | r = gfx_v9_0_ngg_init(adev); | 1572 | r = gfx_v9_0_ngg_init(adev); |
1527 | if (r) | 1573 | if (r) |
@@ -3688,6 +3734,7 @@ static int gfx_v9_0_set_clockgating_state(void *handle, | |||
3688 | switch (adev->asic_type) { | 3734 | switch (adev->asic_type) { |
3689 | case CHIP_VEGA10: | 3735 | case CHIP_VEGA10: |
3690 | case CHIP_VEGA12: | 3736 | case CHIP_VEGA12: |
3737 | case CHIP_VEGA20: | ||
3691 | case CHIP_RAVEN: | 3738 | case CHIP_RAVEN: |
3692 | gfx_v9_0_update_gfx_clock_gating(adev, | 3739 | gfx_v9_0_update_gfx_clock_gating(adev, |
3693 | state == AMD_CG_STATE_GATE ? true : false); | 3740 | state == AMD_CG_STATE_GATE ? true : false); |
@@ -4680,6 +4727,7 @@ static void gfx_v9_0_set_rlc_funcs(struct amdgpu_device *adev) | |||
4680 | switch (adev->asic_type) { | 4727 | switch (adev->asic_type) { |
4681 | case CHIP_VEGA10: | 4728 | case CHIP_VEGA10: |
4682 | case CHIP_VEGA12: | 4729 | case CHIP_VEGA12: |
4730 | case CHIP_VEGA20: | ||
4683 | case CHIP_RAVEN: | 4731 | case CHIP_RAVEN: |
4684 | adev->gfx.rlc.funcs = &gfx_v9_0_rlc_funcs; | 4732 | adev->gfx.rlc.funcs = &gfx_v9_0_rlc_funcs; |
4685 | break; | 4733 | break; |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index 6cccf0e0acd7..3c0a85d4e4ab 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | |||
@@ -675,6 +675,7 @@ static int gmc_v9_0_late_init(void *handle) | |||
675 | DRM_INFO("ECC is active.\n"); | 675 | DRM_INFO("ECC is active.\n"); |
676 | } else if (r == 0) { | 676 | } else if (r == 0) { |
677 | DRM_INFO("ECC is not present.\n"); | 677 | DRM_INFO("ECC is not present.\n"); |
678 | adev->df_funcs->enable_ecc_force_par_wr_rmw(adev, false); | ||
678 | } else { | 679 | } else { |
679 | DRM_ERROR("gmc_v9_0_ecc_available() failed. r: %d\n", r); | 680 | DRM_ERROR("gmc_v9_0_ecc_available() failed. r: %d\n", r); |
680 | return r; | 681 | return r; |
@@ -693,10 +694,7 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev, | |||
693 | amdgpu_device_vram_location(adev, &adev->gmc, base); | 694 | amdgpu_device_vram_location(adev, &adev->gmc, base); |
694 | amdgpu_device_gart_location(adev, mc); | 695 | amdgpu_device_gart_location(adev, mc); |
695 | /* base offset of vram pages */ | 696 | /* base offset of vram pages */ |
696 | if (adev->flags & AMD_IS_APU) | 697 | adev->vm_manager.vram_base_offset = gfxhub_v1_0_get_mc_fb_offset(adev); |
697 | adev->vm_manager.vram_base_offset = gfxhub_v1_0_get_mc_fb_offset(adev); | ||
698 | else | ||
699 | adev->vm_manager.vram_base_offset = 0; | ||
700 | } | 698 | } |
701 | 699 | ||
702 | /** | 700 | /** |
@@ -755,6 +753,7 @@ static int gmc_v9_0_mc_init(struct amdgpu_device *adev) | |||
755 | switch (adev->asic_type) { | 753 | switch (adev->asic_type) { |
756 | case CHIP_VEGA10: /* all engines support GPUVM */ | 754 | case CHIP_VEGA10: /* all engines support GPUVM */ |
757 | case CHIP_VEGA12: /* all engines support GPUVM */ | 755 | case CHIP_VEGA12: /* all engines support GPUVM */ |
756 | case CHIP_VEGA20: | ||
758 | default: | 757 | default: |
759 | adev->gmc.gart_size = 512ULL << 20; | 758 | adev->gmc.gart_size = 512ULL << 20; |
760 | break; | 759 | break; |
@@ -860,6 +859,7 @@ static int gmc_v9_0_sw_init(void *handle) | |||
860 | break; | 859 | break; |
861 | case CHIP_VEGA10: | 860 | case CHIP_VEGA10: |
862 | case CHIP_VEGA12: | 861 | case CHIP_VEGA12: |
862 | case CHIP_VEGA20: | ||
863 | /* | 863 | /* |
864 | * To fulfill 4-level page support, | 864 | * To fulfill 4-level page support, |
865 | * vm size is 256TB (48bit), maximum size of Vega10, | 865 | * vm size is 256TB (48bit), maximum size of Vega10, |
@@ -977,6 +977,7 @@ static void gmc_v9_0_init_golden_registers(struct amdgpu_device *adev) | |||
977 | 977 | ||
978 | switch (adev->asic_type) { | 978 | switch (adev->asic_type) { |
979 | case CHIP_VEGA10: | 979 | case CHIP_VEGA10: |
980 | case CHIP_VEGA20: | ||
980 | soc15_program_register_sequence(adev, | 981 | soc15_program_register_sequence(adev, |
981 | golden_settings_mmhub_1_0_0, | 982 | golden_settings_mmhub_1_0_0, |
982 | ARRAY_SIZE(golden_settings_mmhub_1_0_0)); | 983 | ARRAY_SIZE(golden_settings_mmhub_1_0_0)); |
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c index 43f925773b57..3d53c4413f13 100644 --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | |||
@@ -734,6 +734,7 @@ int mmhub_v1_0_set_clockgating(struct amdgpu_device *adev, | |||
734 | switch (adev->asic_type) { | 734 | switch (adev->asic_type) { |
735 | case CHIP_VEGA10: | 735 | case CHIP_VEGA10: |
736 | case CHIP_VEGA12: | 736 | case CHIP_VEGA12: |
737 | case CHIP_VEGA20: | ||
737 | case CHIP_RAVEN: | 738 | case CHIP_RAVEN: |
738 | mmhub_v1_0_update_medium_grain_clock_gating(adev, | 739 | mmhub_v1_0_update_medium_grain_clock_gating(adev, |
739 | state == AMD_CG_STATE_GATE ? true : false); | 740 | state == AMD_CG_STATE_GATE ? true : false); |
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c index df34dc79d444..365517c0121e 100644 --- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c | |||
@@ -34,10 +34,19 @@ | |||
34 | #define smnCPM_CONTROL 0x11180460 | 34 | #define smnCPM_CONTROL 0x11180460 |
35 | #define smnPCIE_CNTL2 0x11180070 | 35 | #define smnPCIE_CNTL2 0x11180070 |
36 | 36 | ||
37 | /* vega20 */ | ||
38 | #define mmRCC_DEV0_EPF0_STRAP0_VG20 0x0011 | ||
39 | #define mmRCC_DEV0_EPF0_STRAP0_VG20_BASE_IDX 2 | ||
40 | |||
37 | static u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev) | 41 | static u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev) |
38 | { | 42 | { |
39 | u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); | 43 | u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); |
40 | 44 | ||
45 | if (adev->asic_type == CHIP_VEGA20) | ||
46 | tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0_VG20); | ||
47 | else | ||
48 | tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); | ||
49 | |||
41 | tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK; | 50 | tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK; |
42 | tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT; | 51 | tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT; |
43 | 52 | ||
@@ -75,10 +84,14 @@ static void nbio_v7_0_sdma_doorbell_range(struct amdgpu_device *adev, int instan | |||
75 | SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE); | 84 | SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE); |
76 | 85 | ||
77 | u32 doorbell_range = RREG32(reg); | 86 | u32 doorbell_range = RREG32(reg); |
87 | u32 range = 2; | ||
88 | |||
89 | if (adev->asic_type == CHIP_VEGA20) | ||
90 | range = 8; | ||
78 | 91 | ||
79 | if (use_doorbell) { | 92 | if (use_doorbell) { |
80 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index); | 93 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index); |
81 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 2); | 94 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, range); |
82 | } else | 95 | } else |
83 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0); | 96 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0); |
84 | 97 | ||
@@ -133,6 +146,9 @@ static void nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device *ade | |||
133 | { | 146 | { |
134 | uint32_t def, data; | 147 | uint32_t def, data; |
135 | 148 | ||
149 | if (adev->asic_type == CHIP_VEGA20) | ||
150 | return; | ||
151 | |||
136 | /* NBIF_MGCG_CTRL_LCLK */ | 152 | /* NBIF_MGCG_CTRL_LCLK */ |
137 | def = data = RREG32_PCIE(smnNBIF_MGCG_CTRL_LCLK); | 153 | def = data = RREG32_PCIE(smnNBIF_MGCG_CTRL_LCLK); |
138 | 154 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c index 196e75def1f2..0c768e388ace 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c | |||
@@ -41,6 +41,9 @@ MODULE_FIRMWARE("amdgpu/vega10_sos.bin"); | |||
41 | MODULE_FIRMWARE("amdgpu/vega10_asd.bin"); | 41 | MODULE_FIRMWARE("amdgpu/vega10_asd.bin"); |
42 | MODULE_FIRMWARE("amdgpu/vega12_sos.bin"); | 42 | MODULE_FIRMWARE("amdgpu/vega12_sos.bin"); |
43 | MODULE_FIRMWARE("amdgpu/vega12_asd.bin"); | 43 | MODULE_FIRMWARE("amdgpu/vega12_asd.bin"); |
44 | MODULE_FIRMWARE("amdgpu/vega20_sos.bin"); | ||
45 | MODULE_FIRMWARE("amdgpu/vega20_asd.bin"); | ||
46 | |||
44 | 47 | ||
45 | #define smnMP1_FIRMWARE_FLAGS 0x3010028 | 48 | #define smnMP1_FIRMWARE_FLAGS 0x3010028 |
46 | 49 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index 03a36cbe7557..ca53b3fba422 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | |||
@@ -42,6 +42,8 @@ MODULE_FIRMWARE("amdgpu/vega10_sdma.bin"); | |||
42 | MODULE_FIRMWARE("amdgpu/vega10_sdma1.bin"); | 42 | MODULE_FIRMWARE("amdgpu/vega10_sdma1.bin"); |
43 | MODULE_FIRMWARE("amdgpu/vega12_sdma.bin"); | 43 | MODULE_FIRMWARE("amdgpu/vega12_sdma.bin"); |
44 | MODULE_FIRMWARE("amdgpu/vega12_sdma1.bin"); | 44 | MODULE_FIRMWARE("amdgpu/vega12_sdma1.bin"); |
45 | MODULE_FIRMWARE("amdgpu/vega20_sdma.bin"); | ||
46 | MODULE_FIRMWARE("amdgpu/vega20_sdma1.bin"); | ||
45 | MODULE_FIRMWARE("amdgpu/raven_sdma.bin"); | 47 | MODULE_FIRMWARE("amdgpu/raven_sdma.bin"); |
46 | 48 | ||
47 | #define SDMA0_POWER_CNTL__ON_OFF_CONDITION_HOLD_TIME_MASK 0x000000F8L | 49 | #define SDMA0_POWER_CNTL__ON_OFF_CONDITION_HOLD_TIME_MASK 0x000000F8L |
@@ -107,6 +109,28 @@ static const struct soc15_reg_golden golden_settings_sdma_4_1[] = | |||
107 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0) | 109 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0) |
108 | }; | 110 | }; |
109 | 111 | ||
112 | static const struct soc15_reg_golden golden_settings_sdma_4_2[] = | ||
113 | { | ||
114 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_CHICKEN_BITS, 0xfe931f07, 0x02831d07), | ||
115 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_CLK_CTRL, 0xffffffff, 0x3f000100), | ||
116 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0000773f, 0x00004002), | ||
117 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0000773f, 0x00004002), | ||
118 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GFX_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | ||
119 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_PAGE_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | ||
120 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL, 0xfffffff0, 0x00403000), | ||
121 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | ||
122 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0), | ||
123 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831d07), | ||
124 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CLK_CTRL, 0xffffffff, 0x3f000100), | ||
125 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG, 0x0000773f, 0x00004002), | ||
126 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x0000773f, 0x00004002), | ||
127 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | ||
128 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_PAGE_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | ||
129 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC0_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | ||
130 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC1_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | ||
131 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_UTCL1_PAGE, 0x000003ff, 0x000003c0) | ||
132 | }; | ||
133 | |||
110 | static const struct soc15_reg_golden golden_settings_sdma_rv1[] = | 134 | static const struct soc15_reg_golden golden_settings_sdma_rv1[] = |
111 | { | 135 | { |
112 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00000002), | 136 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00000002), |
@@ -139,6 +163,11 @@ static void sdma_v4_0_init_golden_registers(struct amdgpu_device *adev) | |||
139 | golden_settings_sdma_vg12, | 163 | golden_settings_sdma_vg12, |
140 | ARRAY_SIZE(golden_settings_sdma_vg12)); | 164 | ARRAY_SIZE(golden_settings_sdma_vg12)); |
141 | break; | 165 | break; |
166 | case CHIP_VEGA20: | ||
167 | soc15_program_register_sequence(adev, | ||
168 | golden_settings_sdma_4_2, | ||
169 | ARRAY_SIZE(golden_settings_sdma_4_2)); | ||
170 | break; | ||
142 | case CHIP_RAVEN: | 171 | case CHIP_RAVEN: |
143 | soc15_program_register_sequence(adev, | 172 | soc15_program_register_sequence(adev, |
144 | golden_settings_sdma_4_1, | 173 | golden_settings_sdma_4_1, |
@@ -182,6 +211,9 @@ static int sdma_v4_0_init_microcode(struct amdgpu_device *adev) | |||
182 | case CHIP_VEGA12: | 211 | case CHIP_VEGA12: |
183 | chip_name = "vega12"; | 212 | chip_name = "vega12"; |
184 | break; | 213 | break; |
214 | case CHIP_VEGA20: | ||
215 | chip_name = "vega20"; | ||
216 | break; | ||
185 | case CHIP_RAVEN: | 217 | case CHIP_RAVEN: |
186 | chip_name = "raven"; | 218 | chip_name = "raven"; |
187 | break; | 219 | break; |
@@ -1516,6 +1548,7 @@ static int sdma_v4_0_set_clockgating_state(void *handle, | |||
1516 | switch (adev->asic_type) { | 1548 | switch (adev->asic_type) { |
1517 | case CHIP_VEGA10: | 1549 | case CHIP_VEGA10: |
1518 | case CHIP_VEGA12: | 1550 | case CHIP_VEGA12: |
1551 | case CHIP_VEGA20: | ||
1519 | case CHIP_RAVEN: | 1552 | case CHIP_RAVEN: |
1520 | sdma_v4_0_update_medium_grain_clock_gating(adev, | 1553 | sdma_v4_0_update_medium_grain_clock_gating(adev, |
1521 | state == AMD_CG_STATE_GATE ? true : false); | 1554 | state == AMD_CG_STATE_GATE ? true : false); |
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index 90065766fffb..68b4a22a8892 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c | |||
@@ -41,8 +41,6 @@ | |||
41 | #include "sdma1/sdma1_4_0_offset.h" | 41 | #include "sdma1/sdma1_4_0_offset.h" |
42 | #include "hdp/hdp_4_0_offset.h" | 42 | #include "hdp/hdp_4_0_offset.h" |
43 | #include "hdp/hdp_4_0_sh_mask.h" | 43 | #include "hdp/hdp_4_0_sh_mask.h" |
44 | #include "mp/mp_9_0_offset.h" | ||
45 | #include "mp/mp_9_0_sh_mask.h" | ||
46 | #include "smuio/smuio_9_0_offset.h" | 44 | #include "smuio/smuio_9_0_offset.h" |
47 | #include "smuio/smuio_9_0_sh_mask.h" | 45 | #include "smuio/smuio_9_0_sh_mask.h" |
48 | 46 | ||
@@ -53,6 +51,7 @@ | |||
53 | #include "gfxhub_v1_0.h" | 51 | #include "gfxhub_v1_0.h" |
54 | #include "mmhub_v1_0.h" | 52 | #include "mmhub_v1_0.h" |
55 | #include "df_v1_7.h" | 53 | #include "df_v1_7.h" |
54 | #include "df_v3_6.h" | ||
56 | #include "vega10_ih.h" | 55 | #include "vega10_ih.h" |
57 | #include "sdma_v4_0.h" | 56 | #include "sdma_v4_0.h" |
58 | #include "uvd_v7_0.h" | 57 | #include "uvd_v7_0.h" |
@@ -489,16 +488,24 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) | |||
489 | case CHIP_RAVEN: | 488 | case CHIP_RAVEN: |
490 | vega10_reg_base_init(adev); | 489 | vega10_reg_base_init(adev); |
491 | break; | 490 | break; |
491 | case CHIP_VEGA20: | ||
492 | vega20_reg_base_init(adev); | ||
493 | break; | ||
492 | default: | 494 | default: |
493 | return -EINVAL; | 495 | return -EINVAL; |
494 | } | 496 | } |
495 | 497 | ||
496 | if (adev->flags & AMD_IS_APU) | 498 | if (adev->flags & AMD_IS_APU) |
497 | adev->nbio_funcs = &nbio_v7_0_funcs; | 499 | adev->nbio_funcs = &nbio_v7_0_funcs; |
500 | else if (adev->asic_type == CHIP_VEGA20) | ||
501 | adev->nbio_funcs = &nbio_v7_0_funcs; | ||
498 | else | 502 | else |
499 | adev->nbio_funcs = &nbio_v6_1_funcs; | 503 | adev->nbio_funcs = &nbio_v6_1_funcs; |
500 | 504 | ||
501 | adev->df_funcs = &df_v1_7_funcs; | 505 | if (adev->asic_type == CHIP_VEGA20) |
506 | adev->df_funcs = &df_v3_6_funcs; | ||
507 | else | ||
508 | adev->df_funcs = &df_v1_7_funcs; | ||
502 | adev->nbio_funcs->detect_hw_virt(adev); | 509 | adev->nbio_funcs->detect_hw_virt(adev); |
503 | 510 | ||
504 | if (amdgpu_sriov_vf(adev)) | 511 | if (amdgpu_sriov_vf(adev)) |
@@ -507,12 +514,15 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) | |||
507 | switch (adev->asic_type) { | 514 | switch (adev->asic_type) { |
508 | case CHIP_VEGA10: | 515 | case CHIP_VEGA10: |
509 | case CHIP_VEGA12: | 516 | case CHIP_VEGA12: |
517 | case CHIP_VEGA20: | ||
510 | amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); | 518 | amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); |
511 | amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); | 519 | amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); |
512 | amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); | 520 | amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); |
513 | amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block); | 521 | if (adev->asic_type != CHIP_VEGA20) { |
514 | if (!amdgpu_sriov_vf(adev)) | 522 | amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block); |
515 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 523 | if (!amdgpu_sriov_vf(adev)) |
524 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | ||
525 | } | ||
516 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 526 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
517 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 527 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
518 | #if defined(CONFIG_DRM_AMD_DC) | 528 | #if defined(CONFIG_DRM_AMD_DC) |
@@ -660,6 +670,27 @@ static int soc15_common_early_init(void *handle) | |||
660 | adev->pg_flags = 0; | 670 | adev->pg_flags = 0; |
661 | adev->external_rev_id = adev->rev_id + 0x14; | 671 | adev->external_rev_id = adev->rev_id + 0x14; |
662 | break; | 672 | break; |
673 | case CHIP_VEGA20: | ||
674 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | | ||
675 | AMD_CG_SUPPORT_GFX_MGLS | | ||
676 | AMD_CG_SUPPORT_GFX_CGCG | | ||
677 | AMD_CG_SUPPORT_GFX_CGLS | | ||
678 | AMD_CG_SUPPORT_GFX_3D_CGCG | | ||
679 | AMD_CG_SUPPORT_GFX_3D_CGLS | | ||
680 | AMD_CG_SUPPORT_GFX_CP_LS | | ||
681 | AMD_CG_SUPPORT_MC_LS | | ||
682 | AMD_CG_SUPPORT_MC_MGCG | | ||
683 | AMD_CG_SUPPORT_SDMA_MGCG | | ||
684 | AMD_CG_SUPPORT_SDMA_LS | | ||
685 | AMD_CG_SUPPORT_BIF_MGCG | | ||
686 | AMD_CG_SUPPORT_BIF_LS | | ||
687 | AMD_CG_SUPPORT_HDP_MGCG | | ||
688 | AMD_CG_SUPPORT_ROM_MGCG | | ||
689 | AMD_CG_SUPPORT_VCE_MGCG | | ||
690 | AMD_CG_SUPPORT_UVD_MGCG; | ||
691 | adev->pg_flags = 0; | ||
692 | adev->external_rev_id = adev->rev_id + 0x28; | ||
693 | break; | ||
663 | case CHIP_RAVEN: | 694 | case CHIP_RAVEN: |
664 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | | 695 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | |
665 | AMD_CG_SUPPORT_GFX_MGLS | | 696 | AMD_CG_SUPPORT_GFX_MGLS | |
@@ -679,8 +710,10 @@ static int soc15_common_early_init(void *handle) | |||
679 | AMD_CG_SUPPORT_MC_MGCG | | 710 | AMD_CG_SUPPORT_MC_MGCG | |
680 | AMD_CG_SUPPORT_MC_LS | | 711 | AMD_CG_SUPPORT_MC_LS | |
681 | AMD_CG_SUPPORT_SDMA_MGCG | | 712 | AMD_CG_SUPPORT_SDMA_MGCG | |
682 | AMD_CG_SUPPORT_SDMA_LS; | 713 | AMD_CG_SUPPORT_SDMA_LS | |
683 | adev->pg_flags = AMD_PG_SUPPORT_SDMA; | 714 | AMD_CG_SUPPORT_VCN_MGCG; |
715 | |||
716 | adev->pg_flags = AMD_PG_SUPPORT_SDMA | AMD_PG_SUPPORT_VCN; | ||
684 | 717 | ||
685 | if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) | 718 | if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) |
686 | adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG | | 719 | adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG | |
@@ -872,6 +905,7 @@ static int soc15_common_set_clockgating_state(void *handle, | |||
872 | switch (adev->asic_type) { | 905 | switch (adev->asic_type) { |
873 | case CHIP_VEGA10: | 906 | case CHIP_VEGA10: |
874 | case CHIP_VEGA12: | 907 | case CHIP_VEGA12: |
908 | case CHIP_VEGA20: | ||
875 | adev->nbio_funcs->update_medium_grain_clock_gating(adev, | 909 | adev->nbio_funcs->update_medium_grain_clock_gating(adev, |
876 | state == AMD_CG_STATE_GATE ? true : false); | 910 | state == AMD_CG_STATE_GATE ? true : false); |
877 | adev->nbio_funcs->update_medium_grain_light_sleep(adev, | 911 | adev->nbio_funcs->update_medium_grain_light_sleep(adev, |
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.h b/drivers/gpu/drm/amd/amdgpu/soc15.h index f70da8a29f86..1f714b7af520 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.h +++ b/drivers/gpu/drm/amd/amdgpu/soc15.h | |||
@@ -55,5 +55,6 @@ void soc15_program_register_sequence(struct amdgpu_device *adev, | |||
55 | const u32 array_size); | 55 | const u32 array_size); |
56 | 56 | ||
57 | int vega10_reg_base_init(struct amdgpu_device *adev); | 57 | int vega10_reg_base_init(struct amdgpu_device *adev); |
58 | int vega20_reg_base_init(struct amdgpu_device *adev); | ||
58 | 59 | ||
59 | #endif | 60 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15_common.h b/drivers/gpu/drm/amd/amdgpu/soc15_common.h index def865067edd..0942f492d2e1 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15_common.h +++ b/drivers/gpu/drm/amd/amdgpu/soc15_common.h | |||
@@ -47,6 +47,21 @@ | |||
47 | #define WREG32_SOC15_OFFSET(ip, inst, reg, offset, value) \ | 47 | #define WREG32_SOC15_OFFSET(ip, inst, reg, offset, value) \ |
48 | WREG32((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) + offset, value) | 48 | WREG32((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) + offset, value) |
49 | 49 | ||
50 | #define SOC15_WAIT_ON_RREG(ip, inst, reg, expected_value, mask, ret) \ | ||
51 | do { \ | ||
52 | uint32_t tmp_ = RREG32(adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg); \ | ||
53 | uint32_t loop = adev->usec_timeout; \ | ||
54 | while ((tmp_ & (mask)) != (expected_value)) { \ | ||
55 | udelay(2); \ | ||
56 | tmp_ = RREG32(adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg); \ | ||
57 | loop--; \ | ||
58 | if (!loop) { \ | ||
59 | ret = -ETIMEDOUT; \ | ||
60 | break; \ | ||
61 | } \ | ||
62 | } \ | ||
63 | } while (0) | ||
64 | |||
50 | #endif | 65 | #endif |
51 | 66 | ||
52 | 67 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c index 87cbb142dd0b..6fed3d7797a8 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | |||
@@ -93,6 +93,7 @@ static void uvd_v4_2_ring_set_wptr(struct amdgpu_ring *ring) | |||
93 | static int uvd_v4_2_early_init(void *handle) | 93 | static int uvd_v4_2_early_init(void *handle) |
94 | { | 94 | { |
95 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 95 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
96 | adev->uvd.num_uvd_inst = 1; | ||
96 | 97 | ||
97 | uvd_v4_2_set_ring_funcs(adev); | 98 | uvd_v4_2_set_ring_funcs(adev); |
98 | uvd_v4_2_set_irq_funcs(adev); | 99 | uvd_v4_2_set_irq_funcs(adev); |
@@ -107,7 +108,7 @@ static int uvd_v4_2_sw_init(void *handle) | |||
107 | int r; | 108 | int r; |
108 | 109 | ||
109 | /* UVD TRAP */ | 110 | /* UVD TRAP */ |
110 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 124, &adev->uvd.irq); | 111 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 124, &adev->uvd.inst->irq); |
111 | if (r) | 112 | if (r) |
112 | return r; | 113 | return r; |
113 | 114 | ||
@@ -119,9 +120,9 @@ static int uvd_v4_2_sw_init(void *handle) | |||
119 | if (r) | 120 | if (r) |
120 | return r; | 121 | return r; |
121 | 122 | ||
122 | ring = &adev->uvd.ring; | 123 | ring = &adev->uvd.inst->ring; |
123 | sprintf(ring->name, "uvd"); | 124 | sprintf(ring->name, "uvd"); |
124 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.irq, 0); | 125 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0); |
125 | 126 | ||
126 | return r; | 127 | return r; |
127 | } | 128 | } |
@@ -150,7 +151,7 @@ static void uvd_v4_2_enable_mgcg(struct amdgpu_device *adev, | |||
150 | static int uvd_v4_2_hw_init(void *handle) | 151 | static int uvd_v4_2_hw_init(void *handle) |
151 | { | 152 | { |
152 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 153 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
153 | struct amdgpu_ring *ring = &adev->uvd.ring; | 154 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
154 | uint32_t tmp; | 155 | uint32_t tmp; |
155 | int r; | 156 | int r; |
156 | 157 | ||
@@ -208,7 +209,7 @@ done: | |||
208 | static int uvd_v4_2_hw_fini(void *handle) | 209 | static int uvd_v4_2_hw_fini(void *handle) |
209 | { | 210 | { |
210 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 211 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
211 | struct amdgpu_ring *ring = &adev->uvd.ring; | 212 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
212 | 213 | ||
213 | if (RREG32(mmUVD_STATUS) != 0) | 214 | if (RREG32(mmUVD_STATUS) != 0) |
214 | uvd_v4_2_stop(adev); | 215 | uvd_v4_2_stop(adev); |
@@ -251,7 +252,7 @@ static int uvd_v4_2_resume(void *handle) | |||
251 | */ | 252 | */ |
252 | static int uvd_v4_2_start(struct amdgpu_device *adev) | 253 | static int uvd_v4_2_start(struct amdgpu_device *adev) |
253 | { | 254 | { |
254 | struct amdgpu_ring *ring = &adev->uvd.ring; | 255 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
255 | uint32_t rb_bufsz; | 256 | uint32_t rb_bufsz; |
256 | int i, j, r; | 257 | int i, j, r; |
257 | u32 tmp; | 258 | u32 tmp; |
@@ -523,6 +524,18 @@ static void uvd_v4_2_ring_emit_ib(struct amdgpu_ring *ring, | |||
523 | amdgpu_ring_write(ring, ib->length_dw); | 524 | amdgpu_ring_write(ring, ib->length_dw); |
524 | } | 525 | } |
525 | 526 | ||
527 | static void uvd_v4_2_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) | ||
528 | { | ||
529 | int i; | ||
530 | |||
531 | WARN_ON(ring->wptr % 2 || count % 2); | ||
532 | |||
533 | for (i = 0; i < count / 2; i++) { | ||
534 | amdgpu_ring_write(ring, PACKET0(mmUVD_NO_OP, 0)); | ||
535 | amdgpu_ring_write(ring, 0); | ||
536 | } | ||
537 | } | ||
538 | |||
526 | /** | 539 | /** |
527 | * uvd_v4_2_mc_resume - memory controller programming | 540 | * uvd_v4_2_mc_resume - memory controller programming |
528 | * | 541 | * |
@@ -536,7 +549,7 @@ static void uvd_v4_2_mc_resume(struct amdgpu_device *adev) | |||
536 | uint32_t size; | 549 | uint32_t size; |
537 | 550 | ||
538 | /* programm the VCPU memory controller bits 0-27 */ | 551 | /* programm the VCPU memory controller bits 0-27 */ |
539 | addr = (adev->uvd.gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3; | 552 | addr = (adev->uvd.inst->gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3; |
540 | size = AMDGPU_UVD_FIRMWARE_SIZE(adev) >> 3; | 553 | size = AMDGPU_UVD_FIRMWARE_SIZE(adev) >> 3; |
541 | WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr); | 554 | WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr); |
542 | WREG32(mmUVD_VCPU_CACHE_SIZE0, size); | 555 | WREG32(mmUVD_VCPU_CACHE_SIZE0, size); |
@@ -553,11 +566,11 @@ static void uvd_v4_2_mc_resume(struct amdgpu_device *adev) | |||
553 | WREG32(mmUVD_VCPU_CACHE_SIZE2, size); | 566 | WREG32(mmUVD_VCPU_CACHE_SIZE2, size); |
554 | 567 | ||
555 | /* bits 28-31 */ | 568 | /* bits 28-31 */ |
556 | addr = (adev->uvd.gpu_addr >> 28) & 0xF; | 569 | addr = (adev->uvd.inst->gpu_addr >> 28) & 0xF; |
557 | WREG32(mmUVD_LMI_ADDR_EXT, (addr << 12) | (addr << 0)); | 570 | WREG32(mmUVD_LMI_ADDR_EXT, (addr << 12) | (addr << 0)); |
558 | 571 | ||
559 | /* bits 32-39 */ | 572 | /* bits 32-39 */ |
560 | addr = (adev->uvd.gpu_addr >> 32) & 0xFF; | 573 | addr = (adev->uvd.inst->gpu_addr >> 32) & 0xFF; |
561 | WREG32(mmUVD_LMI_EXT40_ADDR, addr | (0x9 << 16) | (0x1 << 31)); | 574 | WREG32(mmUVD_LMI_EXT40_ADDR, addr | (0x9 << 16) | (0x1 << 31)); |
562 | 575 | ||
563 | WREG32(mmUVD_UDEC_ADDR_CONFIG, adev->gfx.config.gb_addr_config); | 576 | WREG32(mmUVD_UDEC_ADDR_CONFIG, adev->gfx.config.gb_addr_config); |
@@ -664,7 +677,7 @@ static int uvd_v4_2_process_interrupt(struct amdgpu_device *adev, | |||
664 | struct amdgpu_iv_entry *entry) | 677 | struct amdgpu_iv_entry *entry) |
665 | { | 678 | { |
666 | DRM_DEBUG("IH: UVD TRAP\n"); | 679 | DRM_DEBUG("IH: UVD TRAP\n"); |
667 | amdgpu_fence_process(&adev->uvd.ring); | 680 | amdgpu_fence_process(&adev->uvd.inst->ring); |
668 | return 0; | 681 | return 0; |
669 | } | 682 | } |
670 | 683 | ||
@@ -732,7 +745,6 @@ static const struct amd_ip_funcs uvd_v4_2_ip_funcs = { | |||
732 | static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = { | 745 | static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = { |
733 | .type = AMDGPU_RING_TYPE_UVD, | 746 | .type = AMDGPU_RING_TYPE_UVD, |
734 | .align_mask = 0xf, | 747 | .align_mask = 0xf, |
735 | .nop = PACKET0(mmUVD_NO_OP, 0), | ||
736 | .support_64bit_ptrs = false, | 748 | .support_64bit_ptrs = false, |
737 | .get_rptr = uvd_v4_2_ring_get_rptr, | 749 | .get_rptr = uvd_v4_2_ring_get_rptr, |
738 | .get_wptr = uvd_v4_2_ring_get_wptr, | 750 | .get_wptr = uvd_v4_2_ring_get_wptr, |
@@ -745,7 +757,7 @@ static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = { | |||
745 | .emit_fence = uvd_v4_2_ring_emit_fence, | 757 | .emit_fence = uvd_v4_2_ring_emit_fence, |
746 | .test_ring = uvd_v4_2_ring_test_ring, | 758 | .test_ring = uvd_v4_2_ring_test_ring, |
747 | .test_ib = amdgpu_uvd_ring_test_ib, | 759 | .test_ib = amdgpu_uvd_ring_test_ib, |
748 | .insert_nop = amdgpu_ring_insert_nop, | 760 | .insert_nop = uvd_v4_2_ring_insert_nop, |
749 | .pad_ib = amdgpu_ring_generic_pad_ib, | 761 | .pad_ib = amdgpu_ring_generic_pad_ib, |
750 | .begin_use = amdgpu_uvd_ring_begin_use, | 762 | .begin_use = amdgpu_uvd_ring_begin_use, |
751 | .end_use = amdgpu_uvd_ring_end_use, | 763 | .end_use = amdgpu_uvd_ring_end_use, |
@@ -753,7 +765,7 @@ static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = { | |||
753 | 765 | ||
754 | static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev) | 766 | static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev) |
755 | { | 767 | { |
756 | adev->uvd.ring.funcs = &uvd_v4_2_ring_funcs; | 768 | adev->uvd.inst->ring.funcs = &uvd_v4_2_ring_funcs; |
757 | } | 769 | } |
758 | 770 | ||
759 | static const struct amdgpu_irq_src_funcs uvd_v4_2_irq_funcs = { | 771 | static const struct amdgpu_irq_src_funcs uvd_v4_2_irq_funcs = { |
@@ -763,8 +775,8 @@ static const struct amdgpu_irq_src_funcs uvd_v4_2_irq_funcs = { | |||
763 | 775 | ||
764 | static void uvd_v4_2_set_irq_funcs(struct amdgpu_device *adev) | 776 | static void uvd_v4_2_set_irq_funcs(struct amdgpu_device *adev) |
765 | { | 777 | { |
766 | adev->uvd.irq.num_types = 1; | 778 | adev->uvd.inst->irq.num_types = 1; |
767 | adev->uvd.irq.funcs = &uvd_v4_2_irq_funcs; | 779 | adev->uvd.inst->irq.funcs = &uvd_v4_2_irq_funcs; |
768 | } | 780 | } |
769 | 781 | ||
770 | const struct amdgpu_ip_block_version uvd_v4_2_ip_block = | 782 | const struct amdgpu_ip_block_version uvd_v4_2_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c index 6445d55e7d5a..341ee6d55ce8 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | |||
@@ -89,6 +89,7 @@ static void uvd_v5_0_ring_set_wptr(struct amdgpu_ring *ring) | |||
89 | static int uvd_v5_0_early_init(void *handle) | 89 | static int uvd_v5_0_early_init(void *handle) |
90 | { | 90 | { |
91 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 91 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
92 | adev->uvd.num_uvd_inst = 1; | ||
92 | 93 | ||
93 | uvd_v5_0_set_ring_funcs(adev); | 94 | uvd_v5_0_set_ring_funcs(adev); |
94 | uvd_v5_0_set_irq_funcs(adev); | 95 | uvd_v5_0_set_irq_funcs(adev); |
@@ -103,7 +104,7 @@ static int uvd_v5_0_sw_init(void *handle) | |||
103 | int r; | 104 | int r; |
104 | 105 | ||
105 | /* UVD TRAP */ | 106 | /* UVD TRAP */ |
106 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 124, &adev->uvd.irq); | 107 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 124, &adev->uvd.inst->irq); |
107 | if (r) | 108 | if (r) |
108 | return r; | 109 | return r; |
109 | 110 | ||
@@ -115,9 +116,9 @@ static int uvd_v5_0_sw_init(void *handle) | |||
115 | if (r) | 116 | if (r) |
116 | return r; | 117 | return r; |
117 | 118 | ||
118 | ring = &adev->uvd.ring; | 119 | ring = &adev->uvd.inst->ring; |
119 | sprintf(ring->name, "uvd"); | 120 | sprintf(ring->name, "uvd"); |
120 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.irq, 0); | 121 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0); |
121 | 122 | ||
122 | return r; | 123 | return r; |
123 | } | 124 | } |
@@ -144,7 +145,7 @@ static int uvd_v5_0_sw_fini(void *handle) | |||
144 | static int uvd_v5_0_hw_init(void *handle) | 145 | static int uvd_v5_0_hw_init(void *handle) |
145 | { | 146 | { |
146 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 147 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
147 | struct amdgpu_ring *ring = &adev->uvd.ring; | 148 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
148 | uint32_t tmp; | 149 | uint32_t tmp; |
149 | int r; | 150 | int r; |
150 | 151 | ||
@@ -204,7 +205,7 @@ done: | |||
204 | static int uvd_v5_0_hw_fini(void *handle) | 205 | static int uvd_v5_0_hw_fini(void *handle) |
205 | { | 206 | { |
206 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 207 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
207 | struct amdgpu_ring *ring = &adev->uvd.ring; | 208 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
208 | 209 | ||
209 | if (RREG32(mmUVD_STATUS) != 0) | 210 | if (RREG32(mmUVD_STATUS) != 0) |
210 | uvd_v5_0_stop(adev); | 211 | uvd_v5_0_stop(adev); |
@@ -253,9 +254,9 @@ static void uvd_v5_0_mc_resume(struct amdgpu_device *adev) | |||
253 | 254 | ||
254 | /* programm memory controller bits 0-27 */ | 255 | /* programm memory controller bits 0-27 */ |
255 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, | 256 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, |
256 | lower_32_bits(adev->uvd.gpu_addr)); | 257 | lower_32_bits(adev->uvd.inst->gpu_addr)); |
257 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, | 258 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, |
258 | upper_32_bits(adev->uvd.gpu_addr)); | 259 | upper_32_bits(adev->uvd.inst->gpu_addr)); |
259 | 260 | ||
260 | offset = AMDGPU_UVD_FIRMWARE_OFFSET; | 261 | offset = AMDGPU_UVD_FIRMWARE_OFFSET; |
261 | size = AMDGPU_UVD_FIRMWARE_SIZE(adev); | 262 | size = AMDGPU_UVD_FIRMWARE_SIZE(adev); |
@@ -287,7 +288,7 @@ static void uvd_v5_0_mc_resume(struct amdgpu_device *adev) | |||
287 | */ | 288 | */ |
288 | static int uvd_v5_0_start(struct amdgpu_device *adev) | 289 | static int uvd_v5_0_start(struct amdgpu_device *adev) |
289 | { | 290 | { |
290 | struct amdgpu_ring *ring = &adev->uvd.ring; | 291 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
291 | uint32_t rb_bufsz, tmp; | 292 | uint32_t rb_bufsz, tmp; |
292 | uint32_t lmi_swap_cntl; | 293 | uint32_t lmi_swap_cntl; |
293 | uint32_t mp_swap_cntl; | 294 | uint32_t mp_swap_cntl; |
@@ -540,6 +541,18 @@ static void uvd_v5_0_ring_emit_ib(struct amdgpu_ring *ring, | |||
540 | amdgpu_ring_write(ring, ib->length_dw); | 541 | amdgpu_ring_write(ring, ib->length_dw); |
541 | } | 542 | } |
542 | 543 | ||
544 | static void uvd_v5_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) | ||
545 | { | ||
546 | int i; | ||
547 | |||
548 | WARN_ON(ring->wptr % 2 || count % 2); | ||
549 | |||
550 | for (i = 0; i < count / 2; i++) { | ||
551 | amdgpu_ring_write(ring, PACKET0(mmUVD_NO_OP, 0)); | ||
552 | amdgpu_ring_write(ring, 0); | ||
553 | } | ||
554 | } | ||
555 | |||
543 | static bool uvd_v5_0_is_idle(void *handle) | 556 | static bool uvd_v5_0_is_idle(void *handle) |
544 | { | 557 | { |
545 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 558 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
@@ -586,7 +599,7 @@ static int uvd_v5_0_process_interrupt(struct amdgpu_device *adev, | |||
586 | struct amdgpu_iv_entry *entry) | 599 | struct amdgpu_iv_entry *entry) |
587 | { | 600 | { |
588 | DRM_DEBUG("IH: UVD TRAP\n"); | 601 | DRM_DEBUG("IH: UVD TRAP\n"); |
589 | amdgpu_fence_process(&adev->uvd.ring); | 602 | amdgpu_fence_process(&adev->uvd.inst->ring); |
590 | return 0; | 603 | return 0; |
591 | } | 604 | } |
592 | 605 | ||
@@ -840,7 +853,6 @@ static const struct amd_ip_funcs uvd_v5_0_ip_funcs = { | |||
840 | static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { | 853 | static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { |
841 | .type = AMDGPU_RING_TYPE_UVD, | 854 | .type = AMDGPU_RING_TYPE_UVD, |
842 | .align_mask = 0xf, | 855 | .align_mask = 0xf, |
843 | .nop = PACKET0(mmUVD_NO_OP, 0), | ||
844 | .support_64bit_ptrs = false, | 856 | .support_64bit_ptrs = false, |
845 | .get_rptr = uvd_v5_0_ring_get_rptr, | 857 | .get_rptr = uvd_v5_0_ring_get_rptr, |
846 | .get_wptr = uvd_v5_0_ring_get_wptr, | 858 | .get_wptr = uvd_v5_0_ring_get_wptr, |
@@ -853,7 +865,7 @@ static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { | |||
853 | .emit_fence = uvd_v5_0_ring_emit_fence, | 865 | .emit_fence = uvd_v5_0_ring_emit_fence, |
854 | .test_ring = uvd_v5_0_ring_test_ring, | 866 | .test_ring = uvd_v5_0_ring_test_ring, |
855 | .test_ib = amdgpu_uvd_ring_test_ib, | 867 | .test_ib = amdgpu_uvd_ring_test_ib, |
856 | .insert_nop = amdgpu_ring_insert_nop, | 868 | .insert_nop = uvd_v5_0_ring_insert_nop, |
857 | .pad_ib = amdgpu_ring_generic_pad_ib, | 869 | .pad_ib = amdgpu_ring_generic_pad_ib, |
858 | .begin_use = amdgpu_uvd_ring_begin_use, | 870 | .begin_use = amdgpu_uvd_ring_begin_use, |
859 | .end_use = amdgpu_uvd_ring_end_use, | 871 | .end_use = amdgpu_uvd_ring_end_use, |
@@ -861,7 +873,7 @@ static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { | |||
861 | 873 | ||
862 | static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev) | 874 | static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev) |
863 | { | 875 | { |
864 | adev->uvd.ring.funcs = &uvd_v5_0_ring_funcs; | 876 | adev->uvd.inst->ring.funcs = &uvd_v5_0_ring_funcs; |
865 | } | 877 | } |
866 | 878 | ||
867 | static const struct amdgpu_irq_src_funcs uvd_v5_0_irq_funcs = { | 879 | static const struct amdgpu_irq_src_funcs uvd_v5_0_irq_funcs = { |
@@ -871,8 +883,8 @@ static const struct amdgpu_irq_src_funcs uvd_v5_0_irq_funcs = { | |||
871 | 883 | ||
872 | static void uvd_v5_0_set_irq_funcs(struct amdgpu_device *adev) | 884 | static void uvd_v5_0_set_irq_funcs(struct amdgpu_device *adev) |
873 | { | 885 | { |
874 | adev->uvd.irq.num_types = 1; | 886 | adev->uvd.inst->irq.num_types = 1; |
875 | adev->uvd.irq.funcs = &uvd_v5_0_irq_funcs; | 887 | adev->uvd.inst->irq.funcs = &uvd_v5_0_irq_funcs; |
876 | } | 888 | } |
877 | 889 | ||
878 | const struct amdgpu_ip_block_version uvd_v5_0_ip_block = | 890 | const struct amdgpu_ip_block_version uvd_v5_0_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index ca6ab56357b5..bfddf97dd13e 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
@@ -91,7 +91,7 @@ static uint64_t uvd_v6_0_enc_ring_get_rptr(struct amdgpu_ring *ring) | |||
91 | { | 91 | { |
92 | struct amdgpu_device *adev = ring->adev; | 92 | struct amdgpu_device *adev = ring->adev; |
93 | 93 | ||
94 | if (ring == &adev->uvd.ring_enc[0]) | 94 | if (ring == &adev->uvd.inst->ring_enc[0]) |
95 | return RREG32(mmUVD_RB_RPTR); | 95 | return RREG32(mmUVD_RB_RPTR); |
96 | else | 96 | else |
97 | return RREG32(mmUVD_RB_RPTR2); | 97 | return RREG32(mmUVD_RB_RPTR2); |
@@ -121,7 +121,7 @@ static uint64_t uvd_v6_0_enc_ring_get_wptr(struct amdgpu_ring *ring) | |||
121 | { | 121 | { |
122 | struct amdgpu_device *adev = ring->adev; | 122 | struct amdgpu_device *adev = ring->adev; |
123 | 123 | ||
124 | if (ring == &adev->uvd.ring_enc[0]) | 124 | if (ring == &adev->uvd.inst->ring_enc[0]) |
125 | return RREG32(mmUVD_RB_WPTR); | 125 | return RREG32(mmUVD_RB_WPTR); |
126 | else | 126 | else |
127 | return RREG32(mmUVD_RB_WPTR2); | 127 | return RREG32(mmUVD_RB_WPTR2); |
@@ -152,7 +152,7 @@ static void uvd_v6_0_enc_ring_set_wptr(struct amdgpu_ring *ring) | |||
152 | { | 152 | { |
153 | struct amdgpu_device *adev = ring->adev; | 153 | struct amdgpu_device *adev = ring->adev; |
154 | 154 | ||
155 | if (ring == &adev->uvd.ring_enc[0]) | 155 | if (ring == &adev->uvd.inst->ring_enc[0]) |
156 | WREG32(mmUVD_RB_WPTR, | 156 | WREG32(mmUVD_RB_WPTR, |
157 | lower_32_bits(ring->wptr)); | 157 | lower_32_bits(ring->wptr)); |
158 | else | 158 | else |
@@ -375,6 +375,7 @@ error: | |||
375 | static int uvd_v6_0_early_init(void *handle) | 375 | static int uvd_v6_0_early_init(void *handle) |
376 | { | 376 | { |
377 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 377 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
378 | adev->uvd.num_uvd_inst = 1; | ||
378 | 379 | ||
379 | if (!(adev->flags & AMD_IS_APU) && | 380 | if (!(adev->flags & AMD_IS_APU) && |
380 | (RREG32_SMC(ixCC_HARVEST_FUSES) & CC_HARVEST_FUSES__UVD_DISABLE_MASK)) | 381 | (RREG32_SMC(ixCC_HARVEST_FUSES) & CC_HARVEST_FUSES__UVD_DISABLE_MASK)) |
@@ -399,14 +400,14 @@ static int uvd_v6_0_sw_init(void *handle) | |||
399 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 400 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
400 | 401 | ||
401 | /* UVD TRAP */ | 402 | /* UVD TRAP */ |
402 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 124, &adev->uvd.irq); | 403 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 124, &adev->uvd.inst->irq); |
403 | if (r) | 404 | if (r) |
404 | return r; | 405 | return r; |
405 | 406 | ||
406 | /* UVD ENC TRAP */ | 407 | /* UVD ENC TRAP */ |
407 | if (uvd_v6_0_enc_support(adev)) { | 408 | if (uvd_v6_0_enc_support(adev)) { |
408 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { | 409 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { |
409 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i + 119, &adev->uvd.irq); | 410 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i + 119, &adev->uvd.inst->irq); |
410 | if (r) | 411 | if (r) |
411 | return r; | 412 | return r; |
412 | } | 413 | } |
@@ -418,17 +419,17 @@ static int uvd_v6_0_sw_init(void *handle) | |||
418 | 419 | ||
419 | if (!uvd_v6_0_enc_support(adev)) { | 420 | if (!uvd_v6_0_enc_support(adev)) { |
420 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) | 421 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) |
421 | adev->uvd.ring_enc[i].funcs = NULL; | 422 | adev->uvd.inst->ring_enc[i].funcs = NULL; |
422 | 423 | ||
423 | adev->uvd.irq.num_types = 1; | 424 | adev->uvd.inst->irq.num_types = 1; |
424 | adev->uvd.num_enc_rings = 0; | 425 | adev->uvd.num_enc_rings = 0; |
425 | 426 | ||
426 | DRM_INFO("UVD ENC is disabled\n"); | 427 | DRM_INFO("UVD ENC is disabled\n"); |
427 | } else { | 428 | } else { |
428 | struct drm_sched_rq *rq; | 429 | struct drm_sched_rq *rq; |
429 | ring = &adev->uvd.ring_enc[0]; | 430 | ring = &adev->uvd.inst->ring_enc[0]; |
430 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; | 431 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
431 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.entity_enc, | 432 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.inst->entity_enc, |
432 | rq, NULL); | 433 | rq, NULL); |
433 | if (r) { | 434 | if (r) { |
434 | DRM_ERROR("Failed setting up UVD ENC run queue.\n"); | 435 | DRM_ERROR("Failed setting up UVD ENC run queue.\n"); |
@@ -440,17 +441,17 @@ static int uvd_v6_0_sw_init(void *handle) | |||
440 | if (r) | 441 | if (r) |
441 | return r; | 442 | return r; |
442 | 443 | ||
443 | ring = &adev->uvd.ring; | 444 | ring = &adev->uvd.inst->ring; |
444 | sprintf(ring->name, "uvd"); | 445 | sprintf(ring->name, "uvd"); |
445 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.irq, 0); | 446 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0); |
446 | if (r) | 447 | if (r) |
447 | return r; | 448 | return r; |
448 | 449 | ||
449 | if (uvd_v6_0_enc_support(adev)) { | 450 | if (uvd_v6_0_enc_support(adev)) { |
450 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { | 451 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { |
451 | ring = &adev->uvd.ring_enc[i]; | 452 | ring = &adev->uvd.inst->ring_enc[i]; |
452 | sprintf(ring->name, "uvd_enc%d", i); | 453 | sprintf(ring->name, "uvd_enc%d", i); |
453 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.irq, 0); | 454 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0); |
454 | if (r) | 455 | if (r) |
455 | return r; | 456 | return r; |
456 | } | 457 | } |
@@ -469,10 +470,10 @@ static int uvd_v6_0_sw_fini(void *handle) | |||
469 | return r; | 470 | return r; |
470 | 471 | ||
471 | if (uvd_v6_0_enc_support(adev)) { | 472 | if (uvd_v6_0_enc_support(adev)) { |
472 | drm_sched_entity_fini(&adev->uvd.ring_enc[0].sched, &adev->uvd.entity_enc); | 473 | drm_sched_entity_fini(&adev->uvd.inst->ring_enc[0].sched, &adev->uvd.inst->entity_enc); |
473 | 474 | ||
474 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) | 475 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) |
475 | amdgpu_ring_fini(&adev->uvd.ring_enc[i]); | 476 | amdgpu_ring_fini(&adev->uvd.inst->ring_enc[i]); |
476 | } | 477 | } |
477 | 478 | ||
478 | return amdgpu_uvd_sw_fini(adev); | 479 | return amdgpu_uvd_sw_fini(adev); |
@@ -488,7 +489,7 @@ static int uvd_v6_0_sw_fini(void *handle) | |||
488 | static int uvd_v6_0_hw_init(void *handle) | 489 | static int uvd_v6_0_hw_init(void *handle) |
489 | { | 490 | { |
490 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 491 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
491 | struct amdgpu_ring *ring = &adev->uvd.ring; | 492 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
492 | uint32_t tmp; | 493 | uint32_t tmp; |
493 | int i, r; | 494 | int i, r; |
494 | 495 | ||
@@ -532,7 +533,7 @@ static int uvd_v6_0_hw_init(void *handle) | |||
532 | 533 | ||
533 | if (uvd_v6_0_enc_support(adev)) { | 534 | if (uvd_v6_0_enc_support(adev)) { |
534 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { | 535 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { |
535 | ring = &adev->uvd.ring_enc[i]; | 536 | ring = &adev->uvd.inst->ring_enc[i]; |
536 | ring->ready = true; | 537 | ring->ready = true; |
537 | r = amdgpu_ring_test_ring(ring); | 538 | r = amdgpu_ring_test_ring(ring); |
538 | if (r) { | 539 | if (r) { |
@@ -563,7 +564,7 @@ done: | |||
563 | static int uvd_v6_0_hw_fini(void *handle) | 564 | static int uvd_v6_0_hw_fini(void *handle) |
564 | { | 565 | { |
565 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 566 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
566 | struct amdgpu_ring *ring = &adev->uvd.ring; | 567 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
567 | 568 | ||
568 | if (RREG32(mmUVD_STATUS) != 0) | 569 | if (RREG32(mmUVD_STATUS) != 0) |
569 | uvd_v6_0_stop(adev); | 570 | uvd_v6_0_stop(adev); |
@@ -611,9 +612,9 @@ static void uvd_v6_0_mc_resume(struct amdgpu_device *adev) | |||
611 | 612 | ||
612 | /* programm memory controller bits 0-27 */ | 613 | /* programm memory controller bits 0-27 */ |
613 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, | 614 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, |
614 | lower_32_bits(adev->uvd.gpu_addr)); | 615 | lower_32_bits(adev->uvd.inst->gpu_addr)); |
615 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, | 616 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, |
616 | upper_32_bits(adev->uvd.gpu_addr)); | 617 | upper_32_bits(adev->uvd.inst->gpu_addr)); |
617 | 618 | ||
618 | offset = AMDGPU_UVD_FIRMWARE_OFFSET; | 619 | offset = AMDGPU_UVD_FIRMWARE_OFFSET; |
619 | size = AMDGPU_UVD_FIRMWARE_SIZE(adev); | 620 | size = AMDGPU_UVD_FIRMWARE_SIZE(adev); |
@@ -726,7 +727,7 @@ static void cz_set_uvd_clock_gating_branches(struct amdgpu_device *adev, | |||
726 | */ | 727 | */ |
727 | static int uvd_v6_0_start(struct amdgpu_device *adev) | 728 | static int uvd_v6_0_start(struct amdgpu_device *adev) |
728 | { | 729 | { |
729 | struct amdgpu_ring *ring = &adev->uvd.ring; | 730 | struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
730 | uint32_t rb_bufsz, tmp; | 731 | uint32_t rb_bufsz, tmp; |
731 | uint32_t lmi_swap_cntl; | 732 | uint32_t lmi_swap_cntl; |
732 | uint32_t mp_swap_cntl; | 733 | uint32_t mp_swap_cntl; |
@@ -866,14 +867,14 @@ static int uvd_v6_0_start(struct amdgpu_device *adev) | |||
866 | WREG32_FIELD(UVD_RBC_RB_CNTL, RB_NO_FETCH, 0); | 867 | WREG32_FIELD(UVD_RBC_RB_CNTL, RB_NO_FETCH, 0); |
867 | 868 | ||
868 | if (uvd_v6_0_enc_support(adev)) { | 869 | if (uvd_v6_0_enc_support(adev)) { |
869 | ring = &adev->uvd.ring_enc[0]; | 870 | ring = &adev->uvd.inst->ring_enc[0]; |
870 | WREG32(mmUVD_RB_RPTR, lower_32_bits(ring->wptr)); | 871 | WREG32(mmUVD_RB_RPTR, lower_32_bits(ring->wptr)); |
871 | WREG32(mmUVD_RB_WPTR, lower_32_bits(ring->wptr)); | 872 | WREG32(mmUVD_RB_WPTR, lower_32_bits(ring->wptr)); |
872 | WREG32(mmUVD_RB_BASE_LO, ring->gpu_addr); | 873 | WREG32(mmUVD_RB_BASE_LO, ring->gpu_addr); |
873 | WREG32(mmUVD_RB_BASE_HI, upper_32_bits(ring->gpu_addr)); | 874 | WREG32(mmUVD_RB_BASE_HI, upper_32_bits(ring->gpu_addr)); |
874 | WREG32(mmUVD_RB_SIZE, ring->ring_size / 4); | 875 | WREG32(mmUVD_RB_SIZE, ring->ring_size / 4); |
875 | 876 | ||
876 | ring = &adev->uvd.ring_enc[1]; | 877 | ring = &adev->uvd.inst->ring_enc[1]; |
877 | WREG32(mmUVD_RB_RPTR2, lower_32_bits(ring->wptr)); | 878 | WREG32(mmUVD_RB_RPTR2, lower_32_bits(ring->wptr)); |
878 | WREG32(mmUVD_RB_WPTR2, lower_32_bits(ring->wptr)); | 879 | WREG32(mmUVD_RB_WPTR2, lower_32_bits(ring->wptr)); |
879 | WREG32(mmUVD_RB_BASE_LO2, ring->gpu_addr); | 880 | WREG32(mmUVD_RB_BASE_LO2, ring->gpu_addr); |
@@ -1099,6 +1100,18 @@ static void uvd_v6_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring) | |||
1099 | amdgpu_ring_write(ring, 0xE); | 1100 | amdgpu_ring_write(ring, 0xE); |
1100 | } | 1101 | } |
1101 | 1102 | ||
1103 | static void uvd_v6_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) | ||
1104 | { | ||
1105 | int i; | ||
1106 | |||
1107 | WARN_ON(ring->wptr % 2 || count % 2); | ||
1108 | |||
1109 | for (i = 0; i < count / 2; i++) { | ||
1110 | amdgpu_ring_write(ring, PACKET0(mmUVD_NO_OP, 0)); | ||
1111 | amdgpu_ring_write(ring, 0); | ||
1112 | } | ||
1113 | } | ||
1114 | |||
1102 | static void uvd_v6_0_enc_ring_emit_pipeline_sync(struct amdgpu_ring *ring) | 1115 | static void uvd_v6_0_enc_ring_emit_pipeline_sync(struct amdgpu_ring *ring) |
1103 | { | 1116 | { |
1104 | uint32_t seq = ring->fence_drv.sync_seq; | 1117 | uint32_t seq = ring->fence_drv.sync_seq; |
@@ -1158,10 +1171,10 @@ static bool uvd_v6_0_check_soft_reset(void *handle) | |||
1158 | srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_UVD, 1); | 1171 | srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_UVD, 1); |
1159 | 1172 | ||
1160 | if (srbm_soft_reset) { | 1173 | if (srbm_soft_reset) { |
1161 | adev->uvd.srbm_soft_reset = srbm_soft_reset; | 1174 | adev->uvd.inst->srbm_soft_reset = srbm_soft_reset; |
1162 | return true; | 1175 | return true; |
1163 | } else { | 1176 | } else { |
1164 | adev->uvd.srbm_soft_reset = 0; | 1177 | adev->uvd.inst->srbm_soft_reset = 0; |
1165 | return false; | 1178 | return false; |
1166 | } | 1179 | } |
1167 | } | 1180 | } |
@@ -1170,7 +1183,7 @@ static int uvd_v6_0_pre_soft_reset(void *handle) | |||
1170 | { | 1183 | { |
1171 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1184 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1172 | 1185 | ||
1173 | if (!adev->uvd.srbm_soft_reset) | 1186 | if (!adev->uvd.inst->srbm_soft_reset) |
1174 | return 0; | 1187 | return 0; |
1175 | 1188 | ||
1176 | uvd_v6_0_stop(adev); | 1189 | uvd_v6_0_stop(adev); |
@@ -1182,9 +1195,9 @@ static int uvd_v6_0_soft_reset(void *handle) | |||
1182 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1195 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1183 | u32 srbm_soft_reset; | 1196 | u32 srbm_soft_reset; |
1184 | 1197 | ||
1185 | if (!adev->uvd.srbm_soft_reset) | 1198 | if (!adev->uvd.inst->srbm_soft_reset) |
1186 | return 0; | 1199 | return 0; |
1187 | srbm_soft_reset = adev->uvd.srbm_soft_reset; | 1200 | srbm_soft_reset = adev->uvd.inst->srbm_soft_reset; |
1188 | 1201 | ||
1189 | if (srbm_soft_reset) { | 1202 | if (srbm_soft_reset) { |
1190 | u32 tmp; | 1203 | u32 tmp; |
@@ -1212,7 +1225,7 @@ static int uvd_v6_0_post_soft_reset(void *handle) | |||
1212 | { | 1225 | { |
1213 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1226 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1214 | 1227 | ||
1215 | if (!adev->uvd.srbm_soft_reset) | 1228 | if (!adev->uvd.inst->srbm_soft_reset) |
1216 | return 0; | 1229 | return 0; |
1217 | 1230 | ||
1218 | mdelay(5); | 1231 | mdelay(5); |
@@ -1238,17 +1251,17 @@ static int uvd_v6_0_process_interrupt(struct amdgpu_device *adev, | |||
1238 | 1251 | ||
1239 | switch (entry->src_id) { | 1252 | switch (entry->src_id) { |
1240 | case 124: | 1253 | case 124: |
1241 | amdgpu_fence_process(&adev->uvd.ring); | 1254 | amdgpu_fence_process(&adev->uvd.inst->ring); |
1242 | break; | 1255 | break; |
1243 | case 119: | 1256 | case 119: |
1244 | if (likely(uvd_v6_0_enc_support(adev))) | 1257 | if (likely(uvd_v6_0_enc_support(adev))) |
1245 | amdgpu_fence_process(&adev->uvd.ring_enc[0]); | 1258 | amdgpu_fence_process(&adev->uvd.inst->ring_enc[0]); |
1246 | else | 1259 | else |
1247 | int_handled = false; | 1260 | int_handled = false; |
1248 | break; | 1261 | break; |
1249 | case 120: | 1262 | case 120: |
1250 | if (likely(uvd_v6_0_enc_support(adev))) | 1263 | if (likely(uvd_v6_0_enc_support(adev))) |
1251 | amdgpu_fence_process(&adev->uvd.ring_enc[1]); | 1264 | amdgpu_fence_process(&adev->uvd.inst->ring_enc[1]); |
1252 | else | 1265 | else |
1253 | int_handled = false; | 1266 | int_handled = false; |
1254 | break; | 1267 | break; |
@@ -1531,7 +1544,6 @@ static const struct amd_ip_funcs uvd_v6_0_ip_funcs = { | |||
1531 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = { | 1544 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = { |
1532 | .type = AMDGPU_RING_TYPE_UVD, | 1545 | .type = AMDGPU_RING_TYPE_UVD, |
1533 | .align_mask = 0xf, | 1546 | .align_mask = 0xf, |
1534 | .nop = PACKET0(mmUVD_NO_OP, 0), | ||
1535 | .support_64bit_ptrs = false, | 1547 | .support_64bit_ptrs = false, |
1536 | .get_rptr = uvd_v6_0_ring_get_rptr, | 1548 | .get_rptr = uvd_v6_0_ring_get_rptr, |
1537 | .get_wptr = uvd_v6_0_ring_get_wptr, | 1549 | .get_wptr = uvd_v6_0_ring_get_wptr, |
@@ -1547,7 +1559,7 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = { | |||
1547 | .emit_hdp_flush = uvd_v6_0_ring_emit_hdp_flush, | 1559 | .emit_hdp_flush = uvd_v6_0_ring_emit_hdp_flush, |
1548 | .test_ring = uvd_v6_0_ring_test_ring, | 1560 | .test_ring = uvd_v6_0_ring_test_ring, |
1549 | .test_ib = amdgpu_uvd_ring_test_ib, | 1561 | .test_ib = amdgpu_uvd_ring_test_ib, |
1550 | .insert_nop = amdgpu_ring_insert_nop, | 1562 | .insert_nop = uvd_v6_0_ring_insert_nop, |
1551 | .pad_ib = amdgpu_ring_generic_pad_ib, | 1563 | .pad_ib = amdgpu_ring_generic_pad_ib, |
1552 | .begin_use = amdgpu_uvd_ring_begin_use, | 1564 | .begin_use = amdgpu_uvd_ring_begin_use, |
1553 | .end_use = amdgpu_uvd_ring_end_use, | 1565 | .end_use = amdgpu_uvd_ring_end_use, |
@@ -1612,10 +1624,10 @@ static const struct amdgpu_ring_funcs uvd_v6_0_enc_ring_vm_funcs = { | |||
1612 | static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev) | 1624 | static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev) |
1613 | { | 1625 | { |
1614 | if (adev->asic_type >= CHIP_POLARIS10) { | 1626 | if (adev->asic_type >= CHIP_POLARIS10) { |
1615 | adev->uvd.ring.funcs = &uvd_v6_0_ring_vm_funcs; | 1627 | adev->uvd.inst->ring.funcs = &uvd_v6_0_ring_vm_funcs; |
1616 | DRM_INFO("UVD is enabled in VM mode\n"); | 1628 | DRM_INFO("UVD is enabled in VM mode\n"); |
1617 | } else { | 1629 | } else { |
1618 | adev->uvd.ring.funcs = &uvd_v6_0_ring_phys_funcs; | 1630 | adev->uvd.inst->ring.funcs = &uvd_v6_0_ring_phys_funcs; |
1619 | DRM_INFO("UVD is enabled in physical mode\n"); | 1631 | DRM_INFO("UVD is enabled in physical mode\n"); |
1620 | } | 1632 | } |
1621 | } | 1633 | } |
@@ -1625,7 +1637,7 @@ static void uvd_v6_0_set_enc_ring_funcs(struct amdgpu_device *adev) | |||
1625 | int i; | 1637 | int i; |
1626 | 1638 | ||
1627 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) | 1639 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) |
1628 | adev->uvd.ring_enc[i].funcs = &uvd_v6_0_enc_ring_vm_funcs; | 1640 | adev->uvd.inst->ring_enc[i].funcs = &uvd_v6_0_enc_ring_vm_funcs; |
1629 | 1641 | ||
1630 | DRM_INFO("UVD ENC is enabled in VM mode\n"); | 1642 | DRM_INFO("UVD ENC is enabled in VM mode\n"); |
1631 | } | 1643 | } |
@@ -1638,11 +1650,11 @@ static const struct amdgpu_irq_src_funcs uvd_v6_0_irq_funcs = { | |||
1638 | static void uvd_v6_0_set_irq_funcs(struct amdgpu_device *adev) | 1650 | static void uvd_v6_0_set_irq_funcs(struct amdgpu_device *adev) |
1639 | { | 1651 | { |
1640 | if (uvd_v6_0_enc_support(adev)) | 1652 | if (uvd_v6_0_enc_support(adev)) |
1641 | adev->uvd.irq.num_types = adev->uvd.num_enc_rings + 1; | 1653 | adev->uvd.inst->irq.num_types = adev->uvd.num_enc_rings + 1; |
1642 | else | 1654 | else |
1643 | adev->uvd.irq.num_types = 1; | 1655 | adev->uvd.inst->irq.num_types = 1; |
1644 | 1656 | ||
1645 | adev->uvd.irq.funcs = &uvd_v6_0_irq_funcs; | 1657 | adev->uvd.inst->irq.funcs = &uvd_v6_0_irq_funcs; |
1646 | } | 1658 | } |
1647 | 1659 | ||
1648 | const struct amdgpu_ip_block_version uvd_v6_0_ip_block = | 1660 | const struct amdgpu_ip_block_version uvd_v6_0_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c index 0ca63d588670..57d32f21b3a6 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | |||
@@ -40,6 +40,8 @@ | |||
40 | #include "mmhub/mmhub_1_0_offset.h" | 40 | #include "mmhub/mmhub_1_0_offset.h" |
41 | #include "mmhub/mmhub_1_0_sh_mask.h" | 41 | #include "mmhub/mmhub_1_0_sh_mask.h" |
42 | 42 | ||
43 | #define UVD7_MAX_HW_INSTANCES_VEGA20 2 | ||
44 | |||
43 | static void uvd_v7_0_set_ring_funcs(struct amdgpu_device *adev); | 45 | static void uvd_v7_0_set_ring_funcs(struct amdgpu_device *adev); |
44 | static void uvd_v7_0_set_enc_ring_funcs(struct amdgpu_device *adev); | 46 | static void uvd_v7_0_set_enc_ring_funcs(struct amdgpu_device *adev); |
45 | static void uvd_v7_0_set_irq_funcs(struct amdgpu_device *adev); | 47 | static void uvd_v7_0_set_irq_funcs(struct amdgpu_device *adev); |
@@ -47,6 +49,11 @@ static int uvd_v7_0_start(struct amdgpu_device *adev); | |||
47 | static void uvd_v7_0_stop(struct amdgpu_device *adev); | 49 | static void uvd_v7_0_stop(struct amdgpu_device *adev); |
48 | static int uvd_v7_0_sriov_start(struct amdgpu_device *adev); | 50 | static int uvd_v7_0_sriov_start(struct amdgpu_device *adev); |
49 | 51 | ||
52 | static int amdgpu_ih_clientid_uvds[] = { | ||
53 | SOC15_IH_CLIENTID_UVD, | ||
54 | SOC15_IH_CLIENTID_UVD1 | ||
55 | }; | ||
56 | |||
50 | /** | 57 | /** |
51 | * uvd_v7_0_ring_get_rptr - get read pointer | 58 | * uvd_v7_0_ring_get_rptr - get read pointer |
52 | * | 59 | * |
@@ -58,7 +65,7 @@ static uint64_t uvd_v7_0_ring_get_rptr(struct amdgpu_ring *ring) | |||
58 | { | 65 | { |
59 | struct amdgpu_device *adev = ring->adev; | 66 | struct amdgpu_device *adev = ring->adev; |
60 | 67 | ||
61 | return RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); | 68 | return RREG32_SOC15(UVD, ring->me, mmUVD_RBC_RB_RPTR); |
62 | } | 69 | } |
63 | 70 | ||
64 | /** | 71 | /** |
@@ -72,10 +79,10 @@ static uint64_t uvd_v7_0_enc_ring_get_rptr(struct amdgpu_ring *ring) | |||
72 | { | 79 | { |
73 | struct amdgpu_device *adev = ring->adev; | 80 | struct amdgpu_device *adev = ring->adev; |
74 | 81 | ||
75 | if (ring == &adev->uvd.ring_enc[0]) | 82 | if (ring == &adev->uvd.inst[ring->me].ring_enc[0]) |
76 | return RREG32_SOC15(UVD, 0, mmUVD_RB_RPTR); | 83 | return RREG32_SOC15(UVD, ring->me, mmUVD_RB_RPTR); |
77 | else | 84 | else |
78 | return RREG32_SOC15(UVD, 0, mmUVD_RB_RPTR2); | 85 | return RREG32_SOC15(UVD, ring->me, mmUVD_RB_RPTR2); |
79 | } | 86 | } |
80 | 87 | ||
81 | /** | 88 | /** |
@@ -89,7 +96,7 @@ static uint64_t uvd_v7_0_ring_get_wptr(struct amdgpu_ring *ring) | |||
89 | { | 96 | { |
90 | struct amdgpu_device *adev = ring->adev; | 97 | struct amdgpu_device *adev = ring->adev; |
91 | 98 | ||
92 | return RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR); | 99 | return RREG32_SOC15(UVD, ring->me, mmUVD_RBC_RB_WPTR); |
93 | } | 100 | } |
94 | 101 | ||
95 | /** | 102 | /** |
@@ -106,10 +113,10 @@ static uint64_t uvd_v7_0_enc_ring_get_wptr(struct amdgpu_ring *ring) | |||
106 | if (ring->use_doorbell) | 113 | if (ring->use_doorbell) |
107 | return adev->wb.wb[ring->wptr_offs]; | 114 | return adev->wb.wb[ring->wptr_offs]; |
108 | 115 | ||
109 | if (ring == &adev->uvd.ring_enc[0]) | 116 | if (ring == &adev->uvd.inst[ring->me].ring_enc[0]) |
110 | return RREG32_SOC15(UVD, 0, mmUVD_RB_WPTR); | 117 | return RREG32_SOC15(UVD, ring->me, mmUVD_RB_WPTR); |
111 | else | 118 | else |
112 | return RREG32_SOC15(UVD, 0, mmUVD_RB_WPTR2); | 119 | return RREG32_SOC15(UVD, ring->me, mmUVD_RB_WPTR2); |
113 | } | 120 | } |
114 | 121 | ||
115 | /** | 122 | /** |
@@ -123,7 +130,7 @@ static void uvd_v7_0_ring_set_wptr(struct amdgpu_ring *ring) | |||
123 | { | 130 | { |
124 | struct amdgpu_device *adev = ring->adev; | 131 | struct amdgpu_device *adev = ring->adev; |
125 | 132 | ||
126 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr)); | 133 | WREG32_SOC15(UVD, ring->me, mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr)); |
127 | } | 134 | } |
128 | 135 | ||
129 | /** | 136 | /** |
@@ -144,11 +151,11 @@ static void uvd_v7_0_enc_ring_set_wptr(struct amdgpu_ring *ring) | |||
144 | return; | 151 | return; |
145 | } | 152 | } |
146 | 153 | ||
147 | if (ring == &adev->uvd.ring_enc[0]) | 154 | if (ring == &adev->uvd.inst[ring->me].ring_enc[0]) |
148 | WREG32_SOC15(UVD, 0, mmUVD_RB_WPTR, | 155 | WREG32_SOC15(UVD, ring->me, mmUVD_RB_WPTR, |
149 | lower_32_bits(ring->wptr)); | 156 | lower_32_bits(ring->wptr)); |
150 | else | 157 | else |
151 | WREG32_SOC15(UVD, 0, mmUVD_RB_WPTR2, | 158 | WREG32_SOC15(UVD, ring->me, mmUVD_RB_WPTR2, |
152 | lower_32_bits(ring->wptr)); | 159 | lower_32_bits(ring->wptr)); |
153 | } | 160 | } |
154 | 161 | ||
@@ -170,8 +177,8 @@ static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring) | |||
170 | 177 | ||
171 | r = amdgpu_ring_alloc(ring, 16); | 178 | r = amdgpu_ring_alloc(ring, 16); |
172 | if (r) { | 179 | if (r) { |
173 | DRM_ERROR("amdgpu: uvd enc failed to lock ring %d (%d).\n", | 180 | DRM_ERROR("amdgpu: uvd enc failed to lock (%d)ring %d (%d).\n", |
174 | ring->idx, r); | 181 | ring->me, ring->idx, r); |
175 | return r; | 182 | return r; |
176 | } | 183 | } |
177 | amdgpu_ring_write(ring, HEVC_ENC_CMD_END); | 184 | amdgpu_ring_write(ring, HEVC_ENC_CMD_END); |
@@ -184,11 +191,11 @@ static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring) | |||
184 | } | 191 | } |
185 | 192 | ||
186 | if (i < adev->usec_timeout) { | 193 | if (i < adev->usec_timeout) { |
187 | DRM_DEBUG("ring test on %d succeeded in %d usecs\n", | 194 | DRM_DEBUG("(%d)ring test on %d succeeded in %d usecs\n", |
188 | ring->idx, i); | 195 | ring->me, ring->idx, i); |
189 | } else { | 196 | } else { |
190 | DRM_ERROR("amdgpu: ring %d test failed\n", | 197 | DRM_ERROR("amdgpu: (%d)ring %d test failed\n", |
191 | ring->idx); | 198 | ring->me, ring->idx); |
192 | r = -ETIMEDOUT; | 199 | r = -ETIMEDOUT; |
193 | } | 200 | } |
194 | 201 | ||
@@ -342,24 +349,24 @@ static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
342 | 349 | ||
343 | r = uvd_v7_0_enc_get_create_msg(ring, 1, NULL); | 350 | r = uvd_v7_0_enc_get_create_msg(ring, 1, NULL); |
344 | if (r) { | 351 | if (r) { |
345 | DRM_ERROR("amdgpu: failed to get create msg (%ld).\n", r); | 352 | DRM_ERROR("amdgpu: (%d)failed to get create msg (%ld).\n", ring->me, r); |
346 | goto error; | 353 | goto error; |
347 | } | 354 | } |
348 | 355 | ||
349 | r = uvd_v7_0_enc_get_destroy_msg(ring, 1, true, &fence); | 356 | r = uvd_v7_0_enc_get_destroy_msg(ring, 1, true, &fence); |
350 | if (r) { | 357 | if (r) { |
351 | DRM_ERROR("amdgpu: failed to get destroy ib (%ld).\n", r); | 358 | DRM_ERROR("amdgpu: (%d)failed to get destroy ib (%ld).\n", ring->me, r); |
352 | goto error; | 359 | goto error; |
353 | } | 360 | } |
354 | 361 | ||
355 | r = dma_fence_wait_timeout(fence, false, timeout); | 362 | r = dma_fence_wait_timeout(fence, false, timeout); |
356 | if (r == 0) { | 363 | if (r == 0) { |
357 | DRM_ERROR("amdgpu: IB test timed out.\n"); | 364 | DRM_ERROR("amdgpu: (%d)IB test timed out.\n", ring->me); |
358 | r = -ETIMEDOUT; | 365 | r = -ETIMEDOUT; |
359 | } else if (r < 0) { | 366 | } else if (r < 0) { |
360 | DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r); | 367 | DRM_ERROR("amdgpu: (%d)fence wait failed (%ld).\n", ring->me, r); |
361 | } else { | 368 | } else { |
362 | DRM_DEBUG("ib test on ring %d succeeded\n", ring->idx); | 369 | DRM_DEBUG("ib test on (%d)ring %d succeeded\n", ring->me, ring->idx); |
363 | r = 0; | 370 | r = 0; |
364 | } | 371 | } |
365 | error: | 372 | error: |
@@ -370,6 +377,10 @@ error: | |||
370 | static int uvd_v7_0_early_init(void *handle) | 377 | static int uvd_v7_0_early_init(void *handle) |
371 | { | 378 | { |
372 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 379 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
380 | if (adev->asic_type == CHIP_VEGA20) | ||
381 | adev->uvd.num_uvd_inst = UVD7_MAX_HW_INSTANCES_VEGA20; | ||
382 | else | ||
383 | adev->uvd.num_uvd_inst = 1; | ||
373 | 384 | ||
374 | if (amdgpu_sriov_vf(adev)) | 385 | if (amdgpu_sriov_vf(adev)) |
375 | adev->uvd.num_enc_rings = 1; | 386 | adev->uvd.num_enc_rings = 1; |
@@ -386,19 +397,21 @@ static int uvd_v7_0_sw_init(void *handle) | |||
386 | { | 397 | { |
387 | struct amdgpu_ring *ring; | 398 | struct amdgpu_ring *ring; |
388 | struct drm_sched_rq *rq; | 399 | struct drm_sched_rq *rq; |
389 | int i, r; | 400 | int i, j, r; |
390 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 401 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
391 | 402 | ||
392 | /* UVD TRAP */ | 403 | for (j = 0; j < adev->uvd.num_uvd_inst; j++) { |
393 | r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_UVD, 124, &adev->uvd.irq); | 404 | /* UVD TRAP */ |
394 | if (r) | 405 | r = amdgpu_irq_add_id(adev, amdgpu_ih_clientid_uvds[j], 124, &adev->uvd.inst[j].irq); |
395 | return r; | ||
396 | |||
397 | /* UVD ENC TRAP */ | ||
398 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { | ||
399 | r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_UVD, i + 119, &adev->uvd.irq); | ||
400 | if (r) | 406 | if (r) |
401 | return r; | 407 | return r; |
408 | |||
409 | /* UVD ENC TRAP */ | ||
410 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { | ||
411 | r = amdgpu_irq_add_id(adev, amdgpu_ih_clientid_uvds[j], i + 119, &adev->uvd.inst[j].irq); | ||
412 | if (r) | ||
413 | return r; | ||
414 | } | ||
402 | } | 415 | } |
403 | 416 | ||
404 | r = amdgpu_uvd_sw_init(adev); | 417 | r = amdgpu_uvd_sw_init(adev); |
@@ -415,43 +428,48 @@ static int uvd_v7_0_sw_init(void *handle) | |||
415 | DRM_INFO("PSP loading UVD firmware\n"); | 428 | DRM_INFO("PSP loading UVD firmware\n"); |
416 | } | 429 | } |
417 | 430 | ||
418 | ring = &adev->uvd.ring_enc[0]; | 431 | for (j = 0; j < adev->uvd.num_uvd_inst; j++) { |
419 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; | 432 | ring = &adev->uvd.inst[j].ring_enc[0]; |
420 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.entity_enc, | 433 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
421 | rq, NULL); | 434 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.inst[j].entity_enc, |
422 | if (r) { | 435 | rq, NULL); |
423 | DRM_ERROR("Failed setting up UVD ENC run queue.\n"); | 436 | if (r) { |
424 | return r; | 437 | DRM_ERROR("(%d)Failed setting up UVD ENC run queue.\n", j); |
438 | return r; | ||
439 | } | ||
425 | } | 440 | } |
426 | 441 | ||
427 | r = amdgpu_uvd_resume(adev); | 442 | r = amdgpu_uvd_resume(adev); |
428 | if (r) | 443 | if (r) |
429 | return r; | 444 | return r; |
430 | if (!amdgpu_sriov_vf(adev)) { | ||
431 | ring = &adev->uvd.ring; | ||
432 | sprintf(ring->name, "uvd"); | ||
433 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.irq, 0); | ||
434 | if (r) | ||
435 | return r; | ||
436 | } | ||
437 | 445 | ||
438 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { | 446 | for (j = 0; j < adev->uvd.num_uvd_inst; j++) { |
439 | ring = &adev->uvd.ring_enc[i]; | 447 | if (!amdgpu_sriov_vf(adev)) { |
440 | sprintf(ring->name, "uvd_enc%d", i); | 448 | ring = &adev->uvd.inst[j].ring; |
441 | if (amdgpu_sriov_vf(adev)) { | 449 | sprintf(ring->name, "uvd<%d>", j); |
442 | ring->use_doorbell = true; | 450 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst[j].irq, 0); |
443 | 451 | if (r) | |
444 | /* currently only use the first enconding ring for | 452 | return r; |
445 | * sriov, so set unused location for other unused rings. | 453 | } |
446 | */ | 454 | |
447 | if (i == 0) | 455 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { |
448 | ring->doorbell_index = AMDGPU_DOORBELL64_UVD_RING0_1 * 2; | 456 | ring = &adev->uvd.inst[j].ring_enc[i]; |
449 | else | 457 | sprintf(ring->name, "uvd_enc%d<%d>", i, j); |
450 | ring->doorbell_index = AMDGPU_DOORBELL64_UVD_RING2_3 * 2 + 1; | 458 | if (amdgpu_sriov_vf(adev)) { |
459 | ring->use_doorbell = true; | ||
460 | |||
461 | /* currently only use the first enconding ring for | ||
462 | * sriov, so set unused location for other unused rings. | ||
463 | */ | ||
464 | if (i == 0) | ||
465 | ring->doorbell_index = AMDGPU_DOORBELL64_UVD_RING0_1 * 2; | ||
466 | else | ||
467 | ring->doorbell_index = AMDGPU_DOORBELL64_UVD_RING2_3 * 2 + 1; | ||
468 | } | ||
469 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst[j].irq, 0); | ||
470 | if (r) | ||
471 | return r; | ||
451 | } | 472 | } |
452 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.irq, 0); | ||
453 | if (r) | ||
454 | return r; | ||
455 | } | 473 | } |
456 | 474 | ||
457 | r = amdgpu_virt_alloc_mm_table(adev); | 475 | r = amdgpu_virt_alloc_mm_table(adev); |
@@ -463,7 +481,7 @@ static int uvd_v7_0_sw_init(void *handle) | |||
463 | 481 | ||
464 | static int uvd_v7_0_sw_fini(void *handle) | 482 | static int uvd_v7_0_sw_fini(void *handle) |
465 | { | 483 | { |
466 | int i, r; | 484 | int i, j, r; |
467 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 485 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
468 | 486 | ||
469 | amdgpu_virt_free_mm_table(adev); | 487 | amdgpu_virt_free_mm_table(adev); |
@@ -472,11 +490,12 @@ static int uvd_v7_0_sw_fini(void *handle) | |||
472 | if (r) | 490 | if (r) |
473 | return r; | 491 | return r; |
474 | 492 | ||
475 | drm_sched_entity_fini(&adev->uvd.ring_enc[0].sched, &adev->uvd.entity_enc); | 493 | for (j = 0; j < adev->uvd.num_uvd_inst; ++j) { |
476 | 494 | drm_sched_entity_fini(&adev->uvd.inst[j].ring_enc[0].sched, &adev->uvd.inst[j].entity_enc); | |
477 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) | ||
478 | amdgpu_ring_fini(&adev->uvd.ring_enc[i]); | ||
479 | 495 | ||
496 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) | ||
497 | amdgpu_ring_fini(&adev->uvd.inst[j].ring_enc[i]); | ||
498 | } | ||
480 | return amdgpu_uvd_sw_fini(adev); | 499 | return amdgpu_uvd_sw_fini(adev); |
481 | } | 500 | } |
482 | 501 | ||
@@ -490,9 +509,9 @@ static int uvd_v7_0_sw_fini(void *handle) | |||
490 | static int uvd_v7_0_hw_init(void *handle) | 509 | static int uvd_v7_0_hw_init(void *handle) |
491 | { | 510 | { |
492 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 511 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
493 | struct amdgpu_ring *ring = &adev->uvd.ring; | 512 | struct amdgpu_ring *ring; |
494 | uint32_t tmp; | 513 | uint32_t tmp; |
495 | int i, r; | 514 | int i, j, r; |
496 | 515 | ||
497 | if (amdgpu_sriov_vf(adev)) | 516 | if (amdgpu_sriov_vf(adev)) |
498 | r = uvd_v7_0_sriov_start(adev); | 517 | r = uvd_v7_0_sriov_start(adev); |
@@ -501,57 +520,60 @@ static int uvd_v7_0_hw_init(void *handle) | |||
501 | if (r) | 520 | if (r) |
502 | goto done; | 521 | goto done; |
503 | 522 | ||
504 | if (!amdgpu_sriov_vf(adev)) { | 523 | for (j = 0; j < adev->uvd.num_uvd_inst; ++j) { |
505 | ring->ready = true; | 524 | ring = &adev->uvd.inst[j].ring; |
506 | r = amdgpu_ring_test_ring(ring); | 525 | |
507 | if (r) { | 526 | if (!amdgpu_sriov_vf(adev)) { |
508 | ring->ready = false; | 527 | ring->ready = true; |
509 | goto done; | 528 | r = amdgpu_ring_test_ring(ring); |
510 | } | 529 | if (r) { |
511 | 530 | ring->ready = false; | |
512 | r = amdgpu_ring_alloc(ring, 10); | 531 | goto done; |
513 | if (r) { | 532 | } |
514 | DRM_ERROR("amdgpu: ring failed to lock UVD ring (%d).\n", r); | 533 | |
515 | goto done; | 534 | r = amdgpu_ring_alloc(ring, 10); |
535 | if (r) { | ||
536 | DRM_ERROR("amdgpu: (%d)ring failed to lock UVD ring (%d).\n", j, r); | ||
537 | goto done; | ||
538 | } | ||
539 | |||
540 | tmp = PACKET0(SOC15_REG_OFFSET(UVD, j, | ||
541 | mmUVD_SEMA_WAIT_FAULT_TIMEOUT_CNTL), 0); | ||
542 | amdgpu_ring_write(ring, tmp); | ||
543 | amdgpu_ring_write(ring, 0xFFFFF); | ||
544 | |||
545 | tmp = PACKET0(SOC15_REG_OFFSET(UVD, j, | ||
546 | mmUVD_SEMA_WAIT_INCOMPLETE_TIMEOUT_CNTL), 0); | ||
547 | amdgpu_ring_write(ring, tmp); | ||
548 | amdgpu_ring_write(ring, 0xFFFFF); | ||
549 | |||
550 | tmp = PACKET0(SOC15_REG_OFFSET(UVD, j, | ||
551 | mmUVD_SEMA_SIGNAL_INCOMPLETE_TIMEOUT_CNTL), 0); | ||
552 | amdgpu_ring_write(ring, tmp); | ||
553 | amdgpu_ring_write(ring, 0xFFFFF); | ||
554 | |||
555 | /* Clear timeout status bits */ | ||
556 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, j, | ||
557 | mmUVD_SEMA_TIMEOUT_STATUS), 0)); | ||
558 | amdgpu_ring_write(ring, 0x8); | ||
559 | |||
560 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, j, | ||
561 | mmUVD_SEMA_CNTL), 0)); | ||
562 | amdgpu_ring_write(ring, 3); | ||
563 | |||
564 | amdgpu_ring_commit(ring); | ||
516 | } | 565 | } |
517 | 566 | ||
518 | tmp = PACKET0(SOC15_REG_OFFSET(UVD, 0, | 567 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { |
519 | mmUVD_SEMA_WAIT_FAULT_TIMEOUT_CNTL), 0); | 568 | ring = &adev->uvd.inst[j].ring_enc[i]; |
520 | amdgpu_ring_write(ring, tmp); | 569 | ring->ready = true; |
521 | amdgpu_ring_write(ring, 0xFFFFF); | 570 | r = amdgpu_ring_test_ring(ring); |
522 | 571 | if (r) { | |
523 | tmp = PACKET0(SOC15_REG_OFFSET(UVD, 0, | 572 | ring->ready = false; |
524 | mmUVD_SEMA_WAIT_INCOMPLETE_TIMEOUT_CNTL), 0); | 573 | goto done; |
525 | amdgpu_ring_write(ring, tmp); | 574 | } |
526 | amdgpu_ring_write(ring, 0xFFFFF); | ||
527 | |||
528 | tmp = PACKET0(SOC15_REG_OFFSET(UVD, 0, | ||
529 | mmUVD_SEMA_SIGNAL_INCOMPLETE_TIMEOUT_CNTL), 0); | ||
530 | amdgpu_ring_write(ring, tmp); | ||
531 | amdgpu_ring_write(ring, 0xFFFFF); | ||
532 | |||
533 | /* Clear timeout status bits */ | ||
534 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, 0, | ||
535 | mmUVD_SEMA_TIMEOUT_STATUS), 0)); | ||
536 | amdgpu_ring_write(ring, 0x8); | ||
537 | |||
538 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, 0, | ||
539 | mmUVD_SEMA_CNTL), 0)); | ||
540 | amdgpu_ring_write(ring, 3); | ||
541 | |||
542 | amdgpu_ring_commit(ring); | ||
543 | } | ||
544 | |||
545 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { | ||
546 | ring = &adev->uvd.ring_enc[i]; | ||
547 | ring->ready = true; | ||
548 | r = amdgpu_ring_test_ring(ring); | ||
549 | if (r) { | ||
550 | ring->ready = false; | ||
551 | goto done; | ||
552 | } | 575 | } |
553 | } | 576 | } |
554 | |||
555 | done: | 577 | done: |
556 | if (!r) | 578 | if (!r) |
557 | DRM_INFO("UVD and UVD ENC initialized successfully.\n"); | 579 | DRM_INFO("UVD and UVD ENC initialized successfully.\n"); |
@@ -569,7 +591,7 @@ done: | |||
569 | static int uvd_v7_0_hw_fini(void *handle) | 591 | static int uvd_v7_0_hw_fini(void *handle) |
570 | { | 592 | { |
571 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 593 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
572 | struct amdgpu_ring *ring = &adev->uvd.ring; | 594 | int i; |
573 | 595 | ||
574 | if (!amdgpu_sriov_vf(adev)) | 596 | if (!amdgpu_sriov_vf(adev)) |
575 | uvd_v7_0_stop(adev); | 597 | uvd_v7_0_stop(adev); |
@@ -578,7 +600,8 @@ static int uvd_v7_0_hw_fini(void *handle) | |||
578 | DRM_DEBUG("For SRIOV client, shouldn't do anything.\n"); | 600 | DRM_DEBUG("For SRIOV client, shouldn't do anything.\n"); |
579 | } | 601 | } |
580 | 602 | ||
581 | ring->ready = false; | 603 | for (i = 0; i < adev->uvd.num_uvd_inst; ++i) |
604 | adev->uvd.inst[i].ring.ready = false; | ||
582 | 605 | ||
583 | return 0; | 606 | return 0; |
584 | } | 607 | } |
@@ -618,48 +641,51 @@ static void uvd_v7_0_mc_resume(struct amdgpu_device *adev) | |||
618 | { | 641 | { |
619 | uint32_t size = AMDGPU_UVD_FIRMWARE_SIZE(adev); | 642 | uint32_t size = AMDGPU_UVD_FIRMWARE_SIZE(adev); |
620 | uint32_t offset; | 643 | uint32_t offset; |
644 | int i; | ||
621 | 645 | ||
622 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { | 646 | for (i = 0; i < adev->uvd.num_uvd_inst; ++i) { |
623 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, | 647 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { |
624 | lower_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr)); | 648 | WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, |
625 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, | 649 | lower_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr)); |
626 | upper_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr)); | 650 | WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, |
627 | offset = 0; | 651 | upper_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr)); |
628 | } else { | 652 | offset = 0; |
629 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, | 653 | } else { |
630 | lower_32_bits(adev->uvd.gpu_addr)); | 654 | WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, |
631 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, | 655 | lower_32_bits(adev->uvd.inst[i].gpu_addr)); |
632 | upper_32_bits(adev->uvd.gpu_addr)); | 656 | WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, |
633 | offset = size; | 657 | upper_32_bits(adev->uvd.inst[i].gpu_addr)); |
634 | } | 658 | offset = size; |
659 | } | ||
635 | 660 | ||
636 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET0, | 661 | WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_OFFSET0, |
637 | AMDGPU_UVD_FIRMWARE_OFFSET >> 3); | 662 | AMDGPU_UVD_FIRMWARE_OFFSET >> 3); |
638 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE0, size); | 663 | WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_SIZE0, size); |
639 | 664 | ||
640 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, | 665 | WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, |
641 | lower_32_bits(adev->uvd.gpu_addr + offset)); | 666 | lower_32_bits(adev->uvd.inst[i].gpu_addr + offset)); |
642 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, | 667 | WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, |
643 | upper_32_bits(adev->uvd.gpu_addr + offset)); | 668 | upper_32_bits(adev->uvd.inst[i].gpu_addr + offset)); |
644 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1, (1 << 21)); | 669 | WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_OFFSET1, (1 << 21)); |
645 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_UVD_HEAP_SIZE); | 670 | WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_UVD_HEAP_SIZE); |
646 | 671 | ||
647 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, | 672 | WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, |
648 | lower_32_bits(adev->uvd.gpu_addr + offset + AMDGPU_UVD_HEAP_SIZE)); | 673 | lower_32_bits(adev->uvd.inst[i].gpu_addr + offset + AMDGPU_UVD_HEAP_SIZE)); |
649 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, | 674 | WREG32_SOC15(UVD, i, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, |
650 | upper_32_bits(adev->uvd.gpu_addr + offset + AMDGPU_UVD_HEAP_SIZE)); | 675 | upper_32_bits(adev->uvd.inst[i].gpu_addr + offset + AMDGPU_UVD_HEAP_SIZE)); |
651 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2, (2 << 21)); | 676 | WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_OFFSET2, (2 << 21)); |
652 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, | 677 | WREG32_SOC15(UVD, i, mmUVD_VCPU_CACHE_SIZE2, |
653 | AMDGPU_UVD_STACK_SIZE + (AMDGPU_UVD_SESSION_SIZE * 40)); | 678 | AMDGPU_UVD_STACK_SIZE + (AMDGPU_UVD_SESSION_SIZE * 40)); |
654 | 679 | ||
655 | WREG32_SOC15(UVD, 0, mmUVD_UDEC_ADDR_CONFIG, | 680 | WREG32_SOC15(UVD, i, mmUVD_UDEC_ADDR_CONFIG, |
656 | adev->gfx.config.gb_addr_config); | 681 | adev->gfx.config.gb_addr_config); |
657 | WREG32_SOC15(UVD, 0, mmUVD_UDEC_DB_ADDR_CONFIG, | 682 | WREG32_SOC15(UVD, i, mmUVD_UDEC_DB_ADDR_CONFIG, |
658 | adev->gfx.config.gb_addr_config); | 683 | adev->gfx.config.gb_addr_config); |
659 | WREG32_SOC15(UVD, 0, mmUVD_UDEC_DBW_ADDR_CONFIG, | 684 | WREG32_SOC15(UVD, i, mmUVD_UDEC_DBW_ADDR_CONFIG, |
660 | adev->gfx.config.gb_addr_config); | 685 | adev->gfx.config.gb_addr_config); |
661 | 686 | ||
662 | WREG32_SOC15(UVD, 0, mmUVD_GP_SCRATCH4, adev->uvd.max_handles); | 687 | WREG32_SOC15(UVD, i, mmUVD_GP_SCRATCH4, adev->uvd.max_handles); |
688 | } | ||
663 | } | 689 | } |
664 | 690 | ||
665 | static int uvd_v7_0_mmsch_start(struct amdgpu_device *adev, | 691 | static int uvd_v7_0_mmsch_start(struct amdgpu_device *adev, |
@@ -669,6 +695,7 @@ static int uvd_v7_0_mmsch_start(struct amdgpu_device *adev, | |||
669 | uint64_t addr = table->gpu_addr; | 695 | uint64_t addr = table->gpu_addr; |
670 | struct mmsch_v1_0_init_header *header = (struct mmsch_v1_0_init_header *)table->cpu_addr; | 696 | struct mmsch_v1_0_init_header *header = (struct mmsch_v1_0_init_header *)table->cpu_addr; |
671 | uint32_t size; | 697 | uint32_t size; |
698 | int i; | ||
672 | 699 | ||
673 | size = header->header_size + header->vce_table_size + header->uvd_table_size; | 700 | size = header->header_size + header->vce_table_size + header->uvd_table_size; |
674 | 701 | ||
@@ -688,11 +715,12 @@ static int uvd_v7_0_mmsch_start(struct amdgpu_device *adev, | |||
688 | /* 4, set resp to zero */ | 715 | /* 4, set resp to zero */ |
689 | WREG32_SOC15(VCE, 0, mmVCE_MMSCH_VF_MAILBOX_RESP, 0); | 716 | WREG32_SOC15(VCE, 0, mmVCE_MMSCH_VF_MAILBOX_RESP, 0); |
690 | 717 | ||
691 | WDOORBELL32(adev->uvd.ring_enc[0].doorbell_index, 0); | 718 | for (i = 0; i < adev->uvd.num_uvd_inst; ++i) { |
692 | adev->wb.wb[adev->uvd.ring_enc[0].wptr_offs] = 0; | 719 | WDOORBELL32(adev->uvd.inst[i].ring_enc[0].doorbell_index, 0); |
693 | adev->uvd.ring_enc[0].wptr = 0; | 720 | adev->wb.wb[adev->uvd.inst[i].ring_enc[0].wptr_offs] = 0; |
694 | adev->uvd.ring_enc[0].wptr_old = 0; | 721 | adev->uvd.inst[i].ring_enc[0].wptr = 0; |
695 | 722 | adev->uvd.inst[i].ring_enc[0].wptr_old = 0; | |
723 | } | ||
696 | /* 5, kick off the initialization and wait until VCE_MMSCH_VF_MAILBOX_RESP becomes non-zero */ | 724 | /* 5, kick off the initialization and wait until VCE_MMSCH_VF_MAILBOX_RESP becomes non-zero */ |
697 | WREG32_SOC15(VCE, 0, mmVCE_MMSCH_VF_MAILBOX_HOST, 0x10000001); | 725 | WREG32_SOC15(VCE, 0, mmVCE_MMSCH_VF_MAILBOX_HOST, 0x10000001); |
698 | 726 | ||
@@ -725,6 +753,7 @@ static int uvd_v7_0_sriov_start(struct amdgpu_device *adev) | |||
725 | struct mmsch_v1_0_cmd_end end = { {0} }; | 753 | struct mmsch_v1_0_cmd_end end = { {0} }; |
726 | uint32_t *init_table = adev->virt.mm_table.cpu_addr; | 754 | uint32_t *init_table = adev->virt.mm_table.cpu_addr; |
727 | struct mmsch_v1_0_init_header *header = (struct mmsch_v1_0_init_header *)init_table; | 755 | struct mmsch_v1_0_init_header *header = (struct mmsch_v1_0_init_header *)init_table; |
756 | uint8_t i = 0; | ||
728 | 757 | ||
729 | direct_wt.cmd_header.command_type = MMSCH_COMMAND__DIRECT_REG_WRITE; | 758 | direct_wt.cmd_header.command_type = MMSCH_COMMAND__DIRECT_REG_WRITE; |
730 | direct_rd_mod_wt.cmd_header.command_type = MMSCH_COMMAND__DIRECT_REG_READ_MODIFY_WRITE; | 759 | direct_rd_mod_wt.cmd_header.command_type = MMSCH_COMMAND__DIRECT_REG_READ_MODIFY_WRITE; |
@@ -742,120 +771,121 @@ static int uvd_v7_0_sriov_start(struct amdgpu_device *adev) | |||
742 | 771 | ||
743 | init_table += header->uvd_table_offset; | 772 | init_table += header->uvd_table_offset; |
744 | 773 | ||
745 | ring = &adev->uvd.ring; | 774 | for (i = 0; i < adev->uvd.num_uvd_inst; ++i) { |
746 | ring->wptr = 0; | 775 | ring = &adev->uvd.inst[i].ring; |
747 | size = AMDGPU_GPU_PAGE_ALIGN(adev->uvd.fw->size + 4); | 776 | ring->wptr = 0; |
748 | 777 | size = AMDGPU_GPU_PAGE_ALIGN(adev->uvd.fw->size + 4); | |
749 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_STATUS), | 778 | |
750 | 0xFFFFFFFF, 0x00000004); | 779 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_STATUS), |
751 | /* mc resume*/ | 780 | 0xFFFFFFFF, 0x00000004); |
752 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { | 781 | /* mc resume*/ |
753 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW), | 782 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { |
754 | lower_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr)); | 783 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW), |
755 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH), | 784 | lower_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr)); |
756 | upper_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr)); | 785 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH), |
757 | offset = 0; | 786 | upper_32_bits(adev->firmware.ucode[AMDGPU_UCODE_ID_UVD].mc_addr)); |
758 | } else { | 787 | offset = 0; |
759 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW), | 788 | } else { |
760 | lower_32_bits(adev->uvd.gpu_addr)); | 789 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW), |
761 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH), | 790 | lower_32_bits(adev->uvd.inst[i].gpu_addr)); |
762 | upper_32_bits(adev->uvd.gpu_addr)); | 791 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH), |
763 | offset = size; | 792 | upper_32_bits(adev->uvd.inst[i].gpu_addr)); |
793 | offset = size; | ||
794 | } | ||
795 | |||
796 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_VCPU_CACHE_OFFSET0), | ||
797 | AMDGPU_UVD_FIRMWARE_OFFSET >> 3); | ||
798 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_VCPU_CACHE_SIZE0), size); | ||
799 | |||
800 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW), | ||
801 | lower_32_bits(adev->uvd.inst[i].gpu_addr + offset)); | ||
802 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH), | ||
803 | upper_32_bits(adev->uvd.inst[i].gpu_addr + offset)); | ||
804 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_VCPU_CACHE_OFFSET1), (1 << 21)); | ||
805 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_VCPU_CACHE_SIZE1), AMDGPU_UVD_HEAP_SIZE); | ||
806 | |||
807 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW), | ||
808 | lower_32_bits(adev->uvd.inst[i].gpu_addr + offset + AMDGPU_UVD_HEAP_SIZE)); | ||
809 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH), | ||
810 | upper_32_bits(adev->uvd.inst[i].gpu_addr + offset + AMDGPU_UVD_HEAP_SIZE)); | ||
811 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_VCPU_CACHE_OFFSET2), (2 << 21)); | ||
812 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_VCPU_CACHE_SIZE2), | ||
813 | AMDGPU_UVD_STACK_SIZE + (AMDGPU_UVD_SESSION_SIZE * 40)); | ||
814 | |||
815 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_GP_SCRATCH4), adev->uvd.max_handles); | ||
816 | /* mc resume end*/ | ||
817 | |||
818 | /* disable clock gating */ | ||
819 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_CGC_CTRL), | ||
820 | ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK, 0); | ||
821 | |||
822 | /* disable interupt */ | ||
823 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_MASTINT_EN), | ||
824 | ~UVD_MASTINT_EN__VCPU_EN_MASK, 0); | ||
825 | |||
826 | /* stall UMC and register bus before resetting VCPU */ | ||
827 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_CTRL2), | ||
828 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, | ||
829 | UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | ||
830 | |||
831 | /* put LMI, VCPU, RBC etc... into reset */ | ||
832 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_SOFT_RESET), | ||
833 | (uint32_t)(UVD_SOFT_RESET__LMI_SOFT_RESET_MASK | | ||
834 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK | | ||
835 | UVD_SOFT_RESET__LBSI_SOFT_RESET_MASK | | ||
836 | UVD_SOFT_RESET__RBC_SOFT_RESET_MASK | | ||
837 | UVD_SOFT_RESET__CSM_SOFT_RESET_MASK | | ||
838 | UVD_SOFT_RESET__CXW_SOFT_RESET_MASK | | ||
839 | UVD_SOFT_RESET__TAP_SOFT_RESET_MASK | | ||
840 | UVD_SOFT_RESET__LMI_UMC_SOFT_RESET_MASK)); | ||
841 | |||
842 | /* initialize UVD memory controller */ | ||
843 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_CTRL), | ||
844 | (uint32_t)((0x40 << UVD_LMI_CTRL__WRITE_CLEAN_TIMER__SHIFT) | | ||
845 | UVD_LMI_CTRL__WRITE_CLEAN_TIMER_EN_MASK | | ||
846 | UVD_LMI_CTRL__DATA_COHERENCY_EN_MASK | | ||
847 | UVD_LMI_CTRL__VCPU_DATA_COHERENCY_EN_MASK | | ||
848 | UVD_LMI_CTRL__REQ_MODE_MASK | | ||
849 | 0x00100000L)); | ||
850 | |||
851 | /* take all subblocks out of reset, except VCPU */ | ||
852 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_SOFT_RESET), | ||
853 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
854 | |||
855 | /* enable VCPU clock */ | ||
856 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_VCPU_CNTL), | ||
857 | UVD_VCPU_CNTL__CLK_EN_MASK); | ||
858 | |||
859 | /* enable master interrupt */ | ||
860 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_MASTINT_EN), | ||
861 | ~(UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK), | ||
862 | (UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK)); | ||
863 | |||
864 | /* clear the bit 4 of UVD_STATUS */ | ||
865 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_STATUS), | ||
866 | ~(2 << UVD_STATUS__VCPU_REPORT__SHIFT), 0); | ||
867 | |||
868 | /* force RBC into idle state */ | ||
869 | size = order_base_2(ring->ring_size); | ||
870 | tmp = REG_SET_FIELD(0, UVD_RBC_RB_CNTL, RB_BUFSZ, size); | ||
871 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_FETCH, 1); | ||
872 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_RBC_RB_CNTL), tmp); | ||
873 | |||
874 | ring = &adev->uvd.inst[i].ring_enc[0]; | ||
875 | ring->wptr = 0; | ||
876 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_RB_BASE_LO), ring->gpu_addr); | ||
877 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_RB_BASE_HI), upper_32_bits(ring->gpu_addr)); | ||
878 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_RB_SIZE), ring->ring_size / 4); | ||
879 | |||
880 | /* boot up the VCPU */ | ||
881 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_SOFT_RESET), 0); | ||
882 | |||
883 | /* enable UMC */ | ||
884 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_CTRL2), | ||
885 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, 0); | ||
886 | |||
887 | MMSCH_V1_0_INSERT_DIRECT_POLL(SOC15_REG_OFFSET(UVD, i, mmUVD_STATUS), 0x02, 0x02); | ||
764 | } | 888 | } |
765 | |||
766 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_VCPU_CACHE_OFFSET0), | ||
767 | AMDGPU_UVD_FIRMWARE_OFFSET >> 3); | ||
768 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_VCPU_CACHE_SIZE0), size); | ||
769 | |||
770 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW), | ||
771 | lower_32_bits(adev->uvd.gpu_addr + offset)); | ||
772 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH), | ||
773 | upper_32_bits(adev->uvd.gpu_addr + offset)); | ||
774 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1), (1 << 21)); | ||
775 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_VCPU_CACHE_SIZE1), AMDGPU_UVD_HEAP_SIZE); | ||
776 | |||
777 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW), | ||
778 | lower_32_bits(adev->uvd.gpu_addr + offset + AMDGPU_UVD_HEAP_SIZE)); | ||
779 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH), | ||
780 | upper_32_bits(adev->uvd.gpu_addr + offset + AMDGPU_UVD_HEAP_SIZE)); | ||
781 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2), (2 << 21)); | ||
782 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_VCPU_CACHE_SIZE2), | ||
783 | AMDGPU_UVD_STACK_SIZE + (AMDGPU_UVD_SESSION_SIZE * 40)); | ||
784 | |||
785 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_GP_SCRATCH4), adev->uvd.max_handles); | ||
786 | /* mc resume end*/ | ||
787 | |||
788 | /* disable clock gating */ | ||
789 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_CGC_CTRL), | ||
790 | ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK, 0); | ||
791 | |||
792 | /* disable interupt */ | ||
793 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_MASTINT_EN), | ||
794 | ~UVD_MASTINT_EN__VCPU_EN_MASK, 0); | ||
795 | |||
796 | /* stall UMC and register bus before resetting VCPU */ | ||
797 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL2), | ||
798 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, | ||
799 | UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | ||
800 | |||
801 | /* put LMI, VCPU, RBC etc... into reset */ | ||
802 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_SOFT_RESET), | ||
803 | (uint32_t)(UVD_SOFT_RESET__LMI_SOFT_RESET_MASK | | ||
804 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK | | ||
805 | UVD_SOFT_RESET__LBSI_SOFT_RESET_MASK | | ||
806 | UVD_SOFT_RESET__RBC_SOFT_RESET_MASK | | ||
807 | UVD_SOFT_RESET__CSM_SOFT_RESET_MASK | | ||
808 | UVD_SOFT_RESET__CXW_SOFT_RESET_MASK | | ||
809 | UVD_SOFT_RESET__TAP_SOFT_RESET_MASK | | ||
810 | UVD_SOFT_RESET__LMI_UMC_SOFT_RESET_MASK)); | ||
811 | |||
812 | /* initialize UVD memory controller */ | ||
813 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL), | ||
814 | (uint32_t)((0x40 << UVD_LMI_CTRL__WRITE_CLEAN_TIMER__SHIFT) | | ||
815 | UVD_LMI_CTRL__WRITE_CLEAN_TIMER_EN_MASK | | ||
816 | UVD_LMI_CTRL__DATA_COHERENCY_EN_MASK | | ||
817 | UVD_LMI_CTRL__VCPU_DATA_COHERENCY_EN_MASK | | ||
818 | UVD_LMI_CTRL__REQ_MODE_MASK | | ||
819 | 0x00100000L)); | ||
820 | |||
821 | /* take all subblocks out of reset, except VCPU */ | ||
822 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_SOFT_RESET), | ||
823 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
824 | |||
825 | /* enable VCPU clock */ | ||
826 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_VCPU_CNTL), | ||
827 | UVD_VCPU_CNTL__CLK_EN_MASK); | ||
828 | |||
829 | /* enable master interrupt */ | ||
830 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_MASTINT_EN), | ||
831 | ~(UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK), | ||
832 | (UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK)); | ||
833 | |||
834 | /* clear the bit 4 of UVD_STATUS */ | ||
835 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_STATUS), | ||
836 | ~(2 << UVD_STATUS__VCPU_REPORT__SHIFT), 0); | ||
837 | |||
838 | /* force RBC into idle state */ | ||
839 | size = order_base_2(ring->ring_size); | ||
840 | tmp = REG_SET_FIELD(0, UVD_RBC_RB_CNTL, RB_BUFSZ, size); | ||
841 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_FETCH, 1); | ||
842 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_RBC_RB_CNTL), tmp); | ||
843 | |||
844 | ring = &adev->uvd.ring_enc[0]; | ||
845 | ring->wptr = 0; | ||
846 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_RB_BASE_LO), ring->gpu_addr); | ||
847 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_RB_BASE_HI), upper_32_bits(ring->gpu_addr)); | ||
848 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_RB_SIZE), ring->ring_size / 4); | ||
849 | |||
850 | /* boot up the VCPU */ | ||
851 | MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_SOFT_RESET), 0); | ||
852 | |||
853 | /* enable UMC */ | ||
854 | MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL2), | ||
855 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, 0); | ||
856 | |||
857 | MMSCH_V1_0_INSERT_DIRECT_POLL(SOC15_REG_OFFSET(UVD, 0, mmUVD_STATUS), 0x02, 0x02); | ||
858 | |||
859 | /* add end packet */ | 889 | /* add end packet */ |
860 | memcpy((void *)init_table, &end, sizeof(struct mmsch_v1_0_cmd_end)); | 890 | memcpy((void *)init_table, &end, sizeof(struct mmsch_v1_0_cmd_end)); |
861 | table_size += sizeof(struct mmsch_v1_0_cmd_end) / 4; | 891 | table_size += sizeof(struct mmsch_v1_0_cmd_end) / 4; |
@@ -874,15 +904,17 @@ static int uvd_v7_0_sriov_start(struct amdgpu_device *adev) | |||
874 | */ | 904 | */ |
875 | static int uvd_v7_0_start(struct amdgpu_device *adev) | 905 | static int uvd_v7_0_start(struct amdgpu_device *adev) |
876 | { | 906 | { |
877 | struct amdgpu_ring *ring = &adev->uvd.ring; | 907 | struct amdgpu_ring *ring; |
878 | uint32_t rb_bufsz, tmp; | 908 | uint32_t rb_bufsz, tmp; |
879 | uint32_t lmi_swap_cntl; | 909 | uint32_t lmi_swap_cntl; |
880 | uint32_t mp_swap_cntl; | 910 | uint32_t mp_swap_cntl; |
881 | int i, j, r; | 911 | int i, j, k, r; |
882 | 912 | ||
883 | /* disable DPG */ | 913 | for (k = 0; k < adev->uvd.num_uvd_inst; ++k) { |
884 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_POWER_STATUS), 0, | 914 | /* disable DPG */ |
885 | ~UVD_POWER_STATUS__UVD_PG_MODE_MASK); | 915 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_POWER_STATUS), 0, |
916 | ~UVD_POWER_STATUS__UVD_PG_MODE_MASK); | ||
917 | } | ||
886 | 918 | ||
887 | /* disable byte swapping */ | 919 | /* disable byte swapping */ |
888 | lmi_swap_cntl = 0; | 920 | lmi_swap_cntl = 0; |
@@ -890,157 +922,159 @@ static int uvd_v7_0_start(struct amdgpu_device *adev) | |||
890 | 922 | ||
891 | uvd_v7_0_mc_resume(adev); | 923 | uvd_v7_0_mc_resume(adev); |
892 | 924 | ||
893 | /* disable clock gating */ | 925 | for (k = 0; k < adev->uvd.num_uvd_inst; ++k) { |
894 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_CGC_CTRL), 0, | 926 | ring = &adev->uvd.inst[k].ring; |
895 | ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK); | 927 | /* disable clock gating */ |
896 | 928 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_CGC_CTRL), 0, | |
897 | /* disable interupt */ | 929 | ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK); |
898 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_MASTINT_EN), 0, | ||
899 | ~UVD_MASTINT_EN__VCPU_EN_MASK); | ||
900 | |||
901 | /* stall UMC and register bus before resetting VCPU */ | ||
902 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL2), | ||
903 | UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, | ||
904 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | ||
905 | mdelay(1); | ||
906 | |||
907 | /* put LMI, VCPU, RBC etc... into reset */ | ||
908 | WREG32_SOC15(UVD, 0, mmUVD_SOFT_RESET, | ||
909 | UVD_SOFT_RESET__LMI_SOFT_RESET_MASK | | ||
910 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK | | ||
911 | UVD_SOFT_RESET__LBSI_SOFT_RESET_MASK | | ||
912 | UVD_SOFT_RESET__RBC_SOFT_RESET_MASK | | ||
913 | UVD_SOFT_RESET__CSM_SOFT_RESET_MASK | | ||
914 | UVD_SOFT_RESET__CXW_SOFT_RESET_MASK | | ||
915 | UVD_SOFT_RESET__TAP_SOFT_RESET_MASK | | ||
916 | UVD_SOFT_RESET__LMI_UMC_SOFT_RESET_MASK); | ||
917 | mdelay(5); | ||
918 | 930 | ||
919 | /* initialize UVD memory controller */ | 931 | /* disable interupt */ |
920 | WREG32_SOC15(UVD, 0, mmUVD_LMI_CTRL, | 932 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_MASTINT_EN), 0, |
921 | (0x40 << UVD_LMI_CTRL__WRITE_CLEAN_TIMER__SHIFT) | | 933 | ~UVD_MASTINT_EN__VCPU_EN_MASK); |
922 | UVD_LMI_CTRL__WRITE_CLEAN_TIMER_EN_MASK | | 934 | |
923 | UVD_LMI_CTRL__DATA_COHERENCY_EN_MASK | | 935 | /* stall UMC and register bus before resetting VCPU */ |
924 | UVD_LMI_CTRL__VCPU_DATA_COHERENCY_EN_MASK | | 936 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_LMI_CTRL2), |
925 | UVD_LMI_CTRL__REQ_MODE_MASK | | 937 | UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, |
926 | 0x00100000L); | 938 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); |
939 | mdelay(1); | ||
940 | |||
941 | /* put LMI, VCPU, RBC etc... into reset */ | ||
942 | WREG32_SOC15(UVD, k, mmUVD_SOFT_RESET, | ||
943 | UVD_SOFT_RESET__LMI_SOFT_RESET_MASK | | ||
944 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK | | ||
945 | UVD_SOFT_RESET__LBSI_SOFT_RESET_MASK | | ||
946 | UVD_SOFT_RESET__RBC_SOFT_RESET_MASK | | ||
947 | UVD_SOFT_RESET__CSM_SOFT_RESET_MASK | | ||
948 | UVD_SOFT_RESET__CXW_SOFT_RESET_MASK | | ||
949 | UVD_SOFT_RESET__TAP_SOFT_RESET_MASK | | ||
950 | UVD_SOFT_RESET__LMI_UMC_SOFT_RESET_MASK); | ||
951 | mdelay(5); | ||
952 | |||
953 | /* initialize UVD memory controller */ | ||
954 | WREG32_SOC15(UVD, k, mmUVD_LMI_CTRL, | ||
955 | (0x40 << UVD_LMI_CTRL__WRITE_CLEAN_TIMER__SHIFT) | | ||
956 | UVD_LMI_CTRL__WRITE_CLEAN_TIMER_EN_MASK | | ||
957 | UVD_LMI_CTRL__DATA_COHERENCY_EN_MASK | | ||
958 | UVD_LMI_CTRL__VCPU_DATA_COHERENCY_EN_MASK | | ||
959 | UVD_LMI_CTRL__REQ_MODE_MASK | | ||
960 | 0x00100000L); | ||
927 | 961 | ||
928 | #ifdef __BIG_ENDIAN | 962 | #ifdef __BIG_ENDIAN |
929 | /* swap (8 in 32) RB and IB */ | 963 | /* swap (8 in 32) RB and IB */ |
930 | lmi_swap_cntl = 0xa; | 964 | lmi_swap_cntl = 0xa; |
931 | mp_swap_cntl = 0; | 965 | mp_swap_cntl = 0; |
932 | #endif | 966 | #endif |
933 | WREG32_SOC15(UVD, 0, mmUVD_LMI_SWAP_CNTL, lmi_swap_cntl); | 967 | WREG32_SOC15(UVD, k, mmUVD_LMI_SWAP_CNTL, lmi_swap_cntl); |
934 | WREG32_SOC15(UVD, 0, mmUVD_MP_SWAP_CNTL, mp_swap_cntl); | 968 | WREG32_SOC15(UVD, k, mmUVD_MP_SWAP_CNTL, mp_swap_cntl); |
935 | |||
936 | WREG32_SOC15(UVD, 0, mmUVD_MPC_SET_MUXA0, 0x40c2040); | ||
937 | WREG32_SOC15(UVD, 0, mmUVD_MPC_SET_MUXA1, 0x0); | ||
938 | WREG32_SOC15(UVD, 0, mmUVD_MPC_SET_MUXB0, 0x40c2040); | ||
939 | WREG32_SOC15(UVD, 0, mmUVD_MPC_SET_MUXB1, 0x0); | ||
940 | WREG32_SOC15(UVD, 0, mmUVD_MPC_SET_ALU, 0); | ||
941 | WREG32_SOC15(UVD, 0, mmUVD_MPC_SET_MUX, 0x88); | ||
942 | |||
943 | /* take all subblocks out of reset, except VCPU */ | ||
944 | WREG32_SOC15(UVD, 0, mmUVD_SOFT_RESET, | ||
945 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
946 | mdelay(5); | ||
947 | 969 | ||
948 | /* enable VCPU clock */ | 970 | WREG32_SOC15(UVD, k, mmUVD_MPC_SET_MUXA0, 0x40c2040); |
949 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CNTL, | 971 | WREG32_SOC15(UVD, k, mmUVD_MPC_SET_MUXA1, 0x0); |
950 | UVD_VCPU_CNTL__CLK_EN_MASK); | 972 | WREG32_SOC15(UVD, k, mmUVD_MPC_SET_MUXB0, 0x40c2040); |
973 | WREG32_SOC15(UVD, k, mmUVD_MPC_SET_MUXB1, 0x0); | ||
974 | WREG32_SOC15(UVD, k, mmUVD_MPC_SET_ALU, 0); | ||
975 | WREG32_SOC15(UVD, k, mmUVD_MPC_SET_MUX, 0x88); | ||
951 | 976 | ||
952 | /* enable UMC */ | 977 | /* take all subblocks out of reset, except VCPU */ |
953 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL2), 0, | 978 | WREG32_SOC15(UVD, k, mmUVD_SOFT_RESET, |
954 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | 979 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); |
980 | mdelay(5); | ||
981 | |||
982 | /* enable VCPU clock */ | ||
983 | WREG32_SOC15(UVD, k, mmUVD_VCPU_CNTL, | ||
984 | UVD_VCPU_CNTL__CLK_EN_MASK); | ||
985 | |||
986 | /* enable UMC */ | ||
987 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_LMI_CTRL2), 0, | ||
988 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | ||
955 | 989 | ||
956 | /* boot up the VCPU */ | 990 | /* boot up the VCPU */ |
957 | WREG32_SOC15(UVD, 0, mmUVD_SOFT_RESET, 0); | 991 | WREG32_SOC15(UVD, k, mmUVD_SOFT_RESET, 0); |
958 | mdelay(10); | 992 | mdelay(10); |
959 | 993 | ||
960 | for (i = 0; i < 10; ++i) { | 994 | for (i = 0; i < 10; ++i) { |
961 | uint32_t status; | 995 | uint32_t status; |
962 | 996 | ||
963 | for (j = 0; j < 100; ++j) { | 997 | for (j = 0; j < 100; ++j) { |
964 | status = RREG32_SOC15(UVD, 0, mmUVD_STATUS); | 998 | status = RREG32_SOC15(UVD, k, mmUVD_STATUS); |
999 | if (status & 2) | ||
1000 | break; | ||
1001 | mdelay(10); | ||
1002 | } | ||
1003 | r = 0; | ||
965 | if (status & 2) | 1004 | if (status & 2) |
966 | break; | 1005 | break; |
1006 | |||
1007 | DRM_ERROR("UVD(%d) not responding, trying to reset the VCPU!!!\n", k); | ||
1008 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_SOFT_RESET), | ||
1009 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK, | ||
1010 | ~UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
967 | mdelay(10); | 1011 | mdelay(10); |
1012 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_SOFT_RESET), 0, | ||
1013 | ~UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
1014 | mdelay(10); | ||
1015 | r = -1; | ||
968 | } | 1016 | } |
969 | r = 0; | ||
970 | if (status & 2) | ||
971 | break; | ||
972 | |||
973 | DRM_ERROR("UVD not responding, trying to reset the VCPU!!!\n"); | ||
974 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_SOFT_RESET), | ||
975 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK, | ||
976 | ~UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
977 | mdelay(10); | ||
978 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_SOFT_RESET), 0, | ||
979 | ~UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
980 | mdelay(10); | ||
981 | r = -1; | ||
982 | } | ||
983 | 1017 | ||
984 | if (r) { | 1018 | if (r) { |
985 | DRM_ERROR("UVD not responding, giving up!!!\n"); | 1019 | DRM_ERROR("UVD(%d) not responding, giving up!!!\n", k); |
986 | return r; | 1020 | return r; |
987 | } | 1021 | } |
988 | /* enable master interrupt */ | 1022 | /* enable master interrupt */ |
989 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_MASTINT_EN), | 1023 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_MASTINT_EN), |
990 | (UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK), | 1024 | (UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK), |
991 | ~(UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK)); | 1025 | ~(UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK)); |
992 | |||
993 | /* clear the bit 4 of UVD_STATUS */ | ||
994 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_STATUS), 0, | ||
995 | ~(2 << UVD_STATUS__VCPU_REPORT__SHIFT)); | ||
996 | |||
997 | /* force RBC into idle state */ | ||
998 | rb_bufsz = order_base_2(ring->ring_size); | ||
999 | tmp = REG_SET_FIELD(0, UVD_RBC_RB_CNTL, RB_BUFSZ, rb_bufsz); | ||
1000 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_BLKSZ, 1); | ||
1001 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_FETCH, 1); | ||
1002 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_WPTR_POLL_EN, 0); | ||
1003 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_UPDATE, 1); | ||
1004 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_RPTR_WR_EN, 1); | ||
1005 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_CNTL, tmp); | ||
1006 | |||
1007 | /* set the write pointer delay */ | ||
1008 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR_CNTL, 0); | ||
1009 | |||
1010 | /* set the wb address */ | ||
1011 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR_ADDR, | ||
1012 | (upper_32_bits(ring->gpu_addr) >> 2)); | ||
1013 | |||
1014 | /* programm the RB_BASE for ring buffer */ | ||
1015 | WREG32_SOC15(UVD, 0, mmUVD_LMI_RBC_RB_64BIT_BAR_LOW, | ||
1016 | lower_32_bits(ring->gpu_addr)); | ||
1017 | WREG32_SOC15(UVD, 0, mmUVD_LMI_RBC_RB_64BIT_BAR_HIGH, | ||
1018 | upper_32_bits(ring->gpu_addr)); | ||
1019 | |||
1020 | /* Initialize the ring buffer's read and write pointers */ | ||
1021 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR, 0); | ||
1022 | |||
1023 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); | ||
1024 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, | ||
1025 | lower_32_bits(ring->wptr)); | ||
1026 | |||
1027 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_RBC_RB_CNTL), 0, | ||
1028 | ~UVD_RBC_RB_CNTL__RB_NO_FETCH_MASK); | ||
1029 | |||
1030 | ring = &adev->uvd.ring_enc[0]; | ||
1031 | WREG32_SOC15(UVD, 0, mmUVD_RB_RPTR, lower_32_bits(ring->wptr)); | ||
1032 | WREG32_SOC15(UVD, 0, mmUVD_RB_WPTR, lower_32_bits(ring->wptr)); | ||
1033 | WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_LO, ring->gpu_addr); | ||
1034 | WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_HI, upper_32_bits(ring->gpu_addr)); | ||
1035 | WREG32_SOC15(UVD, 0, mmUVD_RB_SIZE, ring->ring_size / 4); | ||
1036 | 1026 | ||
1037 | ring = &adev->uvd.ring_enc[1]; | 1027 | /* clear the bit 4 of UVD_STATUS */ |
1038 | WREG32_SOC15(UVD, 0, mmUVD_RB_RPTR2, lower_32_bits(ring->wptr)); | 1028 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_STATUS), 0, |
1039 | WREG32_SOC15(UVD, 0, mmUVD_RB_WPTR2, lower_32_bits(ring->wptr)); | 1029 | ~(2 << UVD_STATUS__VCPU_REPORT__SHIFT)); |
1040 | WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_LO2, ring->gpu_addr); | ||
1041 | WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_HI2, upper_32_bits(ring->gpu_addr)); | ||
1042 | WREG32_SOC15(UVD, 0, mmUVD_RB_SIZE2, ring->ring_size / 4); | ||
1043 | 1030 | ||
1031 | /* force RBC into idle state */ | ||
1032 | rb_bufsz = order_base_2(ring->ring_size); | ||
1033 | tmp = REG_SET_FIELD(0, UVD_RBC_RB_CNTL, RB_BUFSZ, rb_bufsz); | ||
1034 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_BLKSZ, 1); | ||
1035 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_FETCH, 1); | ||
1036 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_WPTR_POLL_EN, 0); | ||
1037 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_UPDATE, 1); | ||
1038 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_RPTR_WR_EN, 1); | ||
1039 | WREG32_SOC15(UVD, k, mmUVD_RBC_RB_CNTL, tmp); | ||
1040 | |||
1041 | /* set the write pointer delay */ | ||
1042 | WREG32_SOC15(UVD, k, mmUVD_RBC_RB_WPTR_CNTL, 0); | ||
1043 | |||
1044 | /* set the wb address */ | ||
1045 | WREG32_SOC15(UVD, k, mmUVD_RBC_RB_RPTR_ADDR, | ||
1046 | (upper_32_bits(ring->gpu_addr) >> 2)); | ||
1047 | |||
1048 | /* programm the RB_BASE for ring buffer */ | ||
1049 | WREG32_SOC15(UVD, k, mmUVD_LMI_RBC_RB_64BIT_BAR_LOW, | ||
1050 | lower_32_bits(ring->gpu_addr)); | ||
1051 | WREG32_SOC15(UVD, k, mmUVD_LMI_RBC_RB_64BIT_BAR_HIGH, | ||
1052 | upper_32_bits(ring->gpu_addr)); | ||
1053 | |||
1054 | /* Initialize the ring buffer's read and write pointers */ | ||
1055 | WREG32_SOC15(UVD, k, mmUVD_RBC_RB_RPTR, 0); | ||
1056 | |||
1057 | ring->wptr = RREG32_SOC15(UVD, k, mmUVD_RBC_RB_RPTR); | ||
1058 | WREG32_SOC15(UVD, k, mmUVD_RBC_RB_WPTR, | ||
1059 | lower_32_bits(ring->wptr)); | ||
1060 | |||
1061 | WREG32_P(SOC15_REG_OFFSET(UVD, k, mmUVD_RBC_RB_CNTL), 0, | ||
1062 | ~UVD_RBC_RB_CNTL__RB_NO_FETCH_MASK); | ||
1063 | |||
1064 | ring = &adev->uvd.inst[k].ring_enc[0]; | ||
1065 | WREG32_SOC15(UVD, k, mmUVD_RB_RPTR, lower_32_bits(ring->wptr)); | ||
1066 | WREG32_SOC15(UVD, k, mmUVD_RB_WPTR, lower_32_bits(ring->wptr)); | ||
1067 | WREG32_SOC15(UVD, k, mmUVD_RB_BASE_LO, ring->gpu_addr); | ||
1068 | WREG32_SOC15(UVD, k, mmUVD_RB_BASE_HI, upper_32_bits(ring->gpu_addr)); | ||
1069 | WREG32_SOC15(UVD, k, mmUVD_RB_SIZE, ring->ring_size / 4); | ||
1070 | |||
1071 | ring = &adev->uvd.inst[k].ring_enc[1]; | ||
1072 | WREG32_SOC15(UVD, k, mmUVD_RB_RPTR2, lower_32_bits(ring->wptr)); | ||
1073 | WREG32_SOC15(UVD, k, mmUVD_RB_WPTR2, lower_32_bits(ring->wptr)); | ||
1074 | WREG32_SOC15(UVD, k, mmUVD_RB_BASE_LO2, ring->gpu_addr); | ||
1075 | WREG32_SOC15(UVD, k, mmUVD_RB_BASE_HI2, upper_32_bits(ring->gpu_addr)); | ||
1076 | WREG32_SOC15(UVD, k, mmUVD_RB_SIZE2, ring->ring_size / 4); | ||
1077 | } | ||
1044 | return 0; | 1078 | return 0; |
1045 | } | 1079 | } |
1046 | 1080 | ||
@@ -1053,26 +1087,30 @@ static int uvd_v7_0_start(struct amdgpu_device *adev) | |||
1053 | */ | 1087 | */ |
1054 | static void uvd_v7_0_stop(struct amdgpu_device *adev) | 1088 | static void uvd_v7_0_stop(struct amdgpu_device *adev) |
1055 | { | 1089 | { |
1056 | /* force RBC into idle state */ | 1090 | uint8_t i = 0; |
1057 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_CNTL, 0x11010101); | ||
1058 | |||
1059 | /* Stall UMC and register bus before resetting VCPU */ | ||
1060 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL2), | ||
1061 | UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, | ||
1062 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | ||
1063 | mdelay(1); | ||
1064 | |||
1065 | /* put VCPU into reset */ | ||
1066 | WREG32_SOC15(UVD, 0, mmUVD_SOFT_RESET, | ||
1067 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
1068 | mdelay(5); | ||
1069 | 1091 | ||
1070 | /* disable VCPU clock */ | 1092 | for (i = 0; i < adev->uvd.num_uvd_inst; ++i) { |
1071 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CNTL, 0x0); | 1093 | /* force RBC into idle state */ |
1094 | WREG32_SOC15(UVD, i, mmUVD_RBC_RB_CNTL, 0x11010101); | ||
1095 | |||
1096 | /* Stall UMC and register bus before resetting VCPU */ | ||
1097 | WREG32_P(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_CTRL2), | ||
1098 | UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, | ||
1099 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | ||
1100 | mdelay(1); | ||
1101 | |||
1102 | /* put VCPU into reset */ | ||
1103 | WREG32_SOC15(UVD, i, mmUVD_SOFT_RESET, | ||
1104 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK); | ||
1105 | mdelay(5); | ||
1072 | 1106 | ||
1073 | /* Unstall UMC and register bus */ | 1107 | /* disable VCPU clock */ |
1074 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL2), 0, | 1108 | WREG32_SOC15(UVD, i, mmUVD_VCPU_CNTL, 0x0); |
1075 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | 1109 | |
1110 | /* Unstall UMC and register bus */ | ||
1111 | WREG32_P(SOC15_REG_OFFSET(UVD, i, mmUVD_LMI_CTRL2), 0, | ||
1112 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | ||
1113 | } | ||
1076 | } | 1114 | } |
1077 | 1115 | ||
1078 | /** | 1116 | /** |
@@ -1091,26 +1129,26 @@ static void uvd_v7_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq | |||
1091 | WARN_ON(flags & AMDGPU_FENCE_FLAG_64BIT); | 1129 | WARN_ON(flags & AMDGPU_FENCE_FLAG_64BIT); |
1092 | 1130 | ||
1093 | amdgpu_ring_write(ring, | 1131 | amdgpu_ring_write(ring, |
1094 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_CONTEXT_ID), 0)); | 1132 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_CONTEXT_ID), 0)); |
1095 | amdgpu_ring_write(ring, seq); | 1133 | amdgpu_ring_write(ring, seq); |
1096 | amdgpu_ring_write(ring, | 1134 | amdgpu_ring_write(ring, |
1097 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 1135 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_DATA0), 0)); |
1098 | amdgpu_ring_write(ring, addr & 0xffffffff); | 1136 | amdgpu_ring_write(ring, addr & 0xffffffff); |
1099 | amdgpu_ring_write(ring, | 1137 | amdgpu_ring_write(ring, |
1100 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA1), 0)); | 1138 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_DATA1), 0)); |
1101 | amdgpu_ring_write(ring, upper_32_bits(addr) & 0xff); | 1139 | amdgpu_ring_write(ring, upper_32_bits(addr) & 0xff); |
1102 | amdgpu_ring_write(ring, | 1140 | amdgpu_ring_write(ring, |
1103 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_CMD), 0)); | 1141 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_CMD), 0)); |
1104 | amdgpu_ring_write(ring, 0); | 1142 | amdgpu_ring_write(ring, 0); |
1105 | 1143 | ||
1106 | amdgpu_ring_write(ring, | 1144 | amdgpu_ring_write(ring, |
1107 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 1145 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_DATA0), 0)); |
1108 | amdgpu_ring_write(ring, 0); | 1146 | amdgpu_ring_write(ring, 0); |
1109 | amdgpu_ring_write(ring, | 1147 | amdgpu_ring_write(ring, |
1110 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA1), 0)); | 1148 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_DATA1), 0)); |
1111 | amdgpu_ring_write(ring, 0); | 1149 | amdgpu_ring_write(ring, 0); |
1112 | amdgpu_ring_write(ring, | 1150 | amdgpu_ring_write(ring, |
1113 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_CMD), 0)); | 1151 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_CMD), 0)); |
1114 | amdgpu_ring_write(ring, 2); | 1152 | amdgpu_ring_write(ring, 2); |
1115 | } | 1153 | } |
1116 | 1154 | ||
@@ -1159,30 +1197,30 @@ static int uvd_v7_0_ring_test_ring(struct amdgpu_ring *ring) | |||
1159 | unsigned i; | 1197 | unsigned i; |
1160 | int r; | 1198 | int r; |
1161 | 1199 | ||
1162 | WREG32_SOC15(UVD, 0, mmUVD_CONTEXT_ID, 0xCAFEDEAD); | 1200 | WREG32_SOC15(UVD, ring->me, mmUVD_CONTEXT_ID, 0xCAFEDEAD); |
1163 | r = amdgpu_ring_alloc(ring, 3); | 1201 | r = amdgpu_ring_alloc(ring, 3); |
1164 | if (r) { | 1202 | if (r) { |
1165 | DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", | 1203 | DRM_ERROR("amdgpu: (%d)cp failed to lock ring %d (%d).\n", |
1166 | ring->idx, r); | 1204 | ring->me, ring->idx, r); |
1167 | return r; | 1205 | return r; |
1168 | } | 1206 | } |
1169 | amdgpu_ring_write(ring, | 1207 | amdgpu_ring_write(ring, |
1170 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_CONTEXT_ID), 0)); | 1208 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_CONTEXT_ID), 0)); |
1171 | amdgpu_ring_write(ring, 0xDEADBEEF); | 1209 | amdgpu_ring_write(ring, 0xDEADBEEF); |
1172 | amdgpu_ring_commit(ring); | 1210 | amdgpu_ring_commit(ring); |
1173 | for (i = 0; i < adev->usec_timeout; i++) { | 1211 | for (i = 0; i < adev->usec_timeout; i++) { |
1174 | tmp = RREG32_SOC15(UVD, 0, mmUVD_CONTEXT_ID); | 1212 | tmp = RREG32_SOC15(UVD, ring->me, mmUVD_CONTEXT_ID); |
1175 | if (tmp == 0xDEADBEEF) | 1213 | if (tmp == 0xDEADBEEF) |
1176 | break; | 1214 | break; |
1177 | DRM_UDELAY(1); | 1215 | DRM_UDELAY(1); |
1178 | } | 1216 | } |
1179 | 1217 | ||
1180 | if (i < adev->usec_timeout) { | 1218 | if (i < adev->usec_timeout) { |
1181 | DRM_DEBUG("ring test on %d succeeded in %d usecs\n", | 1219 | DRM_DEBUG("(%d)ring test on %d succeeded in %d usecs\n", |
1182 | ring->idx, i); | 1220 | ring->me, ring->idx, i); |
1183 | } else { | 1221 | } else { |
1184 | DRM_ERROR("amdgpu: ring %d test failed (0x%08X)\n", | 1222 | DRM_ERROR("(%d)amdgpu: ring %d test failed (0x%08X)\n", |
1185 | ring->idx, tmp); | 1223 | ring->me, ring->idx, tmp); |
1186 | r = -EINVAL; | 1224 | r = -EINVAL; |
1187 | } | 1225 | } |
1188 | return r; | 1226 | return r; |
@@ -1203,17 +1241,17 @@ static void uvd_v7_0_ring_emit_ib(struct amdgpu_ring *ring, | |||
1203 | struct amdgpu_device *adev = ring->adev; | 1241 | struct amdgpu_device *adev = ring->adev; |
1204 | 1242 | ||
1205 | amdgpu_ring_write(ring, | 1243 | amdgpu_ring_write(ring, |
1206 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_VMID), 0)); | 1244 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_LMI_RBC_IB_VMID), 0)); |
1207 | amdgpu_ring_write(ring, vmid); | 1245 | amdgpu_ring_write(ring, vmid); |
1208 | 1246 | ||
1209 | amdgpu_ring_write(ring, | 1247 | amdgpu_ring_write(ring, |
1210 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_64BIT_BAR_LOW), 0)); | 1248 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_LMI_RBC_IB_64BIT_BAR_LOW), 0)); |
1211 | amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); | 1249 | amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); |
1212 | amdgpu_ring_write(ring, | 1250 | amdgpu_ring_write(ring, |
1213 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_64BIT_BAR_HIGH), 0)); | 1251 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_LMI_RBC_IB_64BIT_BAR_HIGH), 0)); |
1214 | amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr)); | 1252 | amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr)); |
1215 | amdgpu_ring_write(ring, | 1253 | amdgpu_ring_write(ring, |
1216 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_RBC_IB_SIZE), 0)); | 1254 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_RBC_IB_SIZE), 0)); |
1217 | amdgpu_ring_write(ring, ib->length_dw); | 1255 | amdgpu_ring_write(ring, ib->length_dw); |
1218 | } | 1256 | } |
1219 | 1257 | ||
@@ -1241,13 +1279,13 @@ static void uvd_v7_0_ring_emit_wreg(struct amdgpu_ring *ring, | |||
1241 | struct amdgpu_device *adev = ring->adev; | 1279 | struct amdgpu_device *adev = ring->adev; |
1242 | 1280 | ||
1243 | amdgpu_ring_write(ring, | 1281 | amdgpu_ring_write(ring, |
1244 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 1282 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_DATA0), 0)); |
1245 | amdgpu_ring_write(ring, reg << 2); | 1283 | amdgpu_ring_write(ring, reg << 2); |
1246 | amdgpu_ring_write(ring, | 1284 | amdgpu_ring_write(ring, |
1247 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA1), 0)); | 1285 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_DATA1), 0)); |
1248 | amdgpu_ring_write(ring, val); | 1286 | amdgpu_ring_write(ring, val); |
1249 | amdgpu_ring_write(ring, | 1287 | amdgpu_ring_write(ring, |
1250 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_CMD), 0)); | 1288 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_CMD), 0)); |
1251 | amdgpu_ring_write(ring, 8); | 1289 | amdgpu_ring_write(ring, 8); |
1252 | } | 1290 | } |
1253 | 1291 | ||
@@ -1257,16 +1295,16 @@ static void uvd_v7_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, | |||
1257 | struct amdgpu_device *adev = ring->adev; | 1295 | struct amdgpu_device *adev = ring->adev; |
1258 | 1296 | ||
1259 | amdgpu_ring_write(ring, | 1297 | amdgpu_ring_write(ring, |
1260 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 1298 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_DATA0), 0)); |
1261 | amdgpu_ring_write(ring, reg << 2); | 1299 | amdgpu_ring_write(ring, reg << 2); |
1262 | amdgpu_ring_write(ring, | 1300 | amdgpu_ring_write(ring, |
1263 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA1), 0)); | 1301 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_DATA1), 0)); |
1264 | amdgpu_ring_write(ring, val); | 1302 | amdgpu_ring_write(ring, val); |
1265 | amdgpu_ring_write(ring, | 1303 | amdgpu_ring_write(ring, |
1266 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GP_SCRATCH8), 0)); | 1304 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GP_SCRATCH8), 0)); |
1267 | amdgpu_ring_write(ring, mask); | 1305 | amdgpu_ring_write(ring, mask); |
1268 | amdgpu_ring_write(ring, | 1306 | amdgpu_ring_write(ring, |
1269 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_CMD), 0)); | 1307 | PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_GPCOM_VCPU_CMD), 0)); |
1270 | amdgpu_ring_write(ring, 12); | 1308 | amdgpu_ring_write(ring, 12); |
1271 | } | 1309 | } |
1272 | 1310 | ||
@@ -1287,12 +1325,15 @@ static void uvd_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
1287 | 1325 | ||
1288 | static void uvd_v7_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) | 1326 | static void uvd_v7_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) |
1289 | { | 1327 | { |
1290 | int i; | ||
1291 | struct amdgpu_device *adev = ring->adev; | 1328 | struct amdgpu_device *adev = ring->adev; |
1329 | int i; | ||
1292 | 1330 | ||
1293 | for (i = 0; i < count; i++) | 1331 | WARN_ON(ring->wptr % 2 || count % 2); |
1294 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_NO_OP), 0)); | ||
1295 | 1332 | ||
1333 | for (i = 0; i < count / 2; i++) { | ||
1334 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, ring->me, mmUVD_NO_OP), 0)); | ||
1335 | amdgpu_ring_write(ring, 0); | ||
1336 | } | ||
1296 | } | 1337 | } |
1297 | 1338 | ||
1298 | static void uvd_v7_0_enc_ring_insert_end(struct amdgpu_ring *ring) | 1339 | static void uvd_v7_0_enc_ring_insert_end(struct amdgpu_ring *ring) |
@@ -1359,16 +1400,16 @@ static bool uvd_v7_0_check_soft_reset(void *handle) | |||
1359 | 1400 | ||
1360 | if (REG_GET_FIELD(tmp, SRBM_STATUS, UVD_RQ_PENDING) || | 1401 | if (REG_GET_FIELD(tmp, SRBM_STATUS, UVD_RQ_PENDING) || |
1361 | REG_GET_FIELD(tmp, SRBM_STATUS, UVD_BUSY) || | 1402 | REG_GET_FIELD(tmp, SRBM_STATUS, UVD_BUSY) || |
1362 | (RREG32_SOC15(UVD, 0, mmUVD_STATUS) & | 1403 | (RREG32_SOC15(UVD, ring->me, mmUVD_STATUS) & |
1363 | AMDGPU_UVD_STATUS_BUSY_MASK)) | 1404 | AMDGPU_UVD_STATUS_BUSY_MASK)) |
1364 | srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, | 1405 | srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, |
1365 | SRBM_SOFT_RESET, SOFT_RESET_UVD, 1); | 1406 | SRBM_SOFT_RESET, SOFT_RESET_UVD, 1); |
1366 | 1407 | ||
1367 | if (srbm_soft_reset) { | 1408 | if (srbm_soft_reset) { |
1368 | adev->uvd.srbm_soft_reset = srbm_soft_reset; | 1409 | adev->uvd.inst[ring->me].srbm_soft_reset = srbm_soft_reset; |
1369 | return true; | 1410 | return true; |
1370 | } else { | 1411 | } else { |
1371 | adev->uvd.srbm_soft_reset = 0; | 1412 | adev->uvd.inst[ring->me].srbm_soft_reset = 0; |
1372 | return false; | 1413 | return false; |
1373 | } | 1414 | } |
1374 | } | 1415 | } |
@@ -1377,7 +1418,7 @@ static int uvd_v7_0_pre_soft_reset(void *handle) | |||
1377 | { | 1418 | { |
1378 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1419 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1379 | 1420 | ||
1380 | if (!adev->uvd.srbm_soft_reset) | 1421 | if (!adev->uvd.inst[ring->me].srbm_soft_reset) |
1381 | return 0; | 1422 | return 0; |
1382 | 1423 | ||
1383 | uvd_v7_0_stop(adev); | 1424 | uvd_v7_0_stop(adev); |
@@ -1389,9 +1430,9 @@ static int uvd_v7_0_soft_reset(void *handle) | |||
1389 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1430 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1390 | u32 srbm_soft_reset; | 1431 | u32 srbm_soft_reset; |
1391 | 1432 | ||
1392 | if (!adev->uvd.srbm_soft_reset) | 1433 | if (!adev->uvd.inst[ring->me].srbm_soft_reset) |
1393 | return 0; | 1434 | return 0; |
1394 | srbm_soft_reset = adev->uvd.srbm_soft_reset; | 1435 | srbm_soft_reset = adev->uvd.inst[ring->me].srbm_soft_reset; |
1395 | 1436 | ||
1396 | if (srbm_soft_reset) { | 1437 | if (srbm_soft_reset) { |
1397 | u32 tmp; | 1438 | u32 tmp; |
@@ -1419,7 +1460,7 @@ static int uvd_v7_0_post_soft_reset(void *handle) | |||
1419 | { | 1460 | { |
1420 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1461 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1421 | 1462 | ||
1422 | if (!adev->uvd.srbm_soft_reset) | 1463 | if (!adev->uvd.inst[ring->me].srbm_soft_reset) |
1423 | return 0; | 1464 | return 0; |
1424 | 1465 | ||
1425 | mdelay(5); | 1466 | mdelay(5); |
@@ -1441,17 +1482,32 @@ static int uvd_v7_0_process_interrupt(struct amdgpu_device *adev, | |||
1441 | struct amdgpu_irq_src *source, | 1482 | struct amdgpu_irq_src *source, |
1442 | struct amdgpu_iv_entry *entry) | 1483 | struct amdgpu_iv_entry *entry) |
1443 | { | 1484 | { |
1485 | uint32_t ip_instance; | ||
1486 | |||
1487 | switch (entry->client_id) { | ||
1488 | case SOC15_IH_CLIENTID_UVD: | ||
1489 | ip_instance = 0; | ||
1490 | break; | ||
1491 | case SOC15_IH_CLIENTID_UVD1: | ||
1492 | ip_instance = 1; | ||
1493 | break; | ||
1494 | default: | ||
1495 | DRM_ERROR("Unhandled client id: %d\n", entry->client_id); | ||
1496 | return 0; | ||
1497 | } | ||
1498 | |||
1444 | DRM_DEBUG("IH: UVD TRAP\n"); | 1499 | DRM_DEBUG("IH: UVD TRAP\n"); |
1500 | |||
1445 | switch (entry->src_id) { | 1501 | switch (entry->src_id) { |
1446 | case 124: | 1502 | case 124: |
1447 | amdgpu_fence_process(&adev->uvd.ring); | 1503 | amdgpu_fence_process(&adev->uvd.inst[ip_instance].ring); |
1448 | break; | 1504 | break; |
1449 | case 119: | 1505 | case 119: |
1450 | amdgpu_fence_process(&adev->uvd.ring_enc[0]); | 1506 | amdgpu_fence_process(&adev->uvd.inst[ip_instance].ring_enc[0]); |
1451 | break; | 1507 | break; |
1452 | case 120: | 1508 | case 120: |
1453 | if (!amdgpu_sriov_vf(adev)) | 1509 | if (!amdgpu_sriov_vf(adev)) |
1454 | amdgpu_fence_process(&adev->uvd.ring_enc[1]); | 1510 | amdgpu_fence_process(&adev->uvd.inst[ip_instance].ring_enc[1]); |
1455 | break; | 1511 | break; |
1456 | default: | 1512 | default: |
1457 | DRM_ERROR("Unhandled interrupt: %d %d\n", | 1513 | DRM_ERROR("Unhandled interrupt: %d %d\n", |
@@ -1467,9 +1523,9 @@ static void uvd_v7_0_set_sw_clock_gating(struct amdgpu_device *adev) | |||
1467 | { | 1523 | { |
1468 | uint32_t data, data1, data2, suvd_flags; | 1524 | uint32_t data, data1, data2, suvd_flags; |
1469 | 1525 | ||
1470 | data = RREG32_SOC15(UVD, 0, mmUVD_CGC_CTRL); | 1526 | data = RREG32_SOC15(UVD, ring->me, mmUVD_CGC_CTRL); |
1471 | data1 = RREG32_SOC15(UVD, 0, mmUVD_SUVD_CGC_GATE); | 1527 | data1 = RREG32_SOC15(UVD, ring->me, mmUVD_SUVD_CGC_GATE); |
1472 | data2 = RREG32_SOC15(UVD, 0, mmUVD_SUVD_CGC_CTRL); | 1528 | data2 = RREG32_SOC15(UVD, ring->me, mmUVD_SUVD_CGC_CTRL); |
1473 | 1529 | ||
1474 | data &= ~(UVD_CGC_CTRL__CLK_OFF_DELAY_MASK | | 1530 | data &= ~(UVD_CGC_CTRL__CLK_OFF_DELAY_MASK | |
1475 | UVD_CGC_CTRL__CLK_GATE_DLY_TIMER_MASK); | 1531 | UVD_CGC_CTRL__CLK_GATE_DLY_TIMER_MASK); |
@@ -1513,18 +1569,18 @@ static void uvd_v7_0_set_sw_clock_gating(struct amdgpu_device *adev) | |||
1513 | UVD_SUVD_CGC_CTRL__SDB_MODE_MASK); | 1569 | UVD_SUVD_CGC_CTRL__SDB_MODE_MASK); |
1514 | data1 |= suvd_flags; | 1570 | data1 |= suvd_flags; |
1515 | 1571 | ||
1516 | WREG32_SOC15(UVD, 0, mmUVD_CGC_CTRL, data); | 1572 | WREG32_SOC15(UVD, ring->me, mmUVD_CGC_CTRL, data); |
1517 | WREG32_SOC15(UVD, 0, mmUVD_CGC_GATE, 0); | 1573 | WREG32_SOC15(UVD, ring->me, mmUVD_CGC_GATE, 0); |
1518 | WREG32_SOC15(UVD, 0, mmUVD_SUVD_CGC_GATE, data1); | 1574 | WREG32_SOC15(UVD, ring->me, mmUVD_SUVD_CGC_GATE, data1); |
1519 | WREG32_SOC15(UVD, 0, mmUVD_SUVD_CGC_CTRL, data2); | 1575 | WREG32_SOC15(UVD, ring->me, mmUVD_SUVD_CGC_CTRL, data2); |
1520 | } | 1576 | } |
1521 | 1577 | ||
1522 | static void uvd_v7_0_set_hw_clock_gating(struct amdgpu_device *adev) | 1578 | static void uvd_v7_0_set_hw_clock_gating(struct amdgpu_device *adev) |
1523 | { | 1579 | { |
1524 | uint32_t data, data1, cgc_flags, suvd_flags; | 1580 | uint32_t data, data1, cgc_flags, suvd_flags; |
1525 | 1581 | ||
1526 | data = RREG32_SOC15(UVD, 0, mmUVD_CGC_GATE); | 1582 | data = RREG32_SOC15(UVD, ring->me, mmUVD_CGC_GATE); |
1527 | data1 = RREG32_SOC15(UVD, 0, mmUVD_SUVD_CGC_GATE); | 1583 | data1 = RREG32_SOC15(UVD, ring->me, mmUVD_SUVD_CGC_GATE); |
1528 | 1584 | ||
1529 | cgc_flags = UVD_CGC_GATE__SYS_MASK | | 1585 | cgc_flags = UVD_CGC_GATE__SYS_MASK | |
1530 | UVD_CGC_GATE__UDEC_MASK | | 1586 | UVD_CGC_GATE__UDEC_MASK | |
@@ -1556,8 +1612,8 @@ static void uvd_v7_0_set_hw_clock_gating(struct amdgpu_device *adev) | |||
1556 | data |= cgc_flags; | 1612 | data |= cgc_flags; |
1557 | data1 |= suvd_flags; | 1613 | data1 |= suvd_flags; |
1558 | 1614 | ||
1559 | WREG32_SOC15(UVD, 0, mmUVD_CGC_GATE, data); | 1615 | WREG32_SOC15(UVD, ring->me, mmUVD_CGC_GATE, data); |
1560 | WREG32_SOC15(UVD, 0, mmUVD_SUVD_CGC_GATE, data1); | 1616 | WREG32_SOC15(UVD, ring->me, mmUVD_SUVD_CGC_GATE, data1); |
1561 | } | 1617 | } |
1562 | 1618 | ||
1563 | static void uvd_v7_0_set_bypass_mode(struct amdgpu_device *adev, bool enable) | 1619 | static void uvd_v7_0_set_bypass_mode(struct amdgpu_device *adev, bool enable) |
@@ -1616,7 +1672,7 @@ static int uvd_v7_0_set_powergating_state(void *handle, | |||
1616 | if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD)) | 1672 | if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD)) |
1617 | return 0; | 1673 | return 0; |
1618 | 1674 | ||
1619 | WREG32_SOC15(UVD, 0, mmUVD_POWER_STATUS, UVD_POWER_STATUS__UVD_PG_EN_MASK); | 1675 | WREG32_SOC15(UVD, ring->me, mmUVD_POWER_STATUS, UVD_POWER_STATUS__UVD_PG_EN_MASK); |
1620 | 1676 | ||
1621 | if (state == AMD_PG_STATE_GATE) { | 1677 | if (state == AMD_PG_STATE_GATE) { |
1622 | uvd_v7_0_stop(adev); | 1678 | uvd_v7_0_stop(adev); |
@@ -1657,7 +1713,6 @@ const struct amd_ip_funcs uvd_v7_0_ip_funcs = { | |||
1657 | static const struct amdgpu_ring_funcs uvd_v7_0_ring_vm_funcs = { | 1713 | static const struct amdgpu_ring_funcs uvd_v7_0_ring_vm_funcs = { |
1658 | .type = AMDGPU_RING_TYPE_UVD, | 1714 | .type = AMDGPU_RING_TYPE_UVD, |
1659 | .align_mask = 0xf, | 1715 | .align_mask = 0xf, |
1660 | .nop = PACKET0(0x81ff, 0), | ||
1661 | .support_64bit_ptrs = false, | 1716 | .support_64bit_ptrs = false, |
1662 | .vmhub = AMDGPU_MMHUB, | 1717 | .vmhub = AMDGPU_MMHUB, |
1663 | .get_rptr = uvd_v7_0_ring_get_rptr, | 1718 | .get_rptr = uvd_v7_0_ring_get_rptr, |
@@ -1719,18 +1774,27 @@ static const struct amdgpu_ring_funcs uvd_v7_0_enc_ring_vm_funcs = { | |||
1719 | 1774 | ||
1720 | static void uvd_v7_0_set_ring_funcs(struct amdgpu_device *adev) | 1775 | static void uvd_v7_0_set_ring_funcs(struct amdgpu_device *adev) |
1721 | { | 1776 | { |
1722 | adev->uvd.ring.funcs = &uvd_v7_0_ring_vm_funcs; | 1777 | int i; |
1723 | DRM_INFO("UVD is enabled in VM mode\n"); | 1778 | |
1779 | for (i = 0; i < adev->uvd.num_uvd_inst; i++) { | ||
1780 | adev->uvd.inst[i].ring.funcs = &uvd_v7_0_ring_vm_funcs; | ||
1781 | adev->uvd.inst[i].ring.me = i; | ||
1782 | DRM_INFO("UVD(%d) is enabled in VM mode\n", i); | ||
1783 | } | ||
1724 | } | 1784 | } |
1725 | 1785 | ||
1726 | static void uvd_v7_0_set_enc_ring_funcs(struct amdgpu_device *adev) | 1786 | static void uvd_v7_0_set_enc_ring_funcs(struct amdgpu_device *adev) |
1727 | { | 1787 | { |
1728 | int i; | 1788 | int i, j; |
1729 | 1789 | ||
1730 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) | 1790 | for (j = 0; j < adev->uvd.num_uvd_inst; j++) { |
1731 | adev->uvd.ring_enc[i].funcs = &uvd_v7_0_enc_ring_vm_funcs; | 1791 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { |
1792 | adev->uvd.inst[j].ring_enc[i].funcs = &uvd_v7_0_enc_ring_vm_funcs; | ||
1793 | adev->uvd.inst[j].ring_enc[i].me = j; | ||
1794 | } | ||
1732 | 1795 | ||
1733 | DRM_INFO("UVD ENC is enabled in VM mode\n"); | 1796 | DRM_INFO("UVD(%d) ENC is enabled in VM mode\n", j); |
1797 | } | ||
1734 | } | 1798 | } |
1735 | 1799 | ||
1736 | static const struct amdgpu_irq_src_funcs uvd_v7_0_irq_funcs = { | 1800 | static const struct amdgpu_irq_src_funcs uvd_v7_0_irq_funcs = { |
@@ -1740,8 +1804,12 @@ static const struct amdgpu_irq_src_funcs uvd_v7_0_irq_funcs = { | |||
1740 | 1804 | ||
1741 | static void uvd_v7_0_set_irq_funcs(struct amdgpu_device *adev) | 1805 | static void uvd_v7_0_set_irq_funcs(struct amdgpu_device *adev) |
1742 | { | 1806 | { |
1743 | adev->uvd.irq.num_types = adev->uvd.num_enc_rings + 1; | 1807 | int i; |
1744 | adev->uvd.irq.funcs = &uvd_v7_0_irq_funcs; | 1808 | |
1809 | for (i = 0; i < adev->uvd.num_uvd_inst; i++) { | ||
1810 | adev->uvd.inst[i].irq.num_types = adev->uvd.num_enc_rings + 1; | ||
1811 | adev->uvd.inst[i].irq.funcs = &uvd_v7_0_irq_funcs; | ||
1812 | } | ||
1745 | } | 1813 | } |
1746 | 1814 | ||
1747 | const struct amdgpu_ip_block_version uvd_v7_0_ip_block = | 1815 | const struct amdgpu_ip_block_version uvd_v7_0_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c index 0501746b6c2c..110b294ebed3 100644 --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include "mmhub/mmhub_9_1_offset.h" | 35 | #include "mmhub/mmhub_9_1_offset.h" |
36 | #include "mmhub/mmhub_9_1_sh_mask.h" | 36 | #include "mmhub/mmhub_9_1_sh_mask.h" |
37 | 37 | ||
38 | static int vcn_v1_0_start(struct amdgpu_device *adev); | ||
39 | static int vcn_v1_0_stop(struct amdgpu_device *adev); | 38 | static int vcn_v1_0_stop(struct amdgpu_device *adev); |
40 | static void vcn_v1_0_set_dec_ring_funcs(struct amdgpu_device *adev); | 39 | static void vcn_v1_0_set_dec_ring_funcs(struct amdgpu_device *adev); |
41 | static void vcn_v1_0_set_enc_ring_funcs(struct amdgpu_device *adev); | 40 | static void vcn_v1_0_set_enc_ring_funcs(struct amdgpu_device *adev); |
@@ -146,10 +145,6 @@ static int vcn_v1_0_hw_init(void *handle) | |||
146 | struct amdgpu_ring *ring = &adev->vcn.ring_dec; | 145 | struct amdgpu_ring *ring = &adev->vcn.ring_dec; |
147 | int i, r; | 146 | int i, r; |
148 | 147 | ||
149 | r = vcn_v1_0_start(adev); | ||
150 | if (r) | ||
151 | goto done; | ||
152 | |||
153 | ring->ready = true; | 148 | ring->ready = true; |
154 | r = amdgpu_ring_test_ring(ring); | 149 | r = amdgpu_ring_test_ring(ring); |
155 | if (r) { | 150 | if (r) { |
@@ -185,11 +180,9 @@ static int vcn_v1_0_hw_fini(void *handle) | |||
185 | { | 180 | { |
186 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 181 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
187 | struct amdgpu_ring *ring = &adev->vcn.ring_dec; | 182 | struct amdgpu_ring *ring = &adev->vcn.ring_dec; |
188 | int r; | ||
189 | 183 | ||
190 | r = vcn_v1_0_stop(adev); | 184 | if (RREG32_SOC15(VCN, 0, mmUVD_STATUS)) |
191 | if (r) | 185 | vcn_v1_0_stop(adev); |
192 | return r; | ||
193 | 186 | ||
194 | ring->ready = false; | 187 | ring->ready = false; |
195 | 188 | ||
@@ -288,14 +281,14 @@ static void vcn_v1_0_mc_resume(struct amdgpu_device *adev) | |||
288 | * | 281 | * |
289 | * Disable clock gating for VCN block | 282 | * Disable clock gating for VCN block |
290 | */ | 283 | */ |
291 | static void vcn_v1_0_disable_clock_gating(struct amdgpu_device *adev, bool sw) | 284 | static void vcn_v1_0_disable_clock_gating(struct amdgpu_device *adev) |
292 | { | 285 | { |
293 | uint32_t data; | 286 | uint32_t data; |
294 | 287 | ||
295 | /* JPEG disable CGC */ | 288 | /* JPEG disable CGC */ |
296 | data = RREG32_SOC15(VCN, 0, mmJPEG_CGC_CTRL); | 289 | data = RREG32_SOC15(VCN, 0, mmJPEG_CGC_CTRL); |
297 | 290 | ||
298 | if (sw) | 291 | if (adev->cg_flags & AMD_CG_SUPPORT_VCN_MGCG) |
299 | data |= 1 << JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | 292 | data |= 1 << JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; |
300 | else | 293 | else |
301 | data &= ~JPEG_CGC_CTRL__DYN_CLOCK_MODE_MASK; | 294 | data &= ~JPEG_CGC_CTRL__DYN_CLOCK_MODE_MASK; |
@@ -310,7 +303,7 @@ static void vcn_v1_0_disable_clock_gating(struct amdgpu_device *adev, bool sw) | |||
310 | 303 | ||
311 | /* UVD disable CGC */ | 304 | /* UVD disable CGC */ |
312 | data = RREG32_SOC15(VCN, 0, mmUVD_CGC_CTRL); | 305 | data = RREG32_SOC15(VCN, 0, mmUVD_CGC_CTRL); |
313 | if (sw) | 306 | if (adev->cg_flags & AMD_CG_SUPPORT_VCN_MGCG) |
314 | data |= 1 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | 307 | data |= 1 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; |
315 | else | 308 | else |
316 | data &= ~ UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK; | 309 | data &= ~ UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK; |
@@ -415,13 +408,13 @@ static void vcn_v1_0_disable_clock_gating(struct amdgpu_device *adev, bool sw) | |||
415 | * | 408 | * |
416 | * Enable clock gating for VCN block | 409 | * Enable clock gating for VCN block |
417 | */ | 410 | */ |
418 | static void vcn_v1_0_enable_clock_gating(struct amdgpu_device *adev, bool sw) | 411 | static void vcn_v1_0_enable_clock_gating(struct amdgpu_device *adev) |
419 | { | 412 | { |
420 | uint32_t data = 0; | 413 | uint32_t data = 0; |
421 | 414 | ||
422 | /* enable JPEG CGC */ | 415 | /* enable JPEG CGC */ |
423 | data = RREG32_SOC15(VCN, 0, mmJPEG_CGC_CTRL); | 416 | data = RREG32_SOC15(VCN, 0, mmJPEG_CGC_CTRL); |
424 | if (sw) | 417 | if (adev->cg_flags & AMD_CG_SUPPORT_VCN_MGCG) |
425 | data |= 1 << JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | 418 | data |= 1 << JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; |
426 | else | 419 | else |
427 | data |= 0 << JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | 420 | data |= 0 << JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; |
@@ -435,7 +428,7 @@ static void vcn_v1_0_enable_clock_gating(struct amdgpu_device *adev, bool sw) | |||
435 | 428 | ||
436 | /* enable UVD CGC */ | 429 | /* enable UVD CGC */ |
437 | data = RREG32_SOC15(VCN, 0, mmUVD_CGC_CTRL); | 430 | data = RREG32_SOC15(VCN, 0, mmUVD_CGC_CTRL); |
438 | if (sw) | 431 | if (adev->cg_flags & AMD_CG_SUPPORT_VCN_MGCG) |
439 | data |= 1 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | 432 | data |= 1 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; |
440 | else | 433 | else |
441 | data |= 0 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | 434 | data |= 0 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; |
@@ -480,6 +473,94 @@ static void vcn_v1_0_enable_clock_gating(struct amdgpu_device *adev, bool sw) | |||
480 | WREG32_SOC15(VCN, 0, mmUVD_SUVD_CGC_CTRL, data); | 473 | WREG32_SOC15(VCN, 0, mmUVD_SUVD_CGC_CTRL, data); |
481 | } | 474 | } |
482 | 475 | ||
476 | static void vcn_1_0_disable_static_power_gating(struct amdgpu_device *adev) | ||
477 | { | ||
478 | uint32_t data = 0; | ||
479 | int ret; | ||
480 | |||
481 | if (adev->pg_flags & AMD_PG_SUPPORT_VCN) { | ||
482 | data = (1 << UVD_PGFSM_CONFIG__UVDM_PWR_CONFIG__SHIFT | ||
483 | | 1 << UVD_PGFSM_CONFIG__UVDU_PWR_CONFIG__SHIFT | ||
484 | | 2 << UVD_PGFSM_CONFIG__UVDF_PWR_CONFIG__SHIFT | ||
485 | | 2 << UVD_PGFSM_CONFIG__UVDC_PWR_CONFIG__SHIFT | ||
486 | | 2 << UVD_PGFSM_CONFIG__UVDB_PWR_CONFIG__SHIFT | ||
487 | | 2 << UVD_PGFSM_CONFIG__UVDIL_PWR_CONFIG__SHIFT | ||
488 | | 2 << UVD_PGFSM_CONFIG__UVDIR_PWR_CONFIG__SHIFT | ||
489 | | 2 << UVD_PGFSM_CONFIG__UVDTD_PWR_CONFIG__SHIFT | ||
490 | | 2 << UVD_PGFSM_CONFIG__UVDTE_PWR_CONFIG__SHIFT | ||
491 | | 2 << UVD_PGFSM_CONFIG__UVDE_PWR_CONFIG__SHIFT | ||
492 | | 2 << UVD_PGFSM_CONFIG__UVDW_PWR_CONFIG__SHIFT); | ||
493 | |||
494 | WREG32_SOC15(VCN, 0, mmUVD_PGFSM_CONFIG, data); | ||
495 | SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_PGFSM_STATUS, UVD_PGFSM_STATUS__UVDM_UVDU_PWR_ON, 0xFFFFFF, ret); | ||
496 | } else { | ||
497 | data = (1 << UVD_PGFSM_CONFIG__UVDM_PWR_CONFIG__SHIFT | ||
498 | | 1 << UVD_PGFSM_CONFIG__UVDU_PWR_CONFIG__SHIFT | ||
499 | | 1 << UVD_PGFSM_CONFIG__UVDF_PWR_CONFIG__SHIFT | ||
500 | | 1 << UVD_PGFSM_CONFIG__UVDC_PWR_CONFIG__SHIFT | ||
501 | | 1 << UVD_PGFSM_CONFIG__UVDB_PWR_CONFIG__SHIFT | ||
502 | | 1 << UVD_PGFSM_CONFIG__UVDIL_PWR_CONFIG__SHIFT | ||
503 | | 1 << UVD_PGFSM_CONFIG__UVDIR_PWR_CONFIG__SHIFT | ||
504 | | 1 << UVD_PGFSM_CONFIG__UVDTD_PWR_CONFIG__SHIFT | ||
505 | | 1 << UVD_PGFSM_CONFIG__UVDTE_PWR_CONFIG__SHIFT | ||
506 | | 1 << UVD_PGFSM_CONFIG__UVDE_PWR_CONFIG__SHIFT | ||
507 | | 1 << UVD_PGFSM_CONFIG__UVDW_PWR_CONFIG__SHIFT); | ||
508 | WREG32_SOC15(VCN, 0, mmUVD_PGFSM_CONFIG, data); | ||
509 | SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_PGFSM_STATUS, 0, 0xFFFFFFFF, ret); | ||
510 | } | ||
511 | |||
512 | /* polling UVD_PGFSM_STATUS to confirm UVDM_PWR_STATUS , UVDU_PWR_STATUS are 0 (power on) */ | ||
513 | |||
514 | data = RREG32_SOC15(VCN, 0, mmUVD_POWER_STATUS); | ||
515 | data &= ~0x103; | ||
516 | if (adev->pg_flags & AMD_PG_SUPPORT_VCN) | ||
517 | data |= UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON | UVD_POWER_STATUS__UVD_PG_EN_MASK; | ||
518 | |||
519 | WREG32_SOC15(VCN, 0, mmUVD_POWER_STATUS, data); | ||
520 | } | ||
521 | |||
522 | static void vcn_1_0_enable_static_power_gating(struct amdgpu_device *adev) | ||
523 | { | ||
524 | uint32_t data = 0; | ||
525 | int ret; | ||
526 | |||
527 | if (adev->pg_flags & AMD_PG_SUPPORT_VCN) { | ||
528 | /* Before power off, this indicator has to be turned on */ | ||
529 | data = RREG32_SOC15(VCN, 0, mmUVD_POWER_STATUS); | ||
530 | data &= ~UVD_POWER_STATUS__UVD_POWER_STATUS_MASK; | ||
531 | data |= UVD_POWER_STATUS__UVD_POWER_STATUS_TILES_OFF; | ||
532 | WREG32_SOC15(VCN, 0, mmUVD_POWER_STATUS, data); | ||
533 | |||
534 | |||
535 | data = (2 << UVD_PGFSM_CONFIG__UVDM_PWR_CONFIG__SHIFT | ||
536 | | 2 << UVD_PGFSM_CONFIG__UVDU_PWR_CONFIG__SHIFT | ||
537 | | 2 << UVD_PGFSM_CONFIG__UVDF_PWR_CONFIG__SHIFT | ||
538 | | 2 << UVD_PGFSM_CONFIG__UVDC_PWR_CONFIG__SHIFT | ||
539 | | 2 << UVD_PGFSM_CONFIG__UVDB_PWR_CONFIG__SHIFT | ||
540 | | 2 << UVD_PGFSM_CONFIG__UVDIL_PWR_CONFIG__SHIFT | ||
541 | | 2 << UVD_PGFSM_CONFIG__UVDIR_PWR_CONFIG__SHIFT | ||
542 | | 2 << UVD_PGFSM_CONFIG__UVDTD_PWR_CONFIG__SHIFT | ||
543 | | 2 << UVD_PGFSM_CONFIG__UVDTE_PWR_CONFIG__SHIFT | ||
544 | | 2 << UVD_PGFSM_CONFIG__UVDE_PWR_CONFIG__SHIFT | ||
545 | | 2 << UVD_PGFSM_CONFIG__UVDW_PWR_CONFIG__SHIFT); | ||
546 | |||
547 | WREG32_SOC15(VCN, 0, mmUVD_PGFSM_CONFIG, data); | ||
548 | |||
549 | data = (2 << UVD_PGFSM_STATUS__UVDM_PWR_STATUS__SHIFT | ||
550 | | 2 << UVD_PGFSM_STATUS__UVDU_PWR_STATUS__SHIFT | ||
551 | | 2 << UVD_PGFSM_STATUS__UVDF_PWR_STATUS__SHIFT | ||
552 | | 2 << UVD_PGFSM_STATUS__UVDC_PWR_STATUS__SHIFT | ||
553 | | 2 << UVD_PGFSM_STATUS__UVDB_PWR_STATUS__SHIFT | ||
554 | | 2 << UVD_PGFSM_STATUS__UVDIL_PWR_STATUS__SHIFT | ||
555 | | 2 << UVD_PGFSM_STATUS__UVDIR_PWR_STATUS__SHIFT | ||
556 | | 2 << UVD_PGFSM_STATUS__UVDTD_PWR_STATUS__SHIFT | ||
557 | | 2 << UVD_PGFSM_STATUS__UVDTE_PWR_STATUS__SHIFT | ||
558 | | 2 << UVD_PGFSM_STATUS__UVDE_PWR_STATUS__SHIFT | ||
559 | | 2 << UVD_PGFSM_STATUS__UVDW_PWR_STATUS__SHIFT); | ||
560 | SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_PGFSM_STATUS, data, 0xFFFFFFFF, ret); | ||
561 | } | ||
562 | } | ||
563 | |||
483 | /** | 564 | /** |
484 | * vcn_v1_0_start - start VCN block | 565 | * vcn_v1_0_start - start VCN block |
485 | * | 566 | * |
@@ -499,8 +580,9 @@ static int vcn_v1_0_start(struct amdgpu_device *adev) | |||
499 | 580 | ||
500 | vcn_v1_0_mc_resume(adev); | 581 | vcn_v1_0_mc_resume(adev); |
501 | 582 | ||
583 | vcn_1_0_disable_static_power_gating(adev); | ||
502 | /* disable clock gating */ | 584 | /* disable clock gating */ |
503 | vcn_v1_0_disable_clock_gating(adev, true); | 585 | vcn_v1_0_disable_clock_gating(adev); |
504 | 586 | ||
505 | /* disable interupt */ | 587 | /* disable interupt */ |
506 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_MASTINT_EN), 0, | 588 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_MASTINT_EN), 0, |
@@ -680,16 +762,45 @@ static int vcn_v1_0_stop(struct amdgpu_device *adev) | |||
680 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL2), 0, | 762 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_CTRL2), 0, |
681 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); | 763 | ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK); |
682 | 764 | ||
683 | /* enable clock gating */ | 765 | WREG32_SOC15(VCN, 0, mmUVD_STATUS, 0); |
684 | vcn_v1_0_enable_clock_gating(adev, true); | ||
685 | 766 | ||
767 | vcn_v1_0_enable_clock_gating(adev); | ||
768 | vcn_1_0_enable_static_power_gating(adev); | ||
686 | return 0; | 769 | return 0; |
687 | } | 770 | } |
688 | 771 | ||
772 | bool vcn_v1_0_is_idle(void *handle) | ||
773 | { | ||
774 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
775 | |||
776 | return (RREG32_SOC15(VCN, 0, mmUVD_STATUS) == 0x2); | ||
777 | } | ||
778 | |||
779 | int vcn_v1_0_wait_for_idle(void *handle) | ||
780 | { | ||
781 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
782 | int ret = 0; | ||
783 | |||
784 | SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, 0x2, 0x2, ret); | ||
785 | |||
786 | return ret; | ||
787 | } | ||
788 | |||
689 | static int vcn_v1_0_set_clockgating_state(void *handle, | 789 | static int vcn_v1_0_set_clockgating_state(void *handle, |
690 | enum amd_clockgating_state state) | 790 | enum amd_clockgating_state state) |
691 | { | 791 | { |
692 | /* needed for driver unload*/ | 792 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
793 | bool enable = (state == AMD_CG_STATE_GATE) ? true : false; | ||
794 | |||
795 | if (enable) { | ||
796 | /* wait for STATUS to clear */ | ||
797 | if (vcn_v1_0_is_idle(handle)) | ||
798 | return -EBUSY; | ||
799 | vcn_v1_0_enable_clock_gating(adev); | ||
800 | } else { | ||
801 | /* disable HW gating and enable Sw gating */ | ||
802 | vcn_v1_0_disable_clock_gating(adev); | ||
803 | } | ||
693 | return 0; | 804 | return 0; |
694 | } | 805 | } |
695 | 806 | ||
@@ -1048,16 +1159,36 @@ static int vcn_v1_0_process_interrupt(struct amdgpu_device *adev, | |||
1048 | return 0; | 1159 | return 0; |
1049 | } | 1160 | } |
1050 | 1161 | ||
1051 | static void vcn_v1_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) | 1162 | static void vcn_v1_0_dec_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) |
1052 | { | 1163 | { |
1053 | int i; | ||
1054 | struct amdgpu_device *adev = ring->adev; | 1164 | struct amdgpu_device *adev = ring->adev; |
1165 | int i; | ||
1055 | 1166 | ||
1056 | for (i = 0; i < count; i++) | 1167 | WARN_ON(ring->wptr % 2 || count % 2); |
1057 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_NO_OP), 0)); | ||
1058 | 1168 | ||
1169 | for (i = 0; i < count / 2; i++) { | ||
1170 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_NO_OP), 0)); | ||
1171 | amdgpu_ring_write(ring, 0); | ||
1172 | } | ||
1059 | } | 1173 | } |
1060 | 1174 | ||
1175 | static int vcn_v1_0_set_powergating_state(void *handle, | ||
1176 | enum amd_powergating_state state) | ||
1177 | { | ||
1178 | /* This doesn't actually powergate the VCN block. | ||
1179 | * That's done in the dpm code via the SMC. This | ||
1180 | * just re-inits the block as necessary. The actual | ||
1181 | * gating still happens in the dpm code. We should | ||
1182 | * revisit this when there is a cleaner line between | ||
1183 | * the smc and the hw blocks | ||
1184 | */ | ||
1185 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
1186 | |||
1187 | if (state == AMD_PG_STATE_GATE) | ||
1188 | return vcn_v1_0_stop(adev); | ||
1189 | else | ||
1190 | return vcn_v1_0_start(adev); | ||
1191 | } | ||
1061 | 1192 | ||
1062 | static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { | 1193 | static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { |
1063 | .name = "vcn_v1_0", | 1194 | .name = "vcn_v1_0", |
@@ -1069,20 +1200,19 @@ static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { | |||
1069 | .hw_fini = vcn_v1_0_hw_fini, | 1200 | .hw_fini = vcn_v1_0_hw_fini, |
1070 | .suspend = vcn_v1_0_suspend, | 1201 | .suspend = vcn_v1_0_suspend, |
1071 | .resume = vcn_v1_0_resume, | 1202 | .resume = vcn_v1_0_resume, |
1072 | .is_idle = NULL /* vcn_v1_0_is_idle */, | 1203 | .is_idle = vcn_v1_0_is_idle, |
1073 | .wait_for_idle = NULL /* vcn_v1_0_wait_for_idle */, | 1204 | .wait_for_idle = vcn_v1_0_wait_for_idle, |
1074 | .check_soft_reset = NULL /* vcn_v1_0_check_soft_reset */, | 1205 | .check_soft_reset = NULL /* vcn_v1_0_check_soft_reset */, |
1075 | .pre_soft_reset = NULL /* vcn_v1_0_pre_soft_reset */, | 1206 | .pre_soft_reset = NULL /* vcn_v1_0_pre_soft_reset */, |
1076 | .soft_reset = NULL /* vcn_v1_0_soft_reset */, | 1207 | .soft_reset = NULL /* vcn_v1_0_soft_reset */, |
1077 | .post_soft_reset = NULL /* vcn_v1_0_post_soft_reset */, | 1208 | .post_soft_reset = NULL /* vcn_v1_0_post_soft_reset */, |
1078 | .set_clockgating_state = vcn_v1_0_set_clockgating_state, | 1209 | .set_clockgating_state = vcn_v1_0_set_clockgating_state, |
1079 | .set_powergating_state = NULL /* vcn_v1_0_set_powergating_state */, | 1210 | .set_powergating_state = vcn_v1_0_set_powergating_state, |
1080 | }; | 1211 | }; |
1081 | 1212 | ||
1082 | static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = { | 1213 | static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = { |
1083 | .type = AMDGPU_RING_TYPE_VCN_DEC, | 1214 | .type = AMDGPU_RING_TYPE_VCN_DEC, |
1084 | .align_mask = 0xf, | 1215 | .align_mask = 0xf, |
1085 | .nop = PACKET0(0x81ff, 0), | ||
1086 | .support_64bit_ptrs = false, | 1216 | .support_64bit_ptrs = false, |
1087 | .vmhub = AMDGPU_MMHUB, | 1217 | .vmhub = AMDGPU_MMHUB, |
1088 | .get_rptr = vcn_v1_0_dec_ring_get_rptr, | 1218 | .get_rptr = vcn_v1_0_dec_ring_get_rptr, |
@@ -1101,7 +1231,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = { | |||
1101 | .emit_vm_flush = vcn_v1_0_dec_ring_emit_vm_flush, | 1231 | .emit_vm_flush = vcn_v1_0_dec_ring_emit_vm_flush, |
1102 | .test_ring = amdgpu_vcn_dec_ring_test_ring, | 1232 | .test_ring = amdgpu_vcn_dec_ring_test_ring, |
1103 | .test_ib = amdgpu_vcn_dec_ring_test_ib, | 1233 | .test_ib = amdgpu_vcn_dec_ring_test_ib, |
1104 | .insert_nop = vcn_v1_0_ring_insert_nop, | 1234 | .insert_nop = vcn_v1_0_dec_ring_insert_nop, |
1105 | .insert_start = vcn_v1_0_dec_ring_insert_start, | 1235 | .insert_start = vcn_v1_0_dec_ring_insert_start, |
1106 | .insert_end = vcn_v1_0_dec_ring_insert_end, | 1236 | .insert_end = vcn_v1_0_dec_ring_insert_end, |
1107 | .pad_ib = amdgpu_ring_generic_pad_ib, | 1237 | .pad_ib = amdgpu_ring_generic_pad_ib, |
diff --git a/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c b/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c new file mode 100644 index 000000000000..52778de93ab0 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Copyright 2018 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 "soc15_hw_ip.h" | ||
28 | #include "vega20_ip_offset.h" | ||
29 | |||
30 | int vega20_reg_base_init(struct amdgpu_device *adev) | ||
31 | { | ||
32 | /* HW has more IP blocks, only initialized the blocke beend by our driver */ | ||
33 | uint32_t i; | ||
34 | for (i = 0 ; i < MAX_INSTANCE ; ++i) { | ||
35 | adev->reg_offset[GC_HWIP][i] = (uint32_t *)(&(GC_BASE.instance[i])); | ||
36 | adev->reg_offset[HDP_HWIP][i] = (uint32_t *)(&(HDP_BASE.instance[i])); | ||
37 | adev->reg_offset[MMHUB_HWIP][i] = (uint32_t *)(&(MMHUB_BASE.instance[i])); | ||
38 | adev->reg_offset[ATHUB_HWIP][i] = (uint32_t *)(&(ATHUB_BASE.instance[i])); | ||
39 | adev->reg_offset[NBIO_HWIP][i] = (uint32_t *)(&(NBIO_BASE.instance[i])); | ||
40 | adev->reg_offset[MP0_HWIP][i] = (uint32_t *)(&(MP0_BASE.instance[i])); | ||
41 | adev->reg_offset[UVD_HWIP][i] = (uint32_t *)(&(UVD_BASE.instance[i])); | ||
42 | adev->reg_offset[VCE_HWIP][i] = (uint32_t *)(&(VCE_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 | } | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | |||
diff --git a/drivers/gpu/drm/amd/display/Kconfig b/drivers/gpu/drm/amd/display/Kconfig index e6ca72c0d347..d5d4586e6176 100644 --- a/drivers/gpu/drm/amd/display/Kconfig +++ b/drivers/gpu/drm/amd/display/Kconfig | |||
@@ -34,10 +34,4 @@ config DEBUG_KERNEL_DC | |||
34 | if you want to hit | 34 | if you want to hit |
35 | kdgb_break in assert. | 35 | kdgb_break in assert. |
36 | 36 | ||
37 | config DRM_AMD_DC_VEGAM | ||
38 | bool "VEGAM support" | ||
39 | depends on DRM_AMD_DC | ||
40 | help | ||
41 | Choose this option if you want to have | ||
42 | VEGAM support for display engine | ||
43 | endmenu | 37 | endmenu |
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 f2f54a9df56f..1ce10bc2d37b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |||
@@ -911,6 +911,7 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector) | |||
911 | drm_mode_connector_update_edid_property(connector, NULL); | 911 | drm_mode_connector_update_edid_property(connector, NULL); |
912 | aconnector->num_modes = 0; | 912 | aconnector->num_modes = 0; |
913 | aconnector->dc_sink = NULL; | 913 | aconnector->dc_sink = NULL; |
914 | aconnector->edid = NULL; | ||
914 | } | 915 | } |
915 | 916 | ||
916 | mutex_unlock(&dev->mode_config.mutex); | 917 | mutex_unlock(&dev->mode_config.mutex); |
@@ -1115,6 +1116,7 @@ static int dce110_register_irq_handlers(struct amdgpu_device *adev) | |||
1115 | 1116 | ||
1116 | if (adev->asic_type == CHIP_VEGA10 || | 1117 | if (adev->asic_type == CHIP_VEGA10 || |
1117 | adev->asic_type == CHIP_VEGA12 || | 1118 | adev->asic_type == CHIP_VEGA12 || |
1119 | adev->asic_type == CHIP_VEGA20 || | ||
1118 | adev->asic_type == CHIP_RAVEN) | 1120 | adev->asic_type == CHIP_RAVEN) |
1119 | client_id = SOC15_IH_CLIENTID_DCE; | 1121 | client_id = SOC15_IH_CLIENTID_DCE; |
1120 | 1122 | ||
@@ -1513,11 +1515,10 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) | |||
1513 | case CHIP_POLARIS11: | 1515 | case CHIP_POLARIS11: |
1514 | case CHIP_POLARIS10: | 1516 | case CHIP_POLARIS10: |
1515 | case CHIP_POLARIS12: | 1517 | case CHIP_POLARIS12: |
1516 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
1517 | case CHIP_VEGAM: | 1518 | case CHIP_VEGAM: |
1518 | #endif | ||
1519 | case CHIP_VEGA10: | 1519 | case CHIP_VEGA10: |
1520 | case CHIP_VEGA12: | 1520 | case CHIP_VEGA12: |
1521 | case CHIP_VEGA20: | ||
1521 | if (dce110_register_irq_handlers(dm->adev)) { | 1522 | if (dce110_register_irq_handlers(dm->adev)) { |
1522 | DRM_ERROR("DM: Failed to initialize IRQ\n"); | 1523 | DRM_ERROR("DM: Failed to initialize IRQ\n"); |
1523 | goto fail; | 1524 | goto fail; |
@@ -1708,9 +1709,7 @@ static int dm_early_init(void *handle) | |||
1708 | adev->mode_info.plane_type = dm_plane_type_default; | 1709 | adev->mode_info.plane_type = dm_plane_type_default; |
1709 | break; | 1710 | break; |
1710 | case CHIP_POLARIS10: | 1711 | case CHIP_POLARIS10: |
1711 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
1712 | case CHIP_VEGAM: | 1712 | case CHIP_VEGAM: |
1713 | #endif | ||
1714 | adev->mode_info.num_crtc = 6; | 1713 | adev->mode_info.num_crtc = 6; |
1715 | adev->mode_info.num_hpd = 6; | 1714 | adev->mode_info.num_hpd = 6; |
1716 | adev->mode_info.num_dig = 6; | 1715 | adev->mode_info.num_dig = 6; |
@@ -1718,6 +1717,7 @@ static int dm_early_init(void *handle) | |||
1718 | break; | 1717 | break; |
1719 | case CHIP_VEGA10: | 1718 | case CHIP_VEGA10: |
1720 | case CHIP_VEGA12: | 1719 | case CHIP_VEGA12: |
1720 | case CHIP_VEGA20: | ||
1721 | adev->mode_info.num_crtc = 6; | 1721 | adev->mode_info.num_crtc = 6; |
1722 | adev->mode_info.num_hpd = 6; | 1722 | adev->mode_info.num_hpd = 6; |
1723 | adev->mode_info.num_dig = 6; | 1723 | adev->mode_info.num_dig = 6; |
@@ -1966,6 +1966,7 @@ static int fill_plane_attributes_from_fb(struct amdgpu_device *adev, | |||
1966 | 1966 | ||
1967 | if (adev->asic_type == CHIP_VEGA10 || | 1967 | if (adev->asic_type == CHIP_VEGA10 || |
1968 | adev->asic_type == CHIP_VEGA12 || | 1968 | adev->asic_type == CHIP_VEGA12 || |
1969 | adev->asic_type == CHIP_VEGA20 || | ||
1969 | adev->asic_type == CHIP_RAVEN) { | 1970 | adev->asic_type == CHIP_RAVEN) { |
1970 | /* Fill GFX9 params */ | 1971 | /* Fill GFX9 params */ |
1971 | plane_state->tiling_info.gfx9.num_pipes = | 1972 | plane_state->tiling_info.gfx9.num_pipes = |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c index e3d90e918d1b..b329393307e5 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | |||
@@ -88,9 +88,9 @@ static void __drm_lut_to_dc_gamma(struct drm_color_lut *lut, | |||
88 | g = drm_color_lut_extract(lut[i].green, 16); | 88 | g = drm_color_lut_extract(lut[i].green, 16); |
89 | b = drm_color_lut_extract(lut[i].blue, 16); | 89 | b = drm_color_lut_extract(lut[i].blue, 16); |
90 | 90 | ||
91 | gamma->entries.red[i] = dal_fixed31_32_from_int(r); | 91 | gamma->entries.red[i] = dc_fixpt_from_int(r); |
92 | gamma->entries.green[i] = dal_fixed31_32_from_int(g); | 92 | gamma->entries.green[i] = dc_fixpt_from_int(g); |
93 | gamma->entries.blue[i] = dal_fixed31_32_from_int(b); | 93 | gamma->entries.blue[i] = dc_fixpt_from_int(b); |
94 | } | 94 | } |
95 | return; | 95 | return; |
96 | } | 96 | } |
@@ -101,9 +101,9 @@ static void __drm_lut_to_dc_gamma(struct drm_color_lut *lut, | |||
101 | g = drm_color_lut_extract(lut[i].green, 16); | 101 | g = drm_color_lut_extract(lut[i].green, 16); |
102 | b = drm_color_lut_extract(lut[i].blue, 16); | 102 | b = drm_color_lut_extract(lut[i].blue, 16); |
103 | 103 | ||
104 | gamma->entries.red[i] = dal_fixed31_32_from_fraction(r, MAX_DRM_LUT_VALUE); | 104 | gamma->entries.red[i] = dc_fixpt_from_fraction(r, MAX_DRM_LUT_VALUE); |
105 | gamma->entries.green[i] = dal_fixed31_32_from_fraction(g, MAX_DRM_LUT_VALUE); | 105 | gamma->entries.green[i] = dc_fixpt_from_fraction(g, MAX_DRM_LUT_VALUE); |
106 | gamma->entries.blue[i] = dal_fixed31_32_from_fraction(b, MAX_DRM_LUT_VALUE); | 106 | gamma->entries.blue[i] = dc_fixpt_from_fraction(b, MAX_DRM_LUT_VALUE); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
@@ -208,7 +208,7 @@ void amdgpu_dm_set_ctm(struct dm_crtc_state *crtc) | |||
208 | for (i = 0; i < 12; i++) { | 208 | for (i = 0; i < 12; i++) { |
209 | /* Skip 4th element */ | 209 | /* Skip 4th element */ |
210 | if (i % 4 == 3) { | 210 | if (i % 4 == 3) { |
211 | stream->gamut_remap_matrix.matrix[i] = dal_fixed31_32_zero; | 211 | stream->gamut_remap_matrix.matrix[i] = dc_fixpt_zero; |
212 | continue; | 212 | continue; |
213 | } | 213 | } |
214 | 214 | ||
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index ca0b08bfa2cf..bd449351803f 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | |||
@@ -330,11 +330,6 @@ bool dm_helpers_dp_mst_send_payload_allocation( | |||
330 | return true; | 330 | return true; |
331 | } | 331 | } |
332 | 332 | ||
333 | bool dm_helpers_dc_conn_log(struct dc_context *ctx, struct log_entry *entry, enum dc_log_type event) | ||
334 | { | ||
335 | return true; | ||
336 | } | ||
337 | |||
338 | void dm_dtn_log_begin(struct dc_context *ctx) | 333 | void dm_dtn_log_begin(struct dc_context *ctx) |
339 | {} | 334 | {} |
340 | 335 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/basics/Makefile b/drivers/gpu/drm/amd/display/dc/basics/Makefile index bca33bd9a0d2..b49ea96b5dae 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 \ | 27 | BASICS = conversion.o fixpt31_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 310964915a83..50b47f11875c 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/conversion.c +++ b/drivers/gpu/drm/amd/display/dc/basics/conversion.c | |||
@@ -41,22 +41,22 @@ uint16_t fixed_point_to_int_frac( | |||
41 | 41 | ||
42 | uint16_t result; | 42 | uint16_t result; |
43 | 43 | ||
44 | uint16_t d = (uint16_t)dal_fixed31_32_floor( | 44 | uint16_t d = (uint16_t)dc_fixpt_floor( |
45 | dal_fixed31_32_abs( | 45 | dc_fixpt_abs( |
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_round( | 49 | numerator = (uint16_t)dc_fixpt_round( |
50 | dal_fixed31_32_mul_int( | 50 | dc_fixpt_mul_int( |
51 | arg, | 51 | arg, |
52 | divisor)); | 52 | divisor)); |
53 | else { | 53 | else { |
54 | numerator = dal_fixed31_32_floor( | 54 | numerator = dc_fixpt_floor( |
55 | dal_fixed31_32_sub( | 55 | dc_fixpt_sub( |
56 | dal_fixed31_32_from_int( | 56 | dc_fixpt_from_int( |
57 | 1LL << integer_bits), | 57 | 1LL << integer_bits), |
58 | dal_fixed31_32_recip( | 58 | dc_fixpt_recip( |
59 | dal_fixed31_32_from_int( | 59 | dc_fixpt_from_int( |
60 | divisor)))); | 60 | divisor)))); |
61 | } | 61 | } |
62 | 62 | ||
@@ -66,8 +66,8 @@ uint16_t fixed_point_to_int_frac( | |||
66 | result = (uint16_t)( | 66 | result = (uint16_t)( |
67 | (1 << (integer_bits + fractional_bits + 1)) + numerator); | 67 | (1 << (integer_bits + fractional_bits + 1)) + numerator); |
68 | 68 | ||
69 | if ((result != 0) && dal_fixed31_32_lt( | 69 | if ((result != 0) && dc_fixpt_lt( |
70 | arg, dal_fixed31_32_zero)) | 70 | arg, dc_fixpt_zero)) |
71 | result |= 1 << (integer_bits + fractional_bits); | 71 | result |= 1 << (integer_bits + fractional_bits); |
72 | 72 | ||
73 | return result; | 73 | return result; |
@@ -84,15 +84,15 @@ void convert_float_matrix( | |||
84 | uint32_t buffer_size) | 84 | uint32_t buffer_size) |
85 | { | 85 | { |
86 | const struct fixed31_32 min_2_13 = | 86 | const struct fixed31_32 min_2_13 = |
87 | dal_fixed31_32_from_fraction(S2D13_MIN, DIVIDER); | 87 | dc_fixpt_from_fraction(S2D13_MIN, DIVIDER); |
88 | const struct fixed31_32 max_2_13 = | 88 | const struct fixed31_32 max_2_13 = |
89 | dal_fixed31_32_from_fraction(S2D13_MAX, DIVIDER); | 89 | dc_fixpt_from_fraction(S2D13_MAX, DIVIDER); |
90 | uint32_t i; | 90 | uint32_t i; |
91 | 91 | ||
92 | for (i = 0; i < buffer_size; ++i) { | 92 | for (i = 0; i < buffer_size; ++i) { |
93 | uint32_t reg_value = | 93 | uint32_t reg_value = |
94 | fixed_point_to_int_frac( | 94 | fixed_point_to_int_frac( |
95 | dal_fixed31_32_clamp( | 95 | dc_fixpt_clamp( |
96 | flt[i], | 96 | flt[i], |
97 | min_2_13, | 97 | min_2_13, |
98 | max_2_13), | 98 | max_2_13), |
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 7191c3213743..e61dd97d0928 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c +++ b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c | |||
@@ -64,9 +64,7 @@ static inline unsigned long long complete_integer_division_u64( | |||
64 | #define GET_FRACTIONAL_PART(x) \ | 64 | #define GET_FRACTIONAL_PART(x) \ |
65 | (FRACTIONAL_PART_MASK & (x)) | 65 | (FRACTIONAL_PART_MASK & (x)) |
66 | 66 | ||
67 | struct fixed31_32 dal_fixed31_32_from_fraction( | 67 | struct fixed31_32 dc_fixpt_from_fraction(long long numerator, long long denominator) |
68 | long long numerator, | ||
69 | long long denominator) | ||
70 | { | 68 | { |
71 | struct fixed31_32 res; | 69 | struct fixed31_32 res; |
72 | 70 | ||
@@ -118,63 +116,7 @@ struct fixed31_32 dal_fixed31_32_from_fraction( | |||
118 | return res; | 116 | return res; |
119 | } | 117 | } |
120 | 118 | ||
121 | struct fixed31_32 dal_fixed31_32_from_int_nonconst( | 119 | struct fixed31_32 dc_fixpt_mul(struct fixed31_32 arg1, struct fixed31_32 arg2) |
122 | long long arg) | ||
123 | { | ||
124 | struct fixed31_32 res; | ||
125 | |||
126 | ASSERT((LONG_MIN <= arg) && (arg <= LONG_MAX)); | ||
127 | |||
128 | res.value = arg << FIXED31_32_BITS_PER_FRACTIONAL_PART; | ||
129 | |||
130 | return res; | ||
131 | } | ||
132 | |||
133 | struct fixed31_32 dal_fixed31_32_shl( | ||
134 | struct fixed31_32 arg, | ||
135 | unsigned char shift) | ||
136 | { | ||
137 | struct fixed31_32 res; | ||
138 | |||
139 | ASSERT(((arg.value >= 0) && (arg.value <= LLONG_MAX >> shift)) || | ||
140 | ((arg.value < 0) && (arg.value >= LLONG_MIN >> shift))); | ||
141 | |||
142 | res.value = arg.value << shift; | ||
143 | |||
144 | return res; | ||
145 | } | ||
146 | |||
147 | struct fixed31_32 dal_fixed31_32_add( | ||
148 | struct fixed31_32 arg1, | ||
149 | struct fixed31_32 arg2) | ||
150 | { | ||
151 | struct fixed31_32 res; | ||
152 | |||
153 | ASSERT(((arg1.value >= 0) && (LLONG_MAX - arg1.value >= arg2.value)) || | ||
154 | ((arg1.value < 0) && (LLONG_MIN - arg1.value <= arg2.value))); | ||
155 | |||
156 | res.value = arg1.value + arg2.value; | ||
157 | |||
158 | return res; | ||
159 | } | ||
160 | |||
161 | struct fixed31_32 dal_fixed31_32_sub( | ||
162 | struct fixed31_32 arg1, | ||
163 | struct fixed31_32 arg2) | ||
164 | { | ||
165 | struct fixed31_32 res; | ||
166 | |||
167 | ASSERT(((arg2.value >= 0) && (LLONG_MIN + arg2.value <= arg1.value)) || | ||
168 | ((arg2.value < 0) && (LLONG_MAX + arg2.value >= arg1.value))); | ||
169 | |||
170 | res.value = arg1.value - arg2.value; | ||
171 | |||
172 | return res; | ||
173 | } | ||
174 | |||
175 | struct fixed31_32 dal_fixed31_32_mul( | ||
176 | struct fixed31_32 arg1, | ||
177 | struct fixed31_32 arg2) | ||
178 | { | 120 | { |
179 | struct fixed31_32 res; | 121 | struct fixed31_32 res; |
180 | 122 | ||
@@ -213,7 +155,7 @@ struct fixed31_32 dal_fixed31_32_mul( | |||
213 | tmp = arg1_fra * arg2_fra; | 155 | tmp = arg1_fra * arg2_fra; |
214 | 156 | ||
215 | tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) + | 157 | tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) + |
216 | (tmp >= (unsigned long long)dal_fixed31_32_half.value); | 158 | (tmp >= (unsigned long long)dc_fixpt_half.value); |
217 | 159 | ||
218 | ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); | 160 | ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); |
219 | 161 | ||
@@ -225,8 +167,7 @@ struct fixed31_32 dal_fixed31_32_mul( | |||
225 | return res; | 167 | return res; |
226 | } | 168 | } |
227 | 169 | ||
228 | struct fixed31_32 dal_fixed31_32_sqr( | 170 | struct fixed31_32 dc_fixpt_sqr(struct fixed31_32 arg) |
229 | struct fixed31_32 arg) | ||
230 | { | 171 | { |
231 | struct fixed31_32 res; | 172 | struct fixed31_32 res; |
232 | 173 | ||
@@ -257,7 +198,7 @@ struct fixed31_32 dal_fixed31_32_sqr( | |||
257 | tmp = arg_fra * arg_fra; | 198 | tmp = arg_fra * arg_fra; |
258 | 199 | ||
259 | tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) + | 200 | tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) + |
260 | (tmp >= (unsigned long long)dal_fixed31_32_half.value); | 201 | (tmp >= (unsigned long long)dc_fixpt_half.value); |
261 | 202 | ||
262 | ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); | 203 | ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); |
263 | 204 | ||
@@ -266,8 +207,7 @@ struct fixed31_32 dal_fixed31_32_sqr( | |||
266 | return res; | 207 | return res; |
267 | } | 208 | } |
268 | 209 | ||
269 | struct fixed31_32 dal_fixed31_32_recip( | 210 | struct fixed31_32 dc_fixpt_recip(struct fixed31_32 arg) |
270 | struct fixed31_32 arg) | ||
271 | { | 211 | { |
272 | /* | 212 | /* |
273 | * @note | 213 | * @note |
@@ -276,41 +216,40 @@ struct fixed31_32 dal_fixed31_32_recip( | |||
276 | 216 | ||
277 | ASSERT(arg.value); | 217 | ASSERT(arg.value); |
278 | 218 | ||
279 | return dal_fixed31_32_from_fraction( | 219 | return dc_fixpt_from_fraction( |
280 | dal_fixed31_32_one.value, | 220 | dc_fixpt_one.value, |
281 | arg.value); | 221 | arg.value); |
282 | } | 222 | } |
283 | 223 | ||
284 | struct fixed31_32 dal_fixed31_32_sinc( | 224 | struct fixed31_32 dc_fixpt_sinc(struct fixed31_32 arg) |
285 | struct fixed31_32 arg) | ||
286 | { | 225 | { |
287 | struct fixed31_32 square; | 226 | struct fixed31_32 square; |
288 | 227 | ||
289 | struct fixed31_32 res = dal_fixed31_32_one; | 228 | struct fixed31_32 res = dc_fixpt_one; |
290 | 229 | ||
291 | int n = 27; | 230 | int n = 27; |
292 | 231 | ||
293 | struct fixed31_32 arg_norm = arg; | 232 | struct fixed31_32 arg_norm = arg; |
294 | 233 | ||
295 | if (dal_fixed31_32_le( | 234 | if (dc_fixpt_le( |
296 | dal_fixed31_32_two_pi, | 235 | dc_fixpt_two_pi, |
297 | dal_fixed31_32_abs(arg))) { | 236 | dc_fixpt_abs(arg))) { |
298 | arg_norm = dal_fixed31_32_sub( | 237 | arg_norm = dc_fixpt_sub( |
299 | arg_norm, | 238 | arg_norm, |
300 | dal_fixed31_32_mul_int( | 239 | dc_fixpt_mul_int( |
301 | dal_fixed31_32_two_pi, | 240 | dc_fixpt_two_pi, |
302 | (int)div64_s64( | 241 | (int)div64_s64( |
303 | arg_norm.value, | 242 | arg_norm.value, |
304 | dal_fixed31_32_two_pi.value))); | 243 | dc_fixpt_two_pi.value))); |
305 | } | 244 | } |
306 | 245 | ||
307 | square = dal_fixed31_32_sqr(arg_norm); | 246 | square = dc_fixpt_sqr(arg_norm); |
308 | 247 | ||
309 | do { | 248 | do { |
310 | res = dal_fixed31_32_sub( | 249 | res = dc_fixpt_sub( |
311 | dal_fixed31_32_one, | 250 | dc_fixpt_one, |
312 | dal_fixed31_32_div_int( | 251 | dc_fixpt_div_int( |
313 | dal_fixed31_32_mul( | 252 | dc_fixpt_mul( |
314 | square, | 253 | square, |
315 | res), | 254 | res), |
316 | n * (n - 1))); | 255 | n * (n - 1))); |
@@ -319,37 +258,35 @@ struct fixed31_32 dal_fixed31_32_sinc( | |||
319 | } while (n > 2); | 258 | } while (n > 2); |
320 | 259 | ||
321 | if (arg.value != arg_norm.value) | 260 | if (arg.value != arg_norm.value) |
322 | res = dal_fixed31_32_div( | 261 | res = dc_fixpt_div( |
323 | dal_fixed31_32_mul(res, arg_norm), | 262 | dc_fixpt_mul(res, arg_norm), |
324 | arg); | 263 | arg); |
325 | 264 | ||
326 | return res; | 265 | return res; |
327 | } | 266 | } |
328 | 267 | ||
329 | struct fixed31_32 dal_fixed31_32_sin( | 268 | struct fixed31_32 dc_fixpt_sin(struct fixed31_32 arg) |
330 | struct fixed31_32 arg) | ||
331 | { | 269 | { |
332 | return dal_fixed31_32_mul( | 270 | return dc_fixpt_mul( |
333 | arg, | 271 | arg, |
334 | dal_fixed31_32_sinc(arg)); | 272 | dc_fixpt_sinc(arg)); |
335 | } | 273 | } |
336 | 274 | ||
337 | struct fixed31_32 dal_fixed31_32_cos( | 275 | struct fixed31_32 dc_fixpt_cos(struct fixed31_32 arg) |
338 | struct fixed31_32 arg) | ||
339 | { | 276 | { |
340 | /* TODO implement argument normalization */ | 277 | /* TODO implement argument normalization */ |
341 | 278 | ||
342 | const struct fixed31_32 square = dal_fixed31_32_sqr(arg); | 279 | const struct fixed31_32 square = dc_fixpt_sqr(arg); |
343 | 280 | ||
344 | struct fixed31_32 res = dal_fixed31_32_one; | 281 | struct fixed31_32 res = dc_fixpt_one; |
345 | 282 | ||
346 | int n = 26; | 283 | int n = 26; |
347 | 284 | ||
348 | do { | 285 | do { |
349 | res = dal_fixed31_32_sub( | 286 | res = dc_fixpt_sub( |
350 | dal_fixed31_32_one, | 287 | dc_fixpt_one, |
351 | dal_fixed31_32_div_int( | 288 | dc_fixpt_div_int( |
352 | dal_fixed31_32_mul( | 289 | dc_fixpt_mul( |
353 | square, | 290 | square, |
354 | res), | 291 | res), |
355 | n * (n - 1))); | 292 | n * (n - 1))); |
@@ -367,37 +304,35 @@ struct fixed31_32 dal_fixed31_32_cos( | |||
367 | * | 304 | * |
368 | * Calculated as Taylor series. | 305 | * Calculated as Taylor series. |
369 | */ | 306 | */ |
370 | static struct fixed31_32 fixed31_32_exp_from_taylor_series( | 307 | static struct fixed31_32 fixed31_32_exp_from_taylor_series(struct fixed31_32 arg) |
371 | struct fixed31_32 arg) | ||
372 | { | 308 | { |
373 | unsigned int n = 9; | 309 | unsigned int n = 9; |
374 | 310 | ||
375 | struct fixed31_32 res = dal_fixed31_32_from_fraction( | 311 | struct fixed31_32 res = dc_fixpt_from_fraction( |
376 | n + 2, | 312 | n + 2, |
377 | n + 1); | 313 | n + 1); |
378 | /* TODO find correct res */ | 314 | /* TODO find correct res */ |
379 | 315 | ||
380 | ASSERT(dal_fixed31_32_lt(arg, dal_fixed31_32_one)); | 316 | ASSERT(dc_fixpt_lt(arg, dc_fixpt_one)); |
381 | 317 | ||
382 | do | 318 | do |
383 | res = dal_fixed31_32_add( | 319 | res = dc_fixpt_add( |
384 | dal_fixed31_32_one, | 320 | dc_fixpt_one, |
385 | dal_fixed31_32_div_int( | 321 | dc_fixpt_div_int( |
386 | dal_fixed31_32_mul( | 322 | dc_fixpt_mul( |
387 | arg, | 323 | arg, |
388 | res), | 324 | res), |
389 | n)); | 325 | n)); |
390 | while (--n != 1); | 326 | while (--n != 1); |
391 | 327 | ||
392 | return dal_fixed31_32_add( | 328 | return dc_fixpt_add( |
393 | dal_fixed31_32_one, | 329 | dc_fixpt_one, |
394 | dal_fixed31_32_mul( | 330 | dc_fixpt_mul( |
395 | arg, | 331 | arg, |
396 | res)); | 332 | res)); |
397 | } | 333 | } |
398 | 334 | ||
399 | struct fixed31_32 dal_fixed31_32_exp( | 335 | struct fixed31_32 dc_fixpt_exp(struct fixed31_32 arg) |
400 | struct fixed31_32 arg) | ||
401 | { | 336 | { |
402 | /* | 337 | /* |
403 | * @brief | 338 | * @brief |
@@ -406,44 +341,43 @@ struct fixed31_32 dal_fixed31_32_exp( | |||
406 | * where m = round(x / ln(2)), r = x - m * ln(2) | 341 | * where m = round(x / ln(2)), r = x - m * ln(2) |
407 | */ | 342 | */ |
408 | 343 | ||
409 | if (dal_fixed31_32_le( | 344 | if (dc_fixpt_le( |
410 | dal_fixed31_32_ln2_div_2, | 345 | dc_fixpt_ln2_div_2, |
411 | dal_fixed31_32_abs(arg))) { | 346 | dc_fixpt_abs(arg))) { |
412 | int m = dal_fixed31_32_round( | 347 | int m = dc_fixpt_round( |
413 | dal_fixed31_32_div( | 348 | dc_fixpt_div( |
414 | arg, | 349 | arg, |
415 | dal_fixed31_32_ln2)); | 350 | dc_fixpt_ln2)); |
416 | 351 | ||
417 | struct fixed31_32 r = dal_fixed31_32_sub( | 352 | struct fixed31_32 r = dc_fixpt_sub( |
418 | arg, | 353 | arg, |
419 | dal_fixed31_32_mul_int( | 354 | dc_fixpt_mul_int( |
420 | dal_fixed31_32_ln2, | 355 | dc_fixpt_ln2, |
421 | m)); | 356 | m)); |
422 | 357 | ||
423 | ASSERT(m != 0); | 358 | ASSERT(m != 0); |
424 | 359 | ||
425 | ASSERT(dal_fixed31_32_lt( | 360 | ASSERT(dc_fixpt_lt( |
426 | dal_fixed31_32_abs(r), | 361 | dc_fixpt_abs(r), |
427 | dal_fixed31_32_one)); | 362 | dc_fixpt_one)); |
428 | 363 | ||
429 | if (m > 0) | 364 | if (m > 0) |
430 | return dal_fixed31_32_shl( | 365 | return dc_fixpt_shl( |
431 | fixed31_32_exp_from_taylor_series(r), | 366 | fixed31_32_exp_from_taylor_series(r), |
432 | (unsigned char)m); | 367 | (unsigned char)m); |
433 | else | 368 | else |
434 | return dal_fixed31_32_div_int( | 369 | return dc_fixpt_div_int( |
435 | fixed31_32_exp_from_taylor_series(r), | 370 | fixed31_32_exp_from_taylor_series(r), |
436 | 1LL << -m); | 371 | 1LL << -m); |
437 | } else if (arg.value != 0) | 372 | } else if (arg.value != 0) |
438 | return fixed31_32_exp_from_taylor_series(arg); | 373 | return fixed31_32_exp_from_taylor_series(arg); |
439 | else | 374 | else |
440 | return dal_fixed31_32_one; | 375 | return dc_fixpt_one; |
441 | } | 376 | } |
442 | 377 | ||
443 | struct fixed31_32 dal_fixed31_32_log( | 378 | struct fixed31_32 dc_fixpt_log(struct fixed31_32 arg) |
444 | struct fixed31_32 arg) | ||
445 | { | 379 | { |
446 | struct fixed31_32 res = dal_fixed31_32_neg(dal_fixed31_32_one); | 380 | struct fixed31_32 res = dc_fixpt_neg(dc_fixpt_one); |
447 | /* TODO improve 1st estimation */ | 381 | /* TODO improve 1st estimation */ |
448 | 382 | ||
449 | struct fixed31_32 error; | 383 | struct fixed31_32 error; |
@@ -453,15 +387,15 @@ struct fixed31_32 dal_fixed31_32_log( | |||
453 | /* TODO if arg is zero, return -INF */ | 387 | /* TODO if arg is zero, return -INF */ |
454 | 388 | ||
455 | do { | 389 | do { |
456 | struct fixed31_32 res1 = dal_fixed31_32_add( | 390 | struct fixed31_32 res1 = dc_fixpt_add( |
457 | dal_fixed31_32_sub( | 391 | dc_fixpt_sub( |
458 | res, | 392 | res, |
459 | dal_fixed31_32_one), | 393 | dc_fixpt_one), |
460 | dal_fixed31_32_div( | 394 | dc_fixpt_div( |
461 | arg, | 395 | arg, |
462 | dal_fixed31_32_exp(res))); | 396 | dc_fixpt_exp(res))); |
463 | 397 | ||
464 | error = dal_fixed31_32_sub( | 398 | error = dc_fixpt_sub( |
465 | res, | 399 | res, |
466 | res1); | 400 | res1); |
467 | 401 | ||
@@ -472,66 +406,11 @@ struct fixed31_32 dal_fixed31_32_log( | |||
472 | return res; | 406 | return res; |
473 | } | 407 | } |
474 | 408 | ||
475 | struct fixed31_32 dal_fixed31_32_pow( | ||
476 | struct fixed31_32 arg1, | ||
477 | struct fixed31_32 arg2) | ||
478 | { | ||
479 | return dal_fixed31_32_exp( | ||
480 | dal_fixed31_32_mul( | ||
481 | dal_fixed31_32_log(arg1), | ||
482 | arg2)); | ||
483 | } | ||
484 | |||
485 | int dal_fixed31_32_floor( | ||
486 | struct fixed31_32 arg) | ||
487 | { | ||
488 | unsigned long long arg_value = abs_i64(arg.value); | ||
489 | |||
490 | if (arg.value >= 0) | ||
491 | return (int)GET_INTEGER_PART(arg_value); | ||
492 | else | ||
493 | return -(int)GET_INTEGER_PART(arg_value); | ||
494 | } | ||
495 | |||
496 | int dal_fixed31_32_round( | ||
497 | struct fixed31_32 arg) | ||
498 | { | ||
499 | unsigned long long arg_value = abs_i64(arg.value); | ||
500 | |||
501 | const long long summand = dal_fixed31_32_half.value; | ||
502 | |||
503 | ASSERT(LLONG_MAX - (long long)arg_value >= summand); | ||
504 | |||
505 | arg_value += summand; | ||
506 | |||
507 | if (arg.value >= 0) | ||
508 | return (int)GET_INTEGER_PART(arg_value); | ||
509 | else | ||
510 | return -(int)GET_INTEGER_PART(arg_value); | ||
511 | } | ||
512 | |||
513 | int dal_fixed31_32_ceil( | ||
514 | struct fixed31_32 arg) | ||
515 | { | ||
516 | unsigned long long arg_value = abs_i64(arg.value); | ||
517 | |||
518 | const long long summand = dal_fixed31_32_one.value - | ||
519 | dal_fixed31_32_epsilon.value; | ||
520 | |||
521 | ASSERT(LLONG_MAX - (long long)arg_value >= summand); | ||
522 | |||
523 | arg_value += summand; | ||
524 | |||
525 | if (arg.value >= 0) | ||
526 | return (int)GET_INTEGER_PART(arg_value); | ||
527 | else | ||
528 | return -(int)GET_INTEGER_PART(arg_value); | ||
529 | } | ||
530 | 409 | ||
531 | /* this function is a generic helper to translate fixed point value to | 410 | /* this function is a generic helper to translate fixed point value to |
532 | * specified integer format that will consist of integer_bits integer part and | 411 | * specified integer format that will consist of integer_bits integer part and |
533 | * fractional_bits fractional part. For example it is used in | 412 | * fractional_bits fractional part. For example it is used in |
534 | * dal_fixed31_32_u2d19 to receive 2 bits integer part and 19 bits fractional | 413 | * dc_fixpt_u2d19 to receive 2 bits integer part and 19 bits fractional |
535 | * part in 32 bits. It is used in hw programming (scaler) | 414 | * part in 32 bits. It is used in hw programming (scaler) |
536 | */ | 415 | */ |
537 | 416 | ||
@@ -570,35 +449,30 @@ static inline unsigned int clamp_ux_dy( | |||
570 | return min_clamp; | 449 | return min_clamp; |
571 | } | 450 | } |
572 | 451 | ||
573 | unsigned int dal_fixed31_32_u2d19( | 452 | unsigned int dc_fixpt_u2d19(struct fixed31_32 arg) |
574 | struct fixed31_32 arg) | ||
575 | { | 453 | { |
576 | return ux_dy(arg.value, 2, 19); | 454 | return ux_dy(arg.value, 2, 19); |
577 | } | 455 | } |
578 | 456 | ||
579 | unsigned int dal_fixed31_32_u0d19( | 457 | unsigned int dc_fixpt_u0d19(struct fixed31_32 arg) |
580 | struct fixed31_32 arg) | ||
581 | { | 458 | { |
582 | return ux_dy(arg.value, 0, 19); | 459 | return ux_dy(arg.value, 0, 19); |
583 | } | 460 | } |
584 | 461 | ||
585 | unsigned int dal_fixed31_32_clamp_u0d14( | 462 | unsigned int dc_fixpt_clamp_u0d14(struct fixed31_32 arg) |
586 | struct fixed31_32 arg) | ||
587 | { | 463 | { |
588 | return clamp_ux_dy(arg.value, 0, 14, 1); | 464 | return clamp_ux_dy(arg.value, 0, 14, 1); |
589 | } | 465 | } |
590 | 466 | ||
591 | unsigned int dal_fixed31_32_clamp_u0d10( | 467 | unsigned int dc_fixpt_clamp_u0d10(struct fixed31_32 arg) |
592 | struct fixed31_32 arg) | ||
593 | { | 468 | { |
594 | return clamp_ux_dy(arg.value, 0, 10, 1); | 469 | return clamp_ux_dy(arg.value, 0, 10, 1); |
595 | } | 470 | } |
596 | 471 | ||
597 | int dal_fixed31_32_s4d19( | 472 | int dc_fixpt_s4d19(struct fixed31_32 arg) |
598 | struct fixed31_32 arg) | ||
599 | { | 473 | { |
600 | if (arg.value < 0) | 474 | if (arg.value < 0) |
601 | return -(int)ux_dy(dal_fixed31_32_abs(arg).value, 4, 19); | 475 | return -(int)ux_dy(dc_fixpt_abs(arg).value, 4, 19); |
602 | else | 476 | else |
603 | return ux_dy(arg.value, 4, 19); | 477 | return ux_dy(arg.value, 4, 19); |
604 | } | 478 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/basics/fixpt32_32.c b/drivers/gpu/drm/amd/display/dc/basics/fixpt32_32.c deleted file mode 100644 index 4d3aaa82a07b..000000000000 --- a/drivers/gpu/drm/amd/display/dc/basics/fixpt32_32.c +++ /dev/null | |||
@@ -1,161 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2012-15 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 | * Authors: AMD | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #include "dm_services.h" | ||
27 | #include "include/fixed32_32.h" | ||
28 | |||
29 | static uint64_t u64_div(uint64_t n, uint64_t d) | ||
30 | { | ||
31 | uint32_t i = 0; | ||
32 | uint64_t r; | ||
33 | uint64_t q = div64_u64_rem(n, d, &r); | ||
34 | |||
35 | for (i = 0; i < 32; ++i) { | ||
36 | uint64_t sbit = q & (1ULL<<63); | ||
37 | |||
38 | r <<= 1; | ||
39 | r |= sbit ? 1 : 0; | ||
40 | q <<= 1; | ||
41 | if (r >= d) { | ||
42 | r -= d; | ||
43 | q |= 1; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | if (2*r >= d) | ||
48 | q += 1; | ||
49 | return q; | ||
50 | } | ||
51 | |||
52 | struct fixed32_32 dal_fixed32_32_from_fraction(uint32_t n, uint32_t d) | ||
53 | { | ||
54 | struct fixed32_32 fx; | ||
55 | |||
56 | fx.value = u64_div((uint64_t)n << 32, (uint64_t)d << 32); | ||
57 | return fx; | ||
58 | } | ||
59 | |||
60 | struct fixed32_32 dal_fixed32_32_add( | ||
61 | struct fixed32_32 lhs, | ||
62 | struct fixed32_32 rhs) | ||
63 | { | ||
64 | struct fixed32_32 fx = {lhs.value + rhs.value}; | ||
65 | |||
66 | ASSERT(fx.value >= rhs.value); | ||
67 | return fx; | ||
68 | } | ||
69 | |||
70 | struct fixed32_32 dal_fixed32_32_add_int(struct fixed32_32 lhs, uint32_t rhs) | ||
71 | { | ||
72 | struct fixed32_32 fx = {lhs.value + ((uint64_t)rhs << 32)}; | ||
73 | |||
74 | ASSERT(fx.value >= (uint64_t)rhs << 32); | ||
75 | return fx; | ||
76 | |||
77 | } | ||
78 | struct fixed32_32 dal_fixed32_32_sub( | ||
79 | struct fixed32_32 lhs, | ||
80 | struct fixed32_32 rhs) | ||
81 | { | ||
82 | struct fixed32_32 fx; | ||
83 | |||
84 | ASSERT(lhs.value >= rhs.value); | ||
85 | fx.value = lhs.value - rhs.value; | ||
86 | return fx; | ||
87 | } | ||
88 | |||
89 | struct fixed32_32 dal_fixed32_32_sub_int(struct fixed32_32 lhs, uint32_t rhs) | ||
90 | { | ||
91 | struct fixed32_32 fx; | ||
92 | |||
93 | ASSERT(lhs.value >= ((uint64_t)rhs<<32)); | ||
94 | fx.value = lhs.value - ((uint64_t)rhs<<32); | ||
95 | return fx; | ||
96 | } | ||
97 | |||
98 | struct fixed32_32 dal_fixed32_32_mul( | ||
99 | struct fixed32_32 lhs, | ||
100 | struct fixed32_32 rhs) | ||
101 | { | ||
102 | struct fixed32_32 fx; | ||
103 | uint64_t lhs_int = lhs.value>>32; | ||
104 | uint64_t lhs_frac = (uint32_t)lhs.value; | ||
105 | uint64_t rhs_int = rhs.value>>32; | ||
106 | uint64_t rhs_frac = (uint32_t)rhs.value; | ||
107 | uint64_t ahbh = lhs_int * rhs_int; | ||
108 | uint64_t ahbl = lhs_int * rhs_frac; | ||
109 | uint64_t albh = lhs_frac * rhs_int; | ||
110 | uint64_t albl = lhs_frac * rhs_frac; | ||
111 | |||
112 | ASSERT((ahbh>>32) == 0); | ||
113 | |||
114 | fx.value = (ahbh<<32) + ahbl + albh + (albl>>32); | ||
115 | return fx; | ||
116 | |||
117 | } | ||
118 | |||
119 | struct fixed32_32 dal_fixed32_32_mul_int(struct fixed32_32 lhs, uint32_t rhs) | ||
120 | { | ||
121 | struct fixed32_32 fx; | ||
122 | uint64_t lhsi = (lhs.value>>32) * (uint64_t)rhs; | ||
123 | uint64_t lhsf; | ||
124 | |||
125 | ASSERT((lhsi>>32) == 0); | ||
126 | lhsf = ((uint32_t)lhs.value) * (uint64_t)rhs; | ||
127 | ASSERT((lhsi<<32) + lhsf >= lhsf); | ||
128 | fx.value = (lhsi<<32) + lhsf; | ||
129 | return fx; | ||
130 | } | ||
131 | |||
132 | struct fixed32_32 dal_fixed32_32_div( | ||
133 | struct fixed32_32 lhs, | ||
134 | struct fixed32_32 rhs) | ||
135 | { | ||
136 | struct fixed32_32 fx; | ||
137 | |||
138 | fx.value = u64_div(lhs.value, rhs.value); | ||
139 | return fx; | ||
140 | } | ||
141 | |||
142 | struct fixed32_32 dal_fixed32_32_div_int(struct fixed32_32 lhs, uint32_t rhs) | ||
143 | { | ||
144 | struct fixed32_32 fx; | ||
145 | |||
146 | fx.value = u64_div(lhs.value, (uint64_t)rhs << 32); | ||
147 | return fx; | ||
148 | } | ||
149 | |||
150 | uint32_t dal_fixed32_32_ceil(struct fixed32_32 v) | ||
151 | { | ||
152 | ASSERT((uint32_t)v.value ? (v.value >> 32) + 1 >= 1 : true); | ||
153 | return (v.value>>32) + ((uint32_t)v.value ? 1 : 0); | ||
154 | } | ||
155 | |||
156 | uint32_t dal_fixed32_32_round(struct fixed32_32 v) | ||
157 | { | ||
158 | ASSERT(v.value + (1ULL<<31) >= (1ULL<<31)); | ||
159 | return (v.value + (1ULL<<31))>>32; | ||
160 | } | ||
161 | |||
diff --git a/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c b/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c index 854678a0c54b..021451549ff7 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c +++ b/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c | |||
@@ -94,7 +94,6 @@ void dc_conn_log(struct dc_context *ctx, | |||
94 | dm_logger_append(&entry, "%2.2X ", hex_data[i]); | 94 | dm_logger_append(&entry, "%2.2X ", hex_data[i]); |
95 | 95 | ||
96 | dm_logger_append(&entry, "^\n"); | 96 | dm_logger_append(&entry, "^\n"); |
97 | dm_helpers_dc_conn_log(ctx, &entry, event); | ||
98 | 97 | ||
99 | fail: | 98 | fail: |
100 | dm_logger_close(&entry); | 99 | dm_logger_close(&entry); |
diff --git a/drivers/gpu/drm/amd/display/dc/basics/logger.c b/drivers/gpu/drm/amd/display/dc/basics/logger.c index 31bee054f43a..738a818d58d1 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/logger.c +++ b/drivers/gpu/drm/amd/display/dc/basics/logger.c | |||
@@ -61,7 +61,7 @@ static const struct dc_log_type_info log_type_info_tbl[] = { | |||
61 | {LOG_EVENT_UNDERFLOW, "Underflow"}, | 61 | {LOG_EVENT_UNDERFLOW, "Underflow"}, |
62 | {LOG_IF_TRACE, "InterfaceTrace"}, | 62 | {LOG_IF_TRACE, "InterfaceTrace"}, |
63 | {LOG_DTN, "DTN"}, | 63 | {LOG_DTN, "DTN"}, |
64 | {LOG_PROFILING, "Profiling"} | 64 | {LOG_DISPLAYSTATS, "DisplayStats"} |
65 | }; | 65 | }; |
66 | 66 | ||
67 | 67 | ||
@@ -402,3 +402,4 @@ cleanup: | |||
402 | entry->max_buf_bytes = 0; | 402 | entry->max_buf_bytes = 0; |
403 | } | 403 | } |
404 | } | 404 | } |
405 | |||
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c index 10a5807a7e8b..b8cef7af3c4a 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | |||
@@ -1330,6 +1330,9 @@ static enum bp_result bios_parser_get_firmware_info( | |||
1330 | case 2: | 1330 | case 2: |
1331 | result = get_firmware_info_v3_2(bp, info); | 1331 | result = get_firmware_info_v3_2(bp, info); |
1332 | break; | 1332 | break; |
1333 | case 3: | ||
1334 | result = get_firmware_info_v3_2(bp, info); | ||
1335 | break; | ||
1333 | default: | 1336 | default: |
1334 | break; | 1337 | break; |
1335 | } | 1338 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table_helper.c b/drivers/gpu/drm/amd/display/dc/bios/command_table_helper.c index be066c49b984..253bbb1eea60 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/command_table_helper.c +++ b/drivers/gpu/drm/amd/display/dc/bios/command_table_helper.c | |||
@@ -51,9 +51,7 @@ bool dal_bios_parser_init_cmd_tbl_helper( | |||
51 | return true; | 51 | return true; |
52 | 52 | ||
53 | case DCE_VERSION_11_2: | 53 | case DCE_VERSION_11_2: |
54 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
55 | case DCE_VERSION_11_22: | 54 | case DCE_VERSION_11_22: |
56 | #endif | ||
57 | *h = dal_cmd_tbl_helper_dce112_get_table(); | 55 | *h = dal_cmd_tbl_helper_dce112_get_table(); |
58 | return true; | 56 | return true; |
59 | 57 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c b/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c index 9b9e06995805..bbbcef566c55 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c +++ b/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c | |||
@@ -52,9 +52,7 @@ bool dal_bios_parser_init_cmd_tbl_helper2( | |||
52 | return true; | 52 | return true; |
53 | 53 | ||
54 | case DCE_VERSION_11_2: | 54 | case DCE_VERSION_11_2: |
55 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
56 | case DCE_VERSION_11_22: | 55 | case DCE_VERSION_11_22: |
57 | #endif | ||
58 | *h = dal_cmd_tbl_helper_dce112_get_table2(); | 56 | *h = dal_cmd_tbl_helper_dce112_get_table2(); |
59 | return true; | 57 | return true; |
60 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | 58 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) |
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c b/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c index 7243c37f569e..31d167bc548f 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c | |||
@@ -36,41 +36,41 @@ static bool build_custom_float( | |||
36 | uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1; | 36 | uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1; |
37 | 37 | ||
38 | const struct fixed31_32 mantissa_constant_plus_max_fraction = | 38 | const struct fixed31_32 mantissa_constant_plus_max_fraction = |
39 | dal_fixed31_32_from_fraction( | 39 | dc_fixpt_from_fraction( |
40 | (1LL << (format->mantissa_bits + 1)) - 1, | 40 | (1LL << (format->mantissa_bits + 1)) - 1, |
41 | 1LL << format->mantissa_bits); | 41 | 1LL << format->mantissa_bits); |
42 | 42 | ||
43 | struct fixed31_32 mantiss; | 43 | struct fixed31_32 mantiss; |
44 | 44 | ||
45 | if (dal_fixed31_32_eq( | 45 | if (dc_fixpt_eq( |
46 | value, | 46 | value, |
47 | dal_fixed31_32_zero)) { | 47 | dc_fixpt_zero)) { |
48 | *negative = false; | 48 | *negative = false; |
49 | *mantissa = 0; | 49 | *mantissa = 0; |
50 | *exponenta = 0; | 50 | *exponenta = 0; |
51 | return true; | 51 | return true; |
52 | } | 52 | } |
53 | 53 | ||
54 | if (dal_fixed31_32_lt( | 54 | if (dc_fixpt_lt( |
55 | value, | 55 | value, |
56 | dal_fixed31_32_zero)) { | 56 | dc_fixpt_zero)) { |
57 | *negative = format->sign; | 57 | *negative = format->sign; |
58 | value = dal_fixed31_32_neg(value); | 58 | value = dc_fixpt_neg(value); |
59 | } else { | 59 | } else { |
60 | *negative = false; | 60 | *negative = false; |
61 | } | 61 | } |
62 | 62 | ||
63 | if (dal_fixed31_32_lt( | 63 | if (dc_fixpt_lt( |
64 | value, | 64 | value, |
65 | dal_fixed31_32_one)) { | 65 | dc_fixpt_one)) { |
66 | uint32_t i = 1; | 66 | uint32_t i = 1; |
67 | 67 | ||
68 | do { | 68 | do { |
69 | value = dal_fixed31_32_shl(value, 1); | 69 | value = dc_fixpt_shl(value, 1); |
70 | ++i; | 70 | ++i; |
71 | } while (dal_fixed31_32_lt( | 71 | } while (dc_fixpt_lt( |
72 | value, | 72 | value, |
73 | dal_fixed31_32_one)); | 73 | dc_fixpt_one)); |
74 | 74 | ||
75 | --i; | 75 | --i; |
76 | 76 | ||
@@ -81,15 +81,15 @@ static bool build_custom_float( | |||
81 | } | 81 | } |
82 | 82 | ||
83 | *exponenta = exp_offset - i; | 83 | *exponenta = exp_offset - i; |
84 | } else if (dal_fixed31_32_le( | 84 | } else if (dc_fixpt_le( |
85 | mantissa_constant_plus_max_fraction, | 85 | mantissa_constant_plus_max_fraction, |
86 | value)) { | 86 | value)) { |
87 | uint32_t i = 1; | 87 | uint32_t i = 1; |
88 | 88 | ||
89 | do { | 89 | do { |
90 | value = dal_fixed31_32_shr(value, 1); | 90 | value = dc_fixpt_shr(value, 1); |
91 | ++i; | 91 | ++i; |
92 | } while (dal_fixed31_32_lt( | 92 | } while (dc_fixpt_lt( |
93 | mantissa_constant_plus_max_fraction, | 93 | mantissa_constant_plus_max_fraction, |
94 | value)); | 94 | value)); |
95 | 95 | ||
@@ -98,23 +98,23 @@ static bool build_custom_float( | |||
98 | *exponenta = exp_offset; | 98 | *exponenta = exp_offset; |
99 | } | 99 | } |
100 | 100 | ||
101 | mantiss = dal_fixed31_32_sub( | 101 | mantiss = dc_fixpt_sub( |
102 | value, | 102 | value, |
103 | dal_fixed31_32_one); | 103 | dc_fixpt_one); |
104 | 104 | ||
105 | if (dal_fixed31_32_lt( | 105 | if (dc_fixpt_lt( |
106 | mantiss, | 106 | mantiss, |
107 | dal_fixed31_32_zero) || | 107 | dc_fixpt_zero) || |
108 | dal_fixed31_32_lt( | 108 | dc_fixpt_lt( |
109 | dal_fixed31_32_one, | 109 | dc_fixpt_one, |
110 | mantiss)) | 110 | mantiss)) |
111 | mantiss = dal_fixed31_32_zero; | 111 | mantiss = dc_fixpt_zero; |
112 | else | 112 | else |
113 | mantiss = dal_fixed31_32_shl( | 113 | mantiss = dc_fixpt_shl( |
114 | mantiss, | 114 | mantiss, |
115 | format->mantissa_bits); | 115 | format->mantissa_bits); |
116 | 116 | ||
117 | *mantissa = dal_fixed31_32_floor(mantiss); | 117 | *mantissa = dc_fixpt_floor(mantiss); |
118 | 118 | ||
119 | return true; | 119 | return true; |
120 | } | 120 | } |
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 4ee3c26f7c13..2c4e8f0cb2dc 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | |||
@@ -59,10 +59,8 @@ static enum bw_calcs_version bw_calcs_version_from_asic_id(struct hw_asic_id asi | |||
59 | return BW_CALCS_VERSION_POLARIS10; | 59 | return BW_CALCS_VERSION_POLARIS10; |
60 | if (ASIC_REV_IS_POLARIS11_M(asic_id.hw_internal_rev)) | 60 | if (ASIC_REV_IS_POLARIS11_M(asic_id.hw_internal_rev)) |
61 | return BW_CALCS_VERSION_POLARIS11; | 61 | return BW_CALCS_VERSION_POLARIS11; |
62 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
63 | if (ASIC_REV_IS_VEGAM(asic_id.hw_internal_rev)) | 62 | if (ASIC_REV_IS_VEGAM(asic_id.hw_internal_rev)) |
64 | return BW_CALCS_VERSION_VEGAM; | 63 | return BW_CALCS_VERSION_VEGAM; |
65 | #endif | ||
66 | return BW_CALCS_VERSION_INVALID; | 64 | return BW_CALCS_VERSION_INVALID; |
67 | 65 | ||
68 | case FAMILY_AI: | 66 | case FAMILY_AI: |
@@ -2151,11 +2149,9 @@ void bw_calcs_init(struct bw_calcs_dceip *bw_dceip, | |||
2151 | dceip.mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0); /* todo: this is a bug*/ | 2149 | dceip.mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0); /* todo: this is a bug*/ |
2152 | break; | 2150 | break; |
2153 | case BW_CALCS_VERSION_POLARIS10: | 2151 | case BW_CALCS_VERSION_POLARIS10: |
2154 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
2155 | /* TODO: Treat VEGAM the same as P10 for now | 2152 | /* TODO: Treat VEGAM the same as P10 for now |
2156 | * Need to tune the para for VEGAM if needed */ | 2153 | * Need to tune the para for VEGAM if needed */ |
2157 | case BW_CALCS_VERSION_VEGAM: | 2154 | case BW_CALCS_VERSION_VEGAM: |
2158 | #endif | ||
2159 | vbios.memory_type = bw_def_gddr5; | 2155 | vbios.memory_type = bw_def_gddr5; |
2160 | vbios.dram_channel_width_in_bits = 32; | 2156 | vbios.dram_channel_width_in_bits = 32; |
2161 | vbios.number_of_dram_channels = asic_id.vram_width / vbios.dram_channel_width_in_bits; | 2157 | vbios.number_of_dram_channels = asic_id.vram_width / vbios.dram_channel_width_in_bits; |
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 a102c192328d..49a4ea45466d 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c | |||
@@ -873,14 +873,14 @@ bool dcn_validate_bandwidth( | |||
873 | } | 873 | } |
874 | 874 | ||
875 | if (pipe->plane_state->rotation % 2 == 0) { | 875 | if (pipe->plane_state->rotation % 2 == 0) { |
876 | ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dal_fixed31_32_one.value | 876 | ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dc_fixpt_one.value |
877 | || v->scaler_rec_out_width[input_idx] == v->viewport_width[input_idx]); | 877 | || v->scaler_rec_out_width[input_idx] == v->viewport_width[input_idx]); |
878 | ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dal_fixed31_32_one.value | 878 | ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dc_fixpt_one.value |
879 | || v->scaler_recout_height[input_idx] == v->viewport_height[input_idx]); | 879 | || v->scaler_recout_height[input_idx] == v->viewport_height[input_idx]); |
880 | } else { | 880 | } else { |
881 | ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dal_fixed31_32_one.value | 881 | ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dc_fixpt_one.value |
882 | || v->scaler_recout_height[input_idx] == v->viewport_width[input_idx]); | 882 | || v->scaler_recout_height[input_idx] == v->viewport_width[input_idx]); |
883 | ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dal_fixed31_32_one.value | 883 | ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dc_fixpt_one.value |
884 | || v->scaler_rec_out_width[input_idx] == v->viewport_height[input_idx]); | 884 | || v->scaler_rec_out_width[input_idx] == v->viewport_height[input_idx]); |
885 | } | 885 | } |
886 | v->dcc_enable[input_idx] = pipe->plane_state->dcc.enable ? dcn_bw_yes : dcn_bw_no; | 886 | v->dcc_enable[input_idx] = pipe->plane_state->dcc.enable ? dcn_bw_yes : dcn_bw_no; |
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 b44cf52090a5..2fa521812d23 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c | |||
@@ -469,6 +469,13 @@ static void link_disconnect_sink(struct dc_link *link) | |||
469 | link->dpcd_sink_count = 0; | 469 | link->dpcd_sink_count = 0; |
470 | } | 470 | } |
471 | 471 | ||
472 | static void link_disconnect_remap(struct dc_sink *prev_sink, struct dc_link *link) | ||
473 | { | ||
474 | dc_sink_release(link->local_sink); | ||
475 | link->local_sink = prev_sink; | ||
476 | } | ||
477 | |||
478 | |||
472 | static bool detect_dp( | 479 | static bool detect_dp( |
473 | struct dc_link *link, | 480 | struct dc_link *link, |
474 | struct display_sink_capability *sink_caps, | 481 | struct display_sink_capability *sink_caps, |
@@ -551,6 +558,17 @@ static bool detect_dp( | |||
551 | return true; | 558 | return true; |
552 | } | 559 | } |
553 | 560 | ||
561 | static bool is_same_edid(struct dc_edid *old_edid, struct dc_edid *new_edid) | ||
562 | { | ||
563 | if (old_edid->length != new_edid->length) | ||
564 | return false; | ||
565 | |||
566 | if (new_edid->length == 0) | ||
567 | return false; | ||
568 | |||
569 | return (memcmp(old_edid->raw_edid, new_edid->raw_edid, new_edid->length) == 0); | ||
570 | } | ||
571 | |||
554 | bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | 572 | bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) |
555 | { | 573 | { |
556 | struct dc_sink_init_data sink_init_data = { 0 }; | 574 | struct dc_sink_init_data sink_init_data = { 0 }; |
@@ -558,9 +576,13 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
558 | uint8_t i; | 576 | uint8_t i; |
559 | bool converter_disable_audio = false; | 577 | bool converter_disable_audio = false; |
560 | struct audio_support *aud_support = &link->dc->res_pool->audio_support; | 578 | struct audio_support *aud_support = &link->dc->res_pool->audio_support; |
579 | bool same_edid = false; | ||
561 | enum dc_edid_status edid_status; | 580 | enum dc_edid_status edid_status; |
562 | struct dc_context *dc_ctx = link->ctx; | 581 | struct dc_context *dc_ctx = link->ctx; |
563 | struct dc_sink *sink = NULL; | 582 | struct dc_sink *sink = NULL; |
583 | struct dc_sink *prev_sink = NULL; | ||
584 | struct dpcd_caps prev_dpcd_caps; | ||
585 | bool same_dpcd = true; | ||
564 | enum dc_connection_type new_connection_type = dc_connection_none; | 586 | enum dc_connection_type new_connection_type = dc_connection_none; |
565 | DC_LOGGER_INIT(link->ctx->logger); | 587 | DC_LOGGER_INIT(link->ctx->logger); |
566 | if (link->connector_signal == SIGNAL_TYPE_VIRTUAL) | 588 | if (link->connector_signal == SIGNAL_TYPE_VIRTUAL) |
@@ -575,6 +597,11 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
575 | link->local_sink) | 597 | link->local_sink) |
576 | return true; | 598 | return true; |
577 | 599 | ||
600 | prev_sink = link->local_sink; | ||
601 | if (prev_sink != NULL) { | ||
602 | dc_sink_retain(prev_sink); | ||
603 | memcpy(&prev_dpcd_caps, &link->dpcd_caps, sizeof(struct dpcd_caps)); | ||
604 | } | ||
578 | link_disconnect_sink(link); | 605 | link_disconnect_sink(link); |
579 | 606 | ||
580 | if (new_connection_type != dc_connection_none) { | 607 | if (new_connection_type != dc_connection_none) { |
@@ -616,14 +643,25 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
616 | link, | 643 | link, |
617 | &sink_caps, | 644 | &sink_caps, |
618 | &converter_disable_audio, | 645 | &converter_disable_audio, |
619 | aud_support, reason)) | 646 | aud_support, reason)) { |
647 | if (prev_sink != NULL) | ||
648 | dc_sink_release(prev_sink); | ||
620 | return false; | 649 | return false; |
650 | } | ||
621 | 651 | ||
652 | // Check if dpcp block is the same | ||
653 | if (prev_sink != NULL) { | ||
654 | if (memcmp(&link->dpcd_caps, &prev_dpcd_caps, sizeof(struct dpcd_caps))) | ||
655 | same_dpcd = false; | ||
656 | } | ||
622 | /* Active dongle downstream unplug */ | 657 | /* Active dongle downstream unplug */ |
623 | if (link->type == dc_connection_active_dongle | 658 | if (link->type == dc_connection_active_dongle |
624 | && link->dpcd_caps.sink_count. | 659 | && link->dpcd_caps.sink_count. |
625 | bits.SINK_COUNT == 0) | 660 | bits.SINK_COUNT == 0) { |
661 | if (prev_sink != NULL) | ||
662 | dc_sink_release(prev_sink); | ||
626 | return true; | 663 | return true; |
664 | } | ||
627 | 665 | ||
628 | if (link->type == dc_connection_mst_branch) { | 666 | if (link->type == dc_connection_mst_branch) { |
629 | LINK_INFO("link=%d, mst branch is now Connected\n", | 667 | LINK_INFO("link=%d, mst branch is now Connected\n", |
@@ -631,9 +669,11 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
631 | /* Need to setup mst link_cap struct here | 669 | /* Need to setup mst link_cap struct here |
632 | * otherwise dc_link_detect() will leave mst link_cap | 670 | * otherwise dc_link_detect() will leave mst link_cap |
633 | * empty which leads to allocate_mst_payload() has "0" | 671 | * empty which leads to allocate_mst_payload() has "0" |
634 | * pbn_per_slot value leading to exception on dal_fixed31_32_div() | 672 | * pbn_per_slot value leading to exception on dc_fixpt_div() |
635 | */ | 673 | */ |
636 | link->verified_link_cap = link->reported_link_cap; | 674 | link->verified_link_cap = link->reported_link_cap; |
675 | if (prev_sink != NULL) | ||
676 | dc_sink_release(prev_sink); | ||
637 | return false; | 677 | return false; |
638 | } | 678 | } |
639 | 679 | ||
@@ -643,6 +683,8 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
643 | default: | 683 | default: |
644 | DC_ERROR("Invalid connector type! signal:%d\n", | 684 | DC_ERROR("Invalid connector type! signal:%d\n", |
645 | link->connector_signal); | 685 | link->connector_signal); |
686 | if (prev_sink != NULL) | ||
687 | dc_sink_release(prev_sink); | ||
646 | return false; | 688 | return false; |
647 | } /* switch() */ | 689 | } /* switch() */ |
648 | 690 | ||
@@ -665,6 +707,8 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
665 | sink = dc_sink_create(&sink_init_data); | 707 | sink = dc_sink_create(&sink_init_data); |
666 | if (!sink) { | 708 | if (!sink) { |
667 | DC_ERROR("Failed to create sink!\n"); | 709 | DC_ERROR("Failed to create sink!\n"); |
710 | if (prev_sink != NULL) | ||
711 | dc_sink_release(prev_sink); | ||
668 | return false; | 712 | return false; |
669 | } | 713 | } |
670 | 714 | ||
@@ -688,22 +732,33 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
688 | break; | 732 | break; |
689 | } | 733 | } |
690 | 734 | ||
691 | if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT && | 735 | // Check if edid is the same |
692 | sink_caps.transaction_type == | 736 | if ((prev_sink != NULL) && ((edid_status == EDID_THE_SAME) || (edid_status == EDID_OK))) |
693 | DDC_TRANSACTION_TYPE_I2C_OVER_AUX) { | 737 | same_edid = is_same_edid(&prev_sink->dc_edid, &sink->dc_edid); |
694 | /* | ||
695 | * TODO debug why Dell 2413 doesn't like | ||
696 | * two link trainings | ||
697 | */ | ||
698 | 738 | ||
699 | /* deal with non-mst cases */ | 739 | // If both edid and dpcd are the same, then discard new sink and revert back to original sink |
700 | dp_hbr_verify_link_cap(link, &link->reported_link_cap); | 740 | if ((same_edid) && (same_dpcd)) { |
701 | } | 741 | link_disconnect_remap(prev_sink, link); |
742 | sink = prev_sink; | ||
743 | prev_sink = NULL; | ||
744 | } else { | ||
745 | if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT && | ||
746 | sink_caps.transaction_type == | ||
747 | DDC_TRANSACTION_TYPE_I2C_OVER_AUX) { | ||
748 | /* | ||
749 | * TODO debug why Dell 2413 doesn't like | ||
750 | * two link trainings | ||
751 | */ | ||
752 | |||
753 | /* deal with non-mst cases */ | ||
754 | dp_hbr_verify_link_cap(link, &link->reported_link_cap); | ||
755 | } | ||
702 | 756 | ||
703 | /* HDMI-DVI Dongle */ | 757 | /* HDMI-DVI Dongle */ |
704 | if (sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A && | 758 | if (sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A && |
705 | !sink->edid_caps.edid_hdmi) | 759 | !sink->edid_caps.edid_hdmi) |
706 | sink->sink_signal = SIGNAL_TYPE_DVI_SINGLE_LINK; | 760 | sink->sink_signal = SIGNAL_TYPE_DVI_SINGLE_LINK; |
761 | } | ||
707 | 762 | ||
708 | /* Connectivity log: detection */ | 763 | /* Connectivity log: detection */ |
709 | for (i = 0; i < sink->dc_edid.length / EDID_BLOCK_SIZE; i++) { | 764 | for (i = 0; i < sink->dc_edid.length / EDID_BLOCK_SIZE; i++) { |
@@ -762,10 +817,14 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) | |||
762 | sink_caps.signal = SIGNAL_TYPE_NONE; | 817 | sink_caps.signal = SIGNAL_TYPE_NONE; |
763 | } | 818 | } |
764 | 819 | ||
765 | LINK_INFO("link=%d, dc_sink_in=%p is now %s\n", | 820 | LINK_INFO("link=%d, dc_sink_in=%p is now %s prev_sink=%p dpcd same=%d edid same=%d\n", |
766 | link->link_index, sink, | 821 | link->link_index, sink, |
767 | (sink_caps.signal == SIGNAL_TYPE_NONE ? | 822 | (sink_caps.signal == SIGNAL_TYPE_NONE ? |
768 | "Disconnected":"Connected")); | 823 | "Disconnected":"Connected"), prev_sink, |
824 | same_dpcd, same_edid); | ||
825 | |||
826 | if (prev_sink != NULL) | ||
827 | dc_sink_release(prev_sink); | ||
769 | 828 | ||
770 | return true; | 829 | return true; |
771 | } | 830 | } |
@@ -2059,10 +2118,10 @@ static struct fixed31_32 get_pbn_per_slot(struct dc_stream_state *stream) | |||
2059 | &stream->sink->link->cur_link_settings; | 2118 | &stream->sink->link->cur_link_settings; |
2060 | uint32_t link_rate_in_mbps = | 2119 | uint32_t link_rate_in_mbps = |
2061 | link_settings->link_rate * LINK_RATE_REF_FREQ_IN_MHZ; | 2120 | link_settings->link_rate * LINK_RATE_REF_FREQ_IN_MHZ; |
2062 | struct fixed31_32 mbps = dal_fixed31_32_from_int( | 2121 | struct fixed31_32 mbps = dc_fixpt_from_int( |
2063 | link_rate_in_mbps * link_settings->lane_count); | 2122 | link_rate_in_mbps * link_settings->lane_count); |
2064 | 2123 | ||
2065 | return dal_fixed31_32_div_int(mbps, 54); | 2124 | return dc_fixpt_div_int(mbps, 54); |
2066 | } | 2125 | } |
2067 | 2126 | ||
2068 | static int get_color_depth(enum dc_color_depth color_depth) | 2127 | static int get_color_depth(enum dc_color_depth color_depth) |
@@ -2103,7 +2162,7 @@ static struct fixed31_32 get_pbn_from_timing(struct pipe_ctx *pipe_ctx) | |||
2103 | numerator = 64 * PEAK_FACTOR_X1000; | 2162 | numerator = 64 * PEAK_FACTOR_X1000; |
2104 | denominator = 54 * 8 * 1000 * 1000; | 2163 | denominator = 54 * 8 * 1000 * 1000; |
2105 | kbps *= numerator; | 2164 | kbps *= numerator; |
2106 | peak_kbps = dal_fixed31_32_from_fraction(kbps, denominator); | 2165 | peak_kbps = dc_fixpt_from_fraction(kbps, denominator); |
2107 | 2166 | ||
2108 | return peak_kbps; | 2167 | return peak_kbps; |
2109 | } | 2168 | } |
@@ -2230,7 +2289,7 @@ static enum dc_status allocate_mst_payload(struct pipe_ctx *pipe_ctx) | |||
2230 | /* slot X.Y for only current stream */ | 2289 | /* slot X.Y for only current stream */ |
2231 | pbn_per_slot = get_pbn_per_slot(stream); | 2290 | pbn_per_slot = get_pbn_per_slot(stream); |
2232 | pbn = get_pbn_from_timing(pipe_ctx); | 2291 | pbn = get_pbn_from_timing(pipe_ctx); |
2233 | avg_time_slots_per_mtp = dal_fixed31_32_div(pbn, pbn_per_slot); | 2292 | avg_time_slots_per_mtp = dc_fixpt_div(pbn, pbn_per_slot); |
2234 | 2293 | ||
2235 | stream_encoder->funcs->set_mst_bandwidth( | 2294 | stream_encoder->funcs->set_mst_bandwidth( |
2236 | stream_encoder, | 2295 | stream_encoder, |
@@ -2247,7 +2306,7 @@ static enum dc_status deallocate_mst_payload(struct pipe_ctx *pipe_ctx) | |||
2247 | struct link_encoder *link_encoder = link->link_enc; | 2306 | struct link_encoder *link_encoder = link->link_enc; |
2248 | struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc; | 2307 | struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc; |
2249 | struct dp_mst_stream_allocation_table proposed_table = {0}; | 2308 | struct dp_mst_stream_allocation_table proposed_table = {0}; |
2250 | struct fixed31_32 avg_time_slots_per_mtp = dal_fixed31_32_from_int(0); | 2309 | struct fixed31_32 avg_time_slots_per_mtp = dc_fixpt_from_int(0); |
2251 | uint8_t i; | 2310 | uint8_t i; |
2252 | bool mst_mode = (link->type == dc_connection_mst_branch); | 2311 | bool mst_mode = (link->type == dc_connection_mst_branch); |
2253 | DC_LOGGER_INIT(link->ctx->logger); | 2312 | DC_LOGGER_INIT(link->ctx->logger); |
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 7c866a7d5e77..82cd1d6e6e59 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 | |||
@@ -11,8 +11,6 @@ | |||
11 | #include "dc_link_dp.h" | 11 | #include "dc_link_dp.h" |
12 | #include "dc_link_ddc.h" | 12 | #include "dc_link_ddc.h" |
13 | #include "dm_helpers.h" | 13 | #include "dm_helpers.h" |
14 | #include "dce/dce_link_encoder.h" | ||
15 | #include "dce/dce_stream_encoder.h" | ||
16 | #include "dpcd_defs.h" | 14 | #include "dpcd_defs.h" |
17 | 15 | ||
18 | enum dc_status core_link_read_dpcd( | 16 | enum dc_status core_link_read_dpcd( |
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 9eb731fb5251..751f3ac9d921 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c | |||
@@ -79,10 +79,8 @@ enum dce_version resource_parse_asic_id(struct hw_asic_id asic_id) | |||
79 | ASIC_REV_IS_POLARIS12_V(asic_id.hw_internal_rev)) { | 79 | ASIC_REV_IS_POLARIS12_V(asic_id.hw_internal_rev)) { |
80 | dc_version = DCE_VERSION_11_2; | 80 | dc_version = DCE_VERSION_11_2; |
81 | } | 81 | } |
82 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
83 | if (ASIC_REV_IS_VEGAM(asic_id.hw_internal_rev)) | 82 | if (ASIC_REV_IS_VEGAM(asic_id.hw_internal_rev)) |
84 | dc_version = DCE_VERSION_11_22; | 83 | dc_version = DCE_VERSION_11_22; |
85 | #endif | ||
86 | break; | 84 | break; |
87 | case FAMILY_AI: | 85 | case FAMILY_AI: |
88 | dc_version = DCE_VERSION_12_0; | 86 | dc_version = DCE_VERSION_12_0; |
@@ -129,9 +127,7 @@ struct resource_pool *dc_create_resource_pool( | |||
129 | num_virtual_links, dc, asic_id); | 127 | num_virtual_links, dc, asic_id); |
130 | break; | 128 | break; |
131 | case DCE_VERSION_11_2: | 129 | case DCE_VERSION_11_2: |
132 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
133 | case DCE_VERSION_11_22: | 130 | case DCE_VERSION_11_22: |
134 | #endif | ||
135 | res_pool = dce112_create_resource_pool( | 131 | res_pool = dce112_create_resource_pool( |
136 | num_virtual_links, dc); | 132 | num_virtual_links, dc); |
137 | break; | 133 | break; |
@@ -500,9 +496,9 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx) | |||
500 | data->viewport_c.x = data->viewport.x / vpc_div; | 496 | data->viewport_c.x = data->viewport.x / vpc_div; |
501 | data->viewport_c.y = data->viewport.y / vpc_div; | 497 | data->viewport_c.y = data->viewport.y / vpc_div; |
502 | data->inits.h_c = (data->viewport.x % vpc_div) != 0 ? | 498 | data->inits.h_c = (data->viewport.x % vpc_div) != 0 ? |
503 | dal_fixed31_32_half : dal_fixed31_32_zero; | 499 | dc_fixpt_half : dc_fixpt_zero; |
504 | data->inits.v_c = (data->viewport.y % vpc_div) != 0 ? | 500 | data->inits.v_c = (data->viewport.y % vpc_div) != 0 ? |
505 | dal_fixed31_32_half : dal_fixed31_32_zero; | 501 | dc_fixpt_half : dc_fixpt_zero; |
506 | /* Round up, assume original video size always even dimensions */ | 502 | /* Round up, assume original video size always even dimensions */ |
507 | data->viewport_c.width = (data->viewport.width + vpc_div - 1) / vpc_div; | 503 | data->viewport_c.width = (data->viewport.width + vpc_div - 1) / vpc_div; |
508 | data->viewport_c.height = (data->viewport.height + vpc_div - 1) / vpc_div; | 504 | data->viewport_c.height = (data->viewport.height + vpc_div - 1) / vpc_div; |
@@ -631,10 +627,10 @@ static void calculate_scaling_ratios(struct pipe_ctx *pipe_ctx) | |||
631 | pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) | 627 | pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) |
632 | rect_swap_helper(&surf_src); | 628 | rect_swap_helper(&surf_src); |
633 | 629 | ||
634 | pipe_ctx->plane_res.scl_data.ratios.horz = dal_fixed31_32_from_fraction( | 630 | pipe_ctx->plane_res.scl_data.ratios.horz = dc_fixpt_from_fraction( |
635 | surf_src.width, | 631 | surf_src.width, |
636 | plane_state->dst_rect.width); | 632 | plane_state->dst_rect.width); |
637 | pipe_ctx->plane_res.scl_data.ratios.vert = dal_fixed31_32_from_fraction( | 633 | pipe_ctx->plane_res.scl_data.ratios.vert = dc_fixpt_from_fraction( |
638 | surf_src.height, | 634 | surf_src.height, |
639 | plane_state->dst_rect.height); | 635 | plane_state->dst_rect.height); |
640 | 636 | ||
@@ -656,6 +652,14 @@ static void calculate_scaling_ratios(struct pipe_ctx *pipe_ctx) | |||
656 | pipe_ctx->plane_res.scl_data.ratios.horz_c.value /= 2; | 652 | pipe_ctx->plane_res.scl_data.ratios.horz_c.value /= 2; |
657 | pipe_ctx->plane_res.scl_data.ratios.vert_c.value /= 2; | 653 | pipe_ctx->plane_res.scl_data.ratios.vert_c.value /= 2; |
658 | } | 654 | } |
655 | pipe_ctx->plane_res.scl_data.ratios.horz = dc_fixpt_truncate( | ||
656 | pipe_ctx->plane_res.scl_data.ratios.horz, 19); | ||
657 | pipe_ctx->plane_res.scl_data.ratios.vert = dc_fixpt_truncate( | ||
658 | pipe_ctx->plane_res.scl_data.ratios.vert, 19); | ||
659 | pipe_ctx->plane_res.scl_data.ratios.horz_c = dc_fixpt_truncate( | ||
660 | pipe_ctx->plane_res.scl_data.ratios.horz_c, 19); | ||
661 | pipe_ctx->plane_res.scl_data.ratios.vert_c = dc_fixpt_truncate( | ||
662 | pipe_ctx->plane_res.scl_data.ratios.vert_c, 19); | ||
659 | } | 663 | } |
660 | 664 | ||
661 | static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *recout_skip) | 665 | static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *recout_skip) |
@@ -692,32 +696,33 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
692 | * init_bot = init + scaling_ratio | 696 | * init_bot = init + scaling_ratio |
693 | * init_c = init + truncated_vp_c_offset(from calculate viewport) | 697 | * init_c = init + truncated_vp_c_offset(from calculate viewport) |
694 | */ | 698 | */ |
695 | data->inits.h = dal_fixed31_32_div_int( | 699 | data->inits.h = dc_fixpt_truncate(dc_fixpt_div_int( |
696 | dal_fixed31_32_add_int(data->ratios.horz, data->taps.h_taps + 1), 2); | 700 | dc_fixpt_add_int(data->ratios.horz, data->taps.h_taps + 1), 2), 19); |
701 | |||
702 | data->inits.h_c = dc_fixpt_truncate(dc_fixpt_add(data->inits.h_c, dc_fixpt_div_int( | ||
703 | dc_fixpt_add_int(data->ratios.horz_c, data->taps.h_taps_c + 1), 2)), 19); | ||
697 | 704 | ||
698 | data->inits.h_c = dal_fixed31_32_add(data->inits.h_c, dal_fixed31_32_div_int( | 705 | data->inits.v = dc_fixpt_truncate(dc_fixpt_div_int( |
699 | dal_fixed31_32_add_int(data->ratios.horz_c, data->taps.h_taps_c + 1), 2)); | 706 | dc_fixpt_add_int(data->ratios.vert, data->taps.v_taps + 1), 2), 19); |
700 | 707 | ||
701 | data->inits.v = dal_fixed31_32_div_int( | 708 | data->inits.v_c = dc_fixpt_truncate(dc_fixpt_add(data->inits.v_c, dc_fixpt_div_int( |
702 | dal_fixed31_32_add_int(data->ratios.vert, data->taps.v_taps + 1), 2); | 709 | dc_fixpt_add_int(data->ratios.vert_c, data->taps.v_taps_c + 1), 2)), 19); |
703 | 710 | ||
704 | data->inits.v_c = dal_fixed31_32_add(data->inits.v_c, dal_fixed31_32_div_int( | ||
705 | dal_fixed31_32_add_int(data->ratios.vert_c, data->taps.v_taps_c + 1), 2)); | ||
706 | 711 | ||
707 | 712 | ||
708 | /* Adjust for viewport end clip-off */ | 713 | /* Adjust for viewport end clip-off */ |
709 | if ((data->viewport.x + data->viewport.width) < (src.x + src.width) && !flip_horz_scan_dir) { | 714 | if ((data->viewport.x + data->viewport.width) < (src.x + src.width) && !flip_horz_scan_dir) { |
710 | int vp_clip = src.x + src.width - data->viewport.width - data->viewport.x; | 715 | int vp_clip = src.x + src.width - data->viewport.width - data->viewport.x; |
711 | int int_part = dal_fixed31_32_floor( | 716 | int int_part = dc_fixpt_floor( |
712 | dal_fixed31_32_sub(data->inits.h, data->ratios.horz)); | 717 | dc_fixpt_sub(data->inits.h, data->ratios.horz)); |
713 | 718 | ||
714 | int_part = int_part > 0 ? int_part : 0; | 719 | int_part = int_part > 0 ? int_part : 0; |
715 | data->viewport.width += int_part < vp_clip ? int_part : vp_clip; | 720 | data->viewport.width += int_part < vp_clip ? int_part : vp_clip; |
716 | } | 721 | } |
717 | if ((data->viewport.y + data->viewport.height) < (src.y + src.height) && !flip_vert_scan_dir) { | 722 | if ((data->viewport.y + data->viewport.height) < (src.y + src.height) && !flip_vert_scan_dir) { |
718 | int vp_clip = src.y + src.height - data->viewport.height - data->viewport.y; | 723 | int vp_clip = src.y + src.height - data->viewport.height - data->viewport.y; |
719 | int int_part = dal_fixed31_32_floor( | 724 | int int_part = dc_fixpt_floor( |
720 | dal_fixed31_32_sub(data->inits.v, data->ratios.vert)); | 725 | dc_fixpt_sub(data->inits.v, data->ratios.vert)); |
721 | 726 | ||
722 | int_part = int_part > 0 ? int_part : 0; | 727 | int_part = int_part > 0 ? int_part : 0; |
723 | data->viewport.height += int_part < vp_clip ? int_part : vp_clip; | 728 | data->viewport.height += int_part < vp_clip ? int_part : vp_clip; |
@@ -725,8 +730,8 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
725 | if ((data->viewport_c.x + data->viewport_c.width) < (src.x + src.width) / vpc_div && !flip_horz_scan_dir) { | 730 | if ((data->viewport_c.x + data->viewport_c.width) < (src.x + src.width) / vpc_div && !flip_horz_scan_dir) { |
726 | int vp_clip = (src.x + src.width) / vpc_div - | 731 | int vp_clip = (src.x + src.width) / vpc_div - |
727 | data->viewport_c.width - data->viewport_c.x; | 732 | data->viewport_c.width - data->viewport_c.x; |
728 | int int_part = dal_fixed31_32_floor( | 733 | int int_part = dc_fixpt_floor( |
729 | dal_fixed31_32_sub(data->inits.h_c, data->ratios.horz_c)); | 734 | dc_fixpt_sub(data->inits.h_c, data->ratios.horz_c)); |
730 | 735 | ||
731 | int_part = int_part > 0 ? int_part : 0; | 736 | int_part = int_part > 0 ? int_part : 0; |
732 | data->viewport_c.width += int_part < vp_clip ? int_part : vp_clip; | 737 | data->viewport_c.width += int_part < vp_clip ? int_part : vp_clip; |
@@ -734,8 +739,8 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
734 | if ((data->viewport_c.y + data->viewport_c.height) < (src.y + src.height) / vpc_div && !flip_vert_scan_dir) { | 739 | if ((data->viewport_c.y + data->viewport_c.height) < (src.y + src.height) / vpc_div && !flip_vert_scan_dir) { |
735 | int vp_clip = (src.y + src.height) / vpc_div - | 740 | int vp_clip = (src.y + src.height) / vpc_div - |
736 | data->viewport_c.height - data->viewport_c.y; | 741 | data->viewport_c.height - data->viewport_c.y; |
737 | int int_part = dal_fixed31_32_floor( | 742 | int int_part = dc_fixpt_floor( |
738 | dal_fixed31_32_sub(data->inits.v_c, data->ratios.vert_c)); | 743 | dc_fixpt_sub(data->inits.v_c, data->ratios.vert_c)); |
739 | 744 | ||
740 | int_part = int_part > 0 ? int_part : 0; | 745 | int_part = int_part > 0 ? int_part : 0; |
741 | data->viewport_c.height += int_part < vp_clip ? int_part : vp_clip; | 746 | data->viewport_c.height += int_part < vp_clip ? int_part : vp_clip; |
@@ -745,9 +750,9 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
745 | if (data->viewport.x && !flip_horz_scan_dir) { | 750 | if (data->viewport.x && !flip_horz_scan_dir) { |
746 | int int_part; | 751 | int int_part; |
747 | 752 | ||
748 | data->inits.h = dal_fixed31_32_add(data->inits.h, dal_fixed31_32_mul_int( | 753 | data->inits.h = dc_fixpt_add(data->inits.h, dc_fixpt_mul_int( |
749 | data->ratios.horz, recout_skip->width)); | 754 | data->ratios.horz, recout_skip->width)); |
750 | int_part = dal_fixed31_32_floor(data->inits.h) - data->viewport.x; | 755 | int_part = dc_fixpt_floor(data->inits.h) - data->viewport.x; |
751 | if (int_part < data->taps.h_taps) { | 756 | if (int_part < data->taps.h_taps) { |
752 | int int_adj = data->viewport.x >= (data->taps.h_taps - int_part) ? | 757 | int int_adj = data->viewport.x >= (data->taps.h_taps - int_part) ? |
753 | (data->taps.h_taps - int_part) : data->viewport.x; | 758 | (data->taps.h_taps - int_part) : data->viewport.x; |
@@ -760,15 +765,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
760 | int_part = data->taps.h_taps; | 765 | int_part = data->taps.h_taps; |
761 | } | 766 | } |
762 | data->inits.h.value &= 0xffffffff; | 767 | data->inits.h.value &= 0xffffffff; |
763 | data->inits.h = dal_fixed31_32_add_int(data->inits.h, int_part); | 768 | data->inits.h = dc_fixpt_add_int(data->inits.h, int_part); |
764 | } | 769 | } |
765 | 770 | ||
766 | if (data->viewport_c.x && !flip_horz_scan_dir) { | 771 | if (data->viewport_c.x && !flip_horz_scan_dir) { |
767 | int int_part; | 772 | int int_part; |
768 | 773 | ||
769 | data->inits.h_c = dal_fixed31_32_add(data->inits.h_c, dal_fixed31_32_mul_int( | 774 | data->inits.h_c = dc_fixpt_add(data->inits.h_c, dc_fixpt_mul_int( |
770 | data->ratios.horz_c, recout_skip->width)); | 775 | data->ratios.horz_c, recout_skip->width)); |
771 | int_part = dal_fixed31_32_floor(data->inits.h_c) - data->viewport_c.x; | 776 | int_part = dc_fixpt_floor(data->inits.h_c) - data->viewport_c.x; |
772 | if (int_part < data->taps.h_taps_c) { | 777 | if (int_part < data->taps.h_taps_c) { |
773 | int int_adj = data->viewport_c.x >= (data->taps.h_taps_c - int_part) ? | 778 | int int_adj = data->viewport_c.x >= (data->taps.h_taps_c - int_part) ? |
774 | (data->taps.h_taps_c - int_part) : data->viewport_c.x; | 779 | (data->taps.h_taps_c - int_part) : data->viewport_c.x; |
@@ -781,15 +786,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
781 | int_part = data->taps.h_taps_c; | 786 | int_part = data->taps.h_taps_c; |
782 | } | 787 | } |
783 | data->inits.h_c.value &= 0xffffffff; | 788 | data->inits.h_c.value &= 0xffffffff; |
784 | data->inits.h_c = dal_fixed31_32_add_int(data->inits.h_c, int_part); | 789 | data->inits.h_c = dc_fixpt_add_int(data->inits.h_c, int_part); |
785 | } | 790 | } |
786 | 791 | ||
787 | if (data->viewport.y && !flip_vert_scan_dir) { | 792 | if (data->viewport.y && !flip_vert_scan_dir) { |
788 | int int_part; | 793 | int int_part; |
789 | 794 | ||
790 | data->inits.v = dal_fixed31_32_add(data->inits.v, dal_fixed31_32_mul_int( | 795 | data->inits.v = dc_fixpt_add(data->inits.v, dc_fixpt_mul_int( |
791 | data->ratios.vert, recout_skip->height)); | 796 | data->ratios.vert, recout_skip->height)); |
792 | int_part = dal_fixed31_32_floor(data->inits.v) - data->viewport.y; | 797 | int_part = dc_fixpt_floor(data->inits.v) - data->viewport.y; |
793 | if (int_part < data->taps.v_taps) { | 798 | if (int_part < data->taps.v_taps) { |
794 | int int_adj = data->viewport.y >= (data->taps.v_taps - int_part) ? | 799 | int int_adj = data->viewport.y >= (data->taps.v_taps - int_part) ? |
795 | (data->taps.v_taps - int_part) : data->viewport.y; | 800 | (data->taps.v_taps - int_part) : data->viewport.y; |
@@ -802,15 +807,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
802 | int_part = data->taps.v_taps; | 807 | int_part = data->taps.v_taps; |
803 | } | 808 | } |
804 | data->inits.v.value &= 0xffffffff; | 809 | data->inits.v.value &= 0xffffffff; |
805 | data->inits.v = dal_fixed31_32_add_int(data->inits.v, int_part); | 810 | data->inits.v = dc_fixpt_add_int(data->inits.v, int_part); |
806 | } | 811 | } |
807 | 812 | ||
808 | if (data->viewport_c.y && !flip_vert_scan_dir) { | 813 | if (data->viewport_c.y && !flip_vert_scan_dir) { |
809 | int int_part; | 814 | int int_part; |
810 | 815 | ||
811 | data->inits.v_c = dal_fixed31_32_add(data->inits.v_c, dal_fixed31_32_mul_int( | 816 | data->inits.v_c = dc_fixpt_add(data->inits.v_c, dc_fixpt_mul_int( |
812 | data->ratios.vert_c, recout_skip->height)); | 817 | data->ratios.vert_c, recout_skip->height)); |
813 | int_part = dal_fixed31_32_floor(data->inits.v_c) - data->viewport_c.y; | 818 | int_part = dc_fixpt_floor(data->inits.v_c) - data->viewport_c.y; |
814 | if (int_part < data->taps.v_taps_c) { | 819 | if (int_part < data->taps.v_taps_c) { |
815 | int int_adj = data->viewport_c.y >= (data->taps.v_taps_c - int_part) ? | 820 | int int_adj = data->viewport_c.y >= (data->taps.v_taps_c - int_part) ? |
816 | (data->taps.v_taps_c - int_part) : data->viewport_c.y; | 821 | (data->taps.v_taps_c - int_part) : data->viewport_c.y; |
@@ -823,12 +828,12 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
823 | int_part = data->taps.v_taps_c; | 828 | int_part = data->taps.v_taps_c; |
824 | } | 829 | } |
825 | data->inits.v_c.value &= 0xffffffff; | 830 | data->inits.v_c.value &= 0xffffffff; |
826 | data->inits.v_c = dal_fixed31_32_add_int(data->inits.v_c, int_part); | 831 | data->inits.v_c = dc_fixpt_add_int(data->inits.v_c, int_part); |
827 | } | 832 | } |
828 | 833 | ||
829 | /* Interlaced inits based on final vert inits */ | 834 | /* Interlaced inits based on final vert inits */ |
830 | data->inits.v_bot = dal_fixed31_32_add(data->inits.v, data->ratios.vert); | 835 | data->inits.v_bot = dc_fixpt_add(data->inits.v, data->ratios.vert); |
831 | data->inits.v_c_bot = dal_fixed31_32_add(data->inits.v_c, data->ratios.vert_c); | 836 | data->inits.v_c_bot = dc_fixpt_add(data->inits.v_c, data->ratios.vert_c); |
832 | 837 | ||
833 | if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 || | 838 | if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 || |
834 | pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) { | 839 | pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) { |
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index cd4f4341cb53..9cfde0ccf4e9 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h | |||
@@ -75,6 +75,7 @@ struct dc_caps { | |||
75 | bool dynamic_audio; | 75 | bool dynamic_audio; |
76 | bool is_apu; | 76 | bool is_apu; |
77 | bool dual_link_dvi; | 77 | bool dual_link_dvi; |
78 | bool post_blend_color_processing; | ||
78 | }; | 79 | }; |
79 | 80 | ||
80 | struct dc_dcc_surface_param { | 81 | struct dc_dcc_surface_param { |
@@ -203,6 +204,7 @@ struct dc_debug { | |||
203 | bool clock_trace; | 204 | bool clock_trace; |
204 | bool validation_trace; | 205 | bool validation_trace; |
205 | bool bandwidth_calcs_trace; | 206 | bool bandwidth_calcs_trace; |
207 | int max_downscale_src_width; | ||
206 | 208 | ||
207 | /* stutter efficiency related */ | 209 | /* stutter efficiency related */ |
208 | bool disable_stutter; | 210 | bool disable_stutter; |
@@ -239,6 +241,8 @@ struct dc_debug { | |||
239 | bool az_endpoint_mute_only; | 241 | bool az_endpoint_mute_only; |
240 | bool always_use_regamma; | 242 | bool always_use_regamma; |
241 | bool p010_mpo_support; | 243 | bool p010_mpo_support; |
244 | bool recovery_enabled; | ||
245 | |||
242 | }; | 246 | }; |
243 | struct dc_state; | 247 | struct dc_state; |
244 | struct resource_pool; | 248 | struct resource_pool; |
@@ -499,18 +503,18 @@ struct dc_surface_update { | |||
499 | struct dc_plane_state *surface; | 503 | struct dc_plane_state *surface; |
500 | 504 | ||
501 | /* isr safe update parameters. null means no updates */ | 505 | /* isr safe update parameters. null means no updates */ |
502 | struct dc_flip_addrs *flip_addr; | 506 | const struct dc_flip_addrs *flip_addr; |
503 | struct dc_plane_info *plane_info; | 507 | const struct dc_plane_info *plane_info; |
504 | struct dc_scaling_info *scaling_info; | 508 | const struct dc_scaling_info *scaling_info; |
505 | 509 | ||
506 | /* following updates require alloc/sleep/spin that is not isr safe, | 510 | /* following updates require alloc/sleep/spin that is not isr safe, |
507 | * null means no updates | 511 | * null means no updates |
508 | */ | 512 | */ |
509 | struct dc_gamma *gamma; | 513 | const struct dc_gamma *gamma; |
510 | struct dc_transfer_func *in_transfer_func; | 514 | const struct dc_transfer_func *in_transfer_func; |
511 | 515 | ||
512 | struct dc_csc_transform *input_csc_color_matrix; | 516 | const struct dc_csc_transform *input_csc_color_matrix; |
513 | struct fixed31_32 *coeff_reduction_factor; | 517 | const struct fixed31_32 *coeff_reduction_factor; |
514 | }; | 518 | }; |
515 | 519 | ||
516 | /* | 520 | /* |
diff --git a/drivers/gpu/drm/amd/display/dc/dc_dp_types.h b/drivers/gpu/drm/amd/display/dc/dc_dp_types.h index 2726b02e006b..90bccd5ccaa2 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_dp_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_dp_types.h | |||
@@ -26,6 +26,8 @@ | |||
26 | #ifndef DC_DP_TYPES_H | 26 | #ifndef DC_DP_TYPES_H |
27 | #define DC_DP_TYPES_H | 27 | #define DC_DP_TYPES_H |
28 | 28 | ||
29 | #include "os_types.h" | ||
30 | |||
29 | enum dc_lane_count { | 31 | enum dc_lane_count { |
30 | LANE_COUNT_UNKNOWN = 0, | 32 | LANE_COUNT_UNKNOWN = 0, |
31 | LANE_COUNT_ONE = 1, | 33 | LANE_COUNT_ONE = 1, |
diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h index 9defe3b17617..76df2534c4a4 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_types.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #ifndef DC_TYPES_H_ | 25 | #ifndef DC_TYPES_H_ |
26 | #define DC_TYPES_H_ | 26 | #define DC_TYPES_H_ |
27 | 27 | ||
28 | #include "fixed32_32.h" | 28 | #include "os_types.h" |
29 | #include "fixed31_32.h" | 29 | #include "fixed31_32.h" |
30 | #include "irq_types.h" | 30 | #include "irq_types.h" |
31 | #include "dc_dp_types.h" | 31 | #include "dc_dp_types.h" |
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 fe92a1222803..29294db1a96b 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "dce_abm.h" | 26 | #include "dce_abm.h" |
27 | #include "dm_services.h" | 27 | #include "dm_services.h" |
28 | #include "reg_helper.h" | 28 | #include "reg_helper.h" |
29 | #include "fixed32_32.h" | 29 | #include "fixed31_32.h" |
30 | #include "dc.h" | 30 | #include "dc.h" |
31 | 31 | ||
32 | #include "atom.h" | 32 | #include "atom.h" |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c index 223db98a568a..599c7ab6befe 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | |||
@@ -590,9 +590,7 @@ static uint32_t dce110_get_pix_clk_dividers( | |||
590 | pll_settings, pix_clk_params); | 590 | pll_settings, pix_clk_params); |
591 | break; | 591 | break; |
592 | case DCE_VERSION_11_2: | 592 | case DCE_VERSION_11_2: |
593 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
594 | case DCE_VERSION_11_22: | 593 | case DCE_VERSION_11_22: |
595 | #endif | ||
596 | case DCE_VERSION_12_0: | 594 | case DCE_VERSION_12_0: |
597 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | 595 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) |
598 | case DCN_VERSION_1_0: | 596 | case DCN_VERSION_1_0: |
@@ -659,12 +657,12 @@ static uint32_t dce110_get_d_to_pixel_rate_in_hz( | |||
659 | return 0; | 657 | return 0; |
660 | } | 658 | } |
661 | 659 | ||
662 | pix_rate = dal_fixed31_32_from_int(clk_src->ref_freq_khz); | 660 | pix_rate = dc_fixpt_from_int(clk_src->ref_freq_khz); |
663 | pix_rate = dal_fixed31_32_mul_int(pix_rate, 1000); | 661 | pix_rate = dc_fixpt_mul_int(pix_rate, 1000); |
664 | pix_rate = dal_fixed31_32_mul_int(pix_rate, phase); | 662 | pix_rate = dc_fixpt_mul_int(pix_rate, phase); |
665 | pix_rate = dal_fixed31_32_div_int(pix_rate, modulo); | 663 | pix_rate = dc_fixpt_div_int(pix_rate, modulo); |
666 | 664 | ||
667 | return dal_fixed31_32_round(pix_rate); | 665 | return dc_fixpt_round(pix_rate); |
668 | } else { | 666 | } else { |
669 | return dce110_get_dp_pixel_rate_from_combo_phy_pll(cs, pix_clk_params, pll_settings); | 667 | return dce110_get_dp_pixel_rate_from_combo_phy_pll(cs, pix_clk_params, pll_settings); |
670 | } | 668 | } |
@@ -713,12 +711,12 @@ static bool calculate_ss( | |||
713 | const struct spread_spectrum_data *ss_data, | 711 | const struct spread_spectrum_data *ss_data, |
714 | struct delta_sigma_data *ds_data) | 712 | struct delta_sigma_data *ds_data) |
715 | { | 713 | { |
716 | struct fixed32_32 fb_div; | 714 | struct fixed31_32 fb_div; |
717 | struct fixed32_32 ss_amount; | 715 | struct fixed31_32 ss_amount; |
718 | struct fixed32_32 ss_nslip_amount; | 716 | struct fixed31_32 ss_nslip_amount; |
719 | struct fixed32_32 ss_ds_frac_amount; | 717 | struct fixed31_32 ss_ds_frac_amount; |
720 | struct fixed32_32 ss_step_size; | 718 | struct fixed31_32 ss_step_size; |
721 | struct fixed32_32 modulation_time; | 719 | struct fixed31_32 modulation_time; |
722 | 720 | ||
723 | if (ds_data == NULL) | 721 | if (ds_data == NULL) |
724 | return false; | 722 | return false; |
@@ -733,42 +731,42 @@ static bool calculate_ss( | |||
733 | 731 | ||
734 | /* compute SS_AMOUNT_FBDIV & SS_AMOUNT_NFRAC_SLIP & SS_AMOUNT_DSFRAC*/ | 732 | /* compute SS_AMOUNT_FBDIV & SS_AMOUNT_NFRAC_SLIP & SS_AMOUNT_DSFRAC*/ |
735 | /* 6 decimal point support in fractional feedback divider */ | 733 | /* 6 decimal point support in fractional feedback divider */ |
736 | fb_div = dal_fixed32_32_from_fraction( | 734 | fb_div = dc_fixpt_from_fraction( |
737 | pll_settings->fract_feedback_divider, 1000000); | 735 | pll_settings->fract_feedback_divider, 1000000); |
738 | fb_div = dal_fixed32_32_add_int(fb_div, pll_settings->feedback_divider); | 736 | fb_div = dc_fixpt_add_int(fb_div, pll_settings->feedback_divider); |
739 | 737 | ||
740 | ds_data->ds_frac_amount = 0; | 738 | ds_data->ds_frac_amount = 0; |
741 | /*spreadSpectrumPercentage is in the unit of .01%, | 739 | /*spreadSpectrumPercentage is in the unit of .01%, |
742 | * so have to divided by 100 * 100*/ | 740 | * so have to divided by 100 * 100*/ |
743 | ss_amount = dal_fixed32_32_mul( | 741 | ss_amount = dc_fixpt_mul( |
744 | fb_div, dal_fixed32_32_from_fraction(ss_data->percentage, | 742 | fb_div, dc_fixpt_from_fraction(ss_data->percentage, |
745 | 100 * ss_data->percentage_divider)); | 743 | 100 * ss_data->percentage_divider)); |
746 | ds_data->feedback_amount = dal_fixed32_32_floor(ss_amount); | 744 | ds_data->feedback_amount = dc_fixpt_floor(ss_amount); |
747 | 745 | ||
748 | ss_nslip_amount = dal_fixed32_32_sub(ss_amount, | 746 | ss_nslip_amount = dc_fixpt_sub(ss_amount, |
749 | dal_fixed32_32_from_int(ds_data->feedback_amount)); | 747 | dc_fixpt_from_int(ds_data->feedback_amount)); |
750 | ss_nslip_amount = dal_fixed32_32_mul_int(ss_nslip_amount, 10); | 748 | ss_nslip_amount = dc_fixpt_mul_int(ss_nslip_amount, 10); |
751 | ds_data->nfrac_amount = dal_fixed32_32_floor(ss_nslip_amount); | 749 | ds_data->nfrac_amount = dc_fixpt_floor(ss_nslip_amount); |
752 | 750 | ||
753 | ss_ds_frac_amount = dal_fixed32_32_sub(ss_nslip_amount, | 751 | ss_ds_frac_amount = dc_fixpt_sub(ss_nslip_amount, |
754 | dal_fixed32_32_from_int(ds_data->nfrac_amount)); | 752 | dc_fixpt_from_int(ds_data->nfrac_amount)); |
755 | ss_ds_frac_amount = dal_fixed32_32_mul_int(ss_ds_frac_amount, 65536); | 753 | ss_ds_frac_amount = dc_fixpt_mul_int(ss_ds_frac_amount, 65536); |
756 | ds_data->ds_frac_amount = dal_fixed32_32_floor(ss_ds_frac_amount); | 754 | ds_data->ds_frac_amount = dc_fixpt_floor(ss_ds_frac_amount); |
757 | 755 | ||
758 | /* compute SS_STEP_SIZE_DSFRAC */ | 756 | /* compute SS_STEP_SIZE_DSFRAC */ |
759 | modulation_time = dal_fixed32_32_from_fraction( | 757 | modulation_time = dc_fixpt_from_fraction( |
760 | pll_settings->reference_freq * 1000, | 758 | pll_settings->reference_freq * 1000, |
761 | pll_settings->reference_divider * ss_data->modulation_freq_hz); | 759 | pll_settings->reference_divider * ss_data->modulation_freq_hz); |
762 | 760 | ||
763 | if (ss_data->flags.CENTER_SPREAD) | 761 | if (ss_data->flags.CENTER_SPREAD) |
764 | modulation_time = dal_fixed32_32_div_int(modulation_time, 4); | 762 | modulation_time = dc_fixpt_div_int(modulation_time, 4); |
765 | else | 763 | else |
766 | modulation_time = dal_fixed32_32_div_int(modulation_time, 2); | 764 | modulation_time = dc_fixpt_div_int(modulation_time, 2); |
767 | 765 | ||
768 | ss_step_size = dal_fixed32_32_div(ss_amount, modulation_time); | 766 | ss_step_size = dc_fixpt_div(ss_amount, modulation_time); |
769 | /* SS_STEP_SIZE_DSFRAC_DEC = Int(SS_STEP_SIZE * 2 ^ 16 * 10)*/ | 767 | /* SS_STEP_SIZE_DSFRAC_DEC = Int(SS_STEP_SIZE * 2 ^ 16 * 10)*/ |
770 | ss_step_size = dal_fixed32_32_mul_int(ss_step_size, 65536 * 10); | 768 | ss_step_size = dc_fixpt_mul_int(ss_step_size, 65536 * 10); |
771 | ds_data->ds_frac_size = dal_fixed32_32_floor(ss_step_size); | 769 | ds_data->ds_frac_size = dc_fixpt_floor(ss_step_size); |
772 | 770 | ||
773 | return true; | 771 | return true; |
774 | } | 772 | } |
@@ -982,9 +980,7 @@ static bool dce110_program_pix_clk( | |||
982 | 980 | ||
983 | break; | 981 | break; |
984 | case DCE_VERSION_11_2: | 982 | case DCE_VERSION_11_2: |
985 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
986 | case DCE_VERSION_11_22: | 983 | case DCE_VERSION_11_22: |
987 | #endif | ||
988 | case DCE_VERSION_12_0: | 984 | case DCE_VERSION_12_0: |
989 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | 985 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) |
990 | case DCN_VERSION_1_0: | 986 | case DCN_VERSION_1_0: |
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 78e6beb6cf26..8a581c67bf2d 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "dce_clocks.h" | 26 | #include "dce_clocks.h" |
27 | #include "dm_services.h" | 27 | #include "dm_services.h" |
28 | #include "reg_helper.h" | 28 | #include "reg_helper.h" |
29 | #include "fixed32_32.h" | 29 | #include "fixed31_32.h" |
30 | #include "bios_parser_interface.h" | 30 | #include "bios_parser_interface.h" |
31 | #include "dc.h" | 31 | #include "dc.h" |
32 | #include "dmcu.h" | 32 | #include "dmcu.h" |
@@ -35,7 +35,7 @@ | |||
35 | #endif | 35 | #endif |
36 | #include "core_types.h" | 36 | #include "core_types.h" |
37 | #include "dc_types.h" | 37 | #include "dc_types.h" |
38 | 38 | #include "dal_asic_id.h" | |
39 | 39 | ||
40 | #define TO_DCE_CLOCKS(clocks)\ | 40 | #define TO_DCE_CLOCKS(clocks)\ |
41 | container_of(clocks, struct dce_disp_clk, base) | 41 | container_of(clocks, struct dce_disp_clk, base) |
@@ -228,19 +228,19 @@ static int dce_clocks_get_dp_ref_freq(struct display_clock *clk) | |||
228 | generated according to average value (case as with previous ASICs) | 228 | generated according to average value (case as with previous ASICs) |
229 | */ | 229 | */ |
230 | if (clk_dce->ss_on_dprefclk && clk_dce->dprefclk_ss_divider != 0) { | 230 | if (clk_dce->ss_on_dprefclk && clk_dce->dprefclk_ss_divider != 0) { |
231 | struct fixed32_32 ss_percentage = dal_fixed32_32_div_int( | 231 | struct fixed31_32 ss_percentage = dc_fixpt_div_int( |
232 | dal_fixed32_32_from_fraction( | 232 | dc_fixpt_from_fraction( |
233 | clk_dce->dprefclk_ss_percentage, | 233 | clk_dce->dprefclk_ss_percentage, |
234 | clk_dce->dprefclk_ss_divider), 200); | 234 | clk_dce->dprefclk_ss_divider), 200); |
235 | struct fixed32_32 adj_dp_ref_clk_khz; | 235 | struct fixed31_32 adj_dp_ref_clk_khz; |
236 | 236 | ||
237 | ss_percentage = dal_fixed32_32_sub(dal_fixed32_32_one, | 237 | ss_percentage = dc_fixpt_sub(dc_fixpt_one, |
238 | ss_percentage); | 238 | ss_percentage); |
239 | adj_dp_ref_clk_khz = | 239 | adj_dp_ref_clk_khz = |
240 | dal_fixed32_32_mul_int( | 240 | dc_fixpt_mul_int( |
241 | ss_percentage, | 241 | ss_percentage, |
242 | dp_ref_clk_khz); | 242 | dp_ref_clk_khz); |
243 | dp_ref_clk_khz = dal_fixed32_32_floor(adj_dp_ref_clk_khz); | 243 | dp_ref_clk_khz = dc_fixpt_floor(adj_dp_ref_clk_khz); |
244 | } | 244 | } |
245 | 245 | ||
246 | return dp_ref_clk_khz; | 246 | return dp_ref_clk_khz; |
@@ -256,19 +256,19 @@ static int dce_clocks_get_dp_ref_freq_wrkaround(struct display_clock *clk) | |||
256 | int dp_ref_clk_khz = 600000; | 256 | int dp_ref_clk_khz = 600000; |
257 | 257 | ||
258 | if (clk_dce->ss_on_dprefclk && clk_dce->dprefclk_ss_divider != 0) { | 258 | if (clk_dce->ss_on_dprefclk && clk_dce->dprefclk_ss_divider != 0) { |
259 | struct fixed32_32 ss_percentage = dal_fixed32_32_div_int( | 259 | struct fixed31_32 ss_percentage = dc_fixpt_div_int( |
260 | dal_fixed32_32_from_fraction( | 260 | dc_fixpt_from_fraction( |
261 | clk_dce->dprefclk_ss_percentage, | 261 | clk_dce->dprefclk_ss_percentage, |
262 | clk_dce->dprefclk_ss_divider), 200); | 262 | clk_dce->dprefclk_ss_divider), 200); |
263 | struct fixed32_32 adj_dp_ref_clk_khz; | 263 | struct fixed31_32 adj_dp_ref_clk_khz; |
264 | 264 | ||
265 | ss_percentage = dal_fixed32_32_sub(dal_fixed32_32_one, | 265 | ss_percentage = dc_fixpt_sub(dc_fixpt_one, |
266 | ss_percentage); | 266 | ss_percentage); |
267 | adj_dp_ref_clk_khz = | 267 | adj_dp_ref_clk_khz = |
268 | dal_fixed32_32_mul_int( | 268 | dc_fixpt_mul_int( |
269 | ss_percentage, | 269 | ss_percentage, |
270 | dp_ref_clk_khz); | 270 | dp_ref_clk_khz); |
271 | dp_ref_clk_khz = dal_fixed32_32_floor(adj_dp_ref_clk_khz); | 271 | dp_ref_clk_khz = dc_fixpt_floor(adj_dp_ref_clk_khz); |
272 | } | 272 | } |
273 | 273 | ||
274 | return dp_ref_clk_khz; | 274 | return dp_ref_clk_khz; |
@@ -413,9 +413,12 @@ static int dce112_set_clock( | |||
413 | /*VBIOS will determine DPREFCLK frequency, so we don't set it*/ | 413 | /*VBIOS will determine DPREFCLK frequency, so we don't set it*/ |
414 | dce_clk_params.target_clock_frequency = 0; | 414 | dce_clk_params.target_clock_frequency = 0; |
415 | dce_clk_params.clock_type = DCECLOCK_TYPE_DPREFCLK; | 415 | dce_clk_params.clock_type = DCECLOCK_TYPE_DPREFCLK; |
416 | dce_clk_params.flags.USE_GENLOCK_AS_SOURCE_FOR_DPREFCLK = | 416 | if (!ASICREV_IS_VEGA20_P(clk->ctx->asic_id.hw_internal_rev)) |
417 | dce_clk_params.flags.USE_GENLOCK_AS_SOURCE_FOR_DPREFCLK = | ||
417 | (dce_clk_params.pll_id == | 418 | (dce_clk_params.pll_id == |
418 | CLOCK_SOURCE_COMBO_DISPLAY_PLL0); | 419 | CLOCK_SOURCE_COMBO_DISPLAY_PLL0); |
420 | else | ||
421 | dce_clk_params.flags.USE_GENLOCK_AS_SOURCE_FOR_DPREFCLK = false; | ||
419 | 422 | ||
420 | bp->funcs->set_dce_clock(bp, &dce_clk_params); | 423 | bp->funcs->set_dce_clock(bp, &dce_clk_params); |
421 | 424 | ||
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 2ee3d9bf1062..a576b8bbb3cd 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "dce_dmcu.h" | 28 | #include "dce_dmcu.h" |
29 | #include "dm_services.h" | 29 | #include "dm_services.h" |
30 | #include "reg_helper.h" | 30 | #include "reg_helper.h" |
31 | #include "fixed32_32.h" | 31 | #include "fixed31_32.h" |
32 | #include "dc.h" | 32 | #include "dc.h" |
33 | 33 | ||
34 | #define TO_DCE_DMCU(dmcu)\ | 34 | #define TO_DCE_DMCU(dmcu)\ |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_ipp.c b/drivers/gpu/drm/amd/display/dc/dce/dce_ipp.c index d737e911971b..5d9506b3d46b 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_ipp.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_ipp.c | |||
@@ -195,13 +195,13 @@ static void dce_ipp_program_input_lut( | |||
195 | 195 | ||
196 | for (i = 0; i < gamma->num_entries; i++) { | 196 | for (i = 0; i < gamma->num_entries; i++) { |
197 | REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, | 197 | REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, |
198 | dal_fixed31_32_round( | 198 | dc_fixpt_round( |
199 | gamma->entries.red[i])); | 199 | gamma->entries.red[i])); |
200 | REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, | 200 | REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, |
201 | dal_fixed31_32_round( | 201 | dc_fixpt_round( |
202 | gamma->entries.green[i])); | 202 | gamma->entries.green[i])); |
203 | REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, | 203 | REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, |
204 | dal_fixed31_32_round( | 204 | dc_fixpt_round( |
205 | gamma->entries.blue[i])); | 205 | gamma->entries.blue[i])); |
206 | } | 206 | } |
207 | 207 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_scl_filters.c b/drivers/gpu/drm/amd/display/dc/dce/dce_scl_filters.c index 6243450b41b7..48862bebf29e 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_scl_filters.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_scl_filters.c | |||
@@ -1014,11 +1014,11 @@ static const uint16_t filter_8tap_64p_183[264] = { | |||
1014 | 1014 | ||
1015 | const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio) | 1015 | const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio) |
1016 | { | 1016 | { |
1017 | if (ratio.value < dal_fixed31_32_one.value) | 1017 | if (ratio.value < dc_fixpt_one.value) |
1018 | return filter_3tap_16p_upscale; | 1018 | return filter_3tap_16p_upscale; |
1019 | else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) | 1019 | else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) |
1020 | return filter_3tap_16p_117; | 1020 | return filter_3tap_16p_117; |
1021 | else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) | 1021 | else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) |
1022 | return filter_3tap_16p_150; | 1022 | return filter_3tap_16p_150; |
1023 | else | 1023 | else |
1024 | return filter_3tap_16p_183; | 1024 | return filter_3tap_16p_183; |
@@ -1026,11 +1026,11 @@ const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio) | |||
1026 | 1026 | ||
1027 | const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio) | 1027 | const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio) |
1028 | { | 1028 | { |
1029 | if (ratio.value < dal_fixed31_32_one.value) | 1029 | if (ratio.value < dc_fixpt_one.value) |
1030 | return filter_3tap_64p_upscale; | 1030 | return filter_3tap_64p_upscale; |
1031 | else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) | 1031 | else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) |
1032 | return filter_3tap_64p_117; | 1032 | return filter_3tap_64p_117; |
1033 | else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) | 1033 | else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) |
1034 | return filter_3tap_64p_150; | 1034 | return filter_3tap_64p_150; |
1035 | else | 1035 | else |
1036 | return filter_3tap_64p_183; | 1036 | return filter_3tap_64p_183; |
@@ -1038,11 +1038,11 @@ const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio) | |||
1038 | 1038 | ||
1039 | const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio) | 1039 | const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio) |
1040 | { | 1040 | { |
1041 | if (ratio.value < dal_fixed31_32_one.value) | 1041 | if (ratio.value < dc_fixpt_one.value) |
1042 | return filter_4tap_16p_upscale; | 1042 | return filter_4tap_16p_upscale; |
1043 | else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) | 1043 | else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) |
1044 | return filter_4tap_16p_117; | 1044 | return filter_4tap_16p_117; |
1045 | else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) | 1045 | else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) |
1046 | return filter_4tap_16p_150; | 1046 | return filter_4tap_16p_150; |
1047 | else | 1047 | else |
1048 | return filter_4tap_16p_183; | 1048 | return filter_4tap_16p_183; |
@@ -1050,11 +1050,11 @@ const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio) | |||
1050 | 1050 | ||
1051 | const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio) | 1051 | const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio) |
1052 | { | 1052 | { |
1053 | if (ratio.value < dal_fixed31_32_one.value) | 1053 | if (ratio.value < dc_fixpt_one.value) |
1054 | return filter_4tap_64p_upscale; | 1054 | return filter_4tap_64p_upscale; |
1055 | else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) | 1055 | else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) |
1056 | return filter_4tap_64p_117; | 1056 | return filter_4tap_64p_117; |
1057 | else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) | 1057 | else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) |
1058 | return filter_4tap_64p_150; | 1058 | return filter_4tap_64p_150; |
1059 | else | 1059 | else |
1060 | return filter_4tap_64p_183; | 1060 | return filter_4tap_64p_183; |
@@ -1062,11 +1062,11 @@ const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio) | |||
1062 | 1062 | ||
1063 | const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio) | 1063 | const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio) |
1064 | { | 1064 | { |
1065 | if (ratio.value < dal_fixed31_32_one.value) | 1065 | if (ratio.value < dc_fixpt_one.value) |
1066 | return filter_5tap_64p_upscale; | 1066 | return filter_5tap_64p_upscale; |
1067 | else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) | 1067 | else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) |
1068 | return filter_5tap_64p_117; | 1068 | return filter_5tap_64p_117; |
1069 | else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) | 1069 | else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) |
1070 | return filter_5tap_64p_150; | 1070 | return filter_5tap_64p_150; |
1071 | else | 1071 | else |
1072 | return filter_5tap_64p_183; | 1072 | return filter_5tap_64p_183; |
@@ -1074,11 +1074,11 @@ const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio) | |||
1074 | 1074 | ||
1075 | const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio) | 1075 | const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio) |
1076 | { | 1076 | { |
1077 | if (ratio.value < dal_fixed31_32_one.value) | 1077 | if (ratio.value < dc_fixpt_one.value) |
1078 | return filter_6tap_64p_upscale; | 1078 | return filter_6tap_64p_upscale; |
1079 | else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) | 1079 | else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) |
1080 | return filter_6tap_64p_117; | 1080 | return filter_6tap_64p_117; |
1081 | else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) | 1081 | else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) |
1082 | return filter_6tap_64p_150; | 1082 | return filter_6tap_64p_150; |
1083 | else | 1083 | else |
1084 | return filter_6tap_64p_183; | 1084 | return filter_6tap_64p_183; |
@@ -1086,11 +1086,11 @@ const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio) | |||
1086 | 1086 | ||
1087 | const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio) | 1087 | const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio) |
1088 | { | 1088 | { |
1089 | if (ratio.value < dal_fixed31_32_one.value) | 1089 | if (ratio.value < dc_fixpt_one.value) |
1090 | return filter_7tap_64p_upscale; | 1090 | return filter_7tap_64p_upscale; |
1091 | else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) | 1091 | else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) |
1092 | return filter_7tap_64p_117; | 1092 | return filter_7tap_64p_117; |
1093 | else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) | 1093 | else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) |
1094 | return filter_7tap_64p_150; | 1094 | return filter_7tap_64p_150; |
1095 | else | 1095 | else |
1096 | return filter_7tap_64p_183; | 1096 | return filter_7tap_64p_183; |
@@ -1098,11 +1098,11 @@ const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio) | |||
1098 | 1098 | ||
1099 | const uint16_t *get_filter_8tap_64p(struct fixed31_32 ratio) | 1099 | const uint16_t *get_filter_8tap_64p(struct fixed31_32 ratio) |
1100 | { | 1100 | { |
1101 | if (ratio.value < dal_fixed31_32_one.value) | 1101 | if (ratio.value < dc_fixpt_one.value) |
1102 | return filter_8tap_64p_upscale; | 1102 | return filter_8tap_64p_upscale; |
1103 | else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) | 1103 | else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) |
1104 | return filter_8tap_64p_117; | 1104 | return filter_8tap_64p_117; |
1105 | else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) | 1105 | else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) |
1106 | return filter_8tap_64p_150; | 1106 | return filter_8tap_64p_150; |
1107 | else | 1107 | else |
1108 | return filter_8tap_64p_183; | 1108 | return filter_8tap_64p_183; |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c index e265a0abe361..0a6d483dc046 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c | |||
@@ -683,11 +683,11 @@ static void dce110_stream_encoder_set_mst_bandwidth( | |||
683 | struct fixed31_32 avg_time_slots_per_mtp) | 683 | struct fixed31_32 avg_time_slots_per_mtp) |
684 | { | 684 | { |
685 | struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc); | 685 | struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc); |
686 | uint32_t x = dal_fixed31_32_floor( | 686 | uint32_t x = dc_fixpt_floor( |
687 | avg_time_slots_per_mtp); | 687 | avg_time_slots_per_mtp); |
688 | uint32_t y = dal_fixed31_32_ceil( | 688 | uint32_t y = dc_fixpt_ceil( |
689 | dal_fixed31_32_shl( | 689 | dc_fixpt_shl( |
690 | dal_fixed31_32_sub_int( | 690 | dc_fixpt_sub_int( |
691 | avg_time_slots_per_mtp, | 691 | avg_time_slots_per_mtp, |
692 | x), | 692 | x), |
693 | 26)); | 693 | 26)); |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c index 832c5daada35..a02e719d7794 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #define DC_LOGGER \ | 41 | #define DC_LOGGER \ |
42 | xfm_dce->base.ctx->logger | 42 | xfm_dce->base.ctx->logger |
43 | 43 | ||
44 | #define IDENTITY_RATIO(ratio) (dal_fixed31_32_u2d19(ratio) == (1 << 19)) | 44 | #define IDENTITY_RATIO(ratio) (dc_fixpt_u2d19(ratio) == (1 << 19)) |
45 | #define GAMUT_MATRIX_SIZE 12 | 45 | #define GAMUT_MATRIX_SIZE 12 |
46 | #define SCL_PHASES 16 | 46 | #define SCL_PHASES 16 |
47 | 47 | ||
@@ -256,27 +256,27 @@ static void calculate_inits( | |||
256 | struct fixed31_32 v_init; | 256 | struct fixed31_32 v_init; |
257 | 257 | ||
258 | inits->h_int_scale_ratio = | 258 | inits->h_int_scale_ratio = |
259 | dal_fixed31_32_u2d19(data->ratios.horz) << 5; | 259 | dc_fixpt_u2d19(data->ratios.horz) << 5; |
260 | inits->v_int_scale_ratio = | 260 | inits->v_int_scale_ratio = |
261 | dal_fixed31_32_u2d19(data->ratios.vert) << 5; | 261 | dc_fixpt_u2d19(data->ratios.vert) << 5; |
262 | 262 | ||
263 | h_init = | 263 | h_init = |
264 | dal_fixed31_32_div_int( | 264 | dc_fixpt_div_int( |
265 | dal_fixed31_32_add( | 265 | dc_fixpt_add( |
266 | data->ratios.horz, | 266 | data->ratios.horz, |
267 | dal_fixed31_32_from_int(data->taps.h_taps + 1)), | 267 | dc_fixpt_from_int(data->taps.h_taps + 1)), |
268 | 2); | 268 | 2); |
269 | inits->h_init.integer = dal_fixed31_32_floor(h_init); | 269 | inits->h_init.integer = dc_fixpt_floor(h_init); |
270 | inits->h_init.fraction = dal_fixed31_32_u0d19(h_init) << 5; | 270 | inits->h_init.fraction = dc_fixpt_u0d19(h_init) << 5; |
271 | 271 | ||
272 | v_init = | 272 | v_init = |
273 | dal_fixed31_32_div_int( | 273 | dc_fixpt_div_int( |
274 | dal_fixed31_32_add( | 274 | dc_fixpt_add( |
275 | data->ratios.vert, | 275 | data->ratios.vert, |
276 | dal_fixed31_32_from_int(data->taps.v_taps + 1)), | 276 | dc_fixpt_from_int(data->taps.v_taps + 1)), |
277 | 2); | 277 | 2); |
278 | inits->v_init.integer = dal_fixed31_32_floor(v_init); | 278 | inits->v_init.integer = dc_fixpt_floor(v_init); |
279 | inits->v_init.fraction = dal_fixed31_32_u0d19(v_init) << 5; | 279 | inits->v_init.fraction = dc_fixpt_u0d19(v_init) << 5; |
280 | } | 280 | } |
281 | 281 | ||
282 | static void program_scl_ratios_inits( | 282 | static void program_scl_ratios_inits( |
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 2288d0aa773b..a92fb0aa2ff3 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 | |||
@@ -509,19 +509,19 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf, | |||
509 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; | 509 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; |
510 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; | 510 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; |
511 | 511 | ||
512 | arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | 512 | arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
513 | dal_fixed31_32_from_int(region_start)); | 513 | dc_fixpt_from_int(region_start)); |
514 | arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | 514 | arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
515 | dal_fixed31_32_from_int(region_end)); | 515 | dc_fixpt_from_int(region_end)); |
516 | 516 | ||
517 | y_r = rgb_resulted[0].red; | 517 | y_r = rgb_resulted[0].red; |
518 | y_g = rgb_resulted[0].green; | 518 | y_g = rgb_resulted[0].green; |
519 | y_b = rgb_resulted[0].blue; | 519 | y_b = rgb_resulted[0].blue; |
520 | 520 | ||
521 | y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b)); | 521 | y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b)); |
522 | 522 | ||
523 | arr_points[0].y = y1_min; | 523 | arr_points[0].y = y1_min; |
524 | arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, | 524 | arr_points[0].slope = dc_fixpt_div(arr_points[0].y, |
525 | arr_points[0].x); | 525 | arr_points[0].x); |
526 | 526 | ||
527 | y_r = rgb_resulted[hw_points - 1].red; | 527 | y_r = rgb_resulted[hw_points - 1].red; |
@@ -531,21 +531,21 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf, | |||
531 | /* see comment above, m_arrPoints[1].y should be the Y value for the | 531 | /* see comment above, m_arrPoints[1].y should be the Y value for the |
532 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) | 532 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) |
533 | */ | 533 | */ |
534 | y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b)); | 534 | y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b)); |
535 | 535 | ||
536 | arr_points[1].y = y3_max; | 536 | arr_points[1].y = y3_max; |
537 | 537 | ||
538 | arr_points[1].slope = dal_fixed31_32_zero; | 538 | arr_points[1].slope = dc_fixpt_zero; |
539 | 539 | ||
540 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { | 540 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { |
541 | /* for PQ, we want to have a straight line from last HW X point, | 541 | /* for PQ, we want to have a straight line from last HW X point, |
542 | * and the slope to be such that we hit 1.0 at 10000 nits. | 542 | * and the slope to be such that we hit 1.0 at 10000 nits. |
543 | */ | 543 | */ |
544 | const struct fixed31_32 end_value = dal_fixed31_32_from_int(125); | 544 | const struct fixed31_32 end_value = dc_fixpt_from_int(125); |
545 | 545 | ||
546 | arr_points[1].slope = dal_fixed31_32_div( | 546 | arr_points[1].slope = dc_fixpt_div( |
547 | dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y), | 547 | dc_fixpt_sub(dc_fixpt_one, arr_points[1].y), |
548 | dal_fixed31_32_sub(end_value, arr_points[1].x)); | 548 | dc_fixpt_sub(end_value, arr_points[1].x)); |
549 | } | 549 | } |
550 | 550 | ||
551 | regamma_params->hw_points_num = hw_points; | 551 | regamma_params->hw_points_num = hw_points; |
@@ -569,16 +569,16 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf, | |||
569 | i = 1; | 569 | i = 1; |
570 | 570 | ||
571 | while (i != hw_points + 1) { | 571 | while (i != hw_points + 1) { |
572 | if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red)) | 572 | if (dc_fixpt_lt(rgb_plus_1->red, rgb->red)) |
573 | rgb_plus_1->red = rgb->red; | 573 | rgb_plus_1->red = rgb->red; |
574 | if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green)) | 574 | if (dc_fixpt_lt(rgb_plus_1->green, rgb->green)) |
575 | rgb_plus_1->green = rgb->green; | 575 | rgb_plus_1->green = rgb->green; |
576 | if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue)) | 576 | if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue)) |
577 | rgb_plus_1->blue = rgb->blue; | 577 | rgb_plus_1->blue = rgb->blue; |
578 | 578 | ||
579 | rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red); | 579 | rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); |
580 | rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green); | 580 | rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); |
581 | rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue); | 581 | rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue); |
582 | 582 | ||
583 | ++rgb_plus_1; | 583 | ++rgb_plus_1; |
584 | ++rgb; | 584 | ++rgb; |
@@ -2269,74 +2269,6 @@ static void program_gamut_remap(struct pipe_ctx *pipe_ctx) | |||
2269 | 2269 | ||
2270 | pipe_ctx->plane_res.xfm->funcs->transform_set_gamut_remap(pipe_ctx->plane_res.xfm, &adjust); | 2270 | pipe_ctx->plane_res.xfm->funcs->transform_set_gamut_remap(pipe_ctx->plane_res.xfm, &adjust); |
2271 | } | 2271 | } |
2272 | |||
2273 | /** | ||
2274 | * TODO REMOVE, USE UPDATE INSTEAD | ||
2275 | */ | ||
2276 | static void set_plane_config( | ||
2277 | const struct dc *dc, | ||
2278 | struct pipe_ctx *pipe_ctx, | ||
2279 | struct resource_context *res_ctx) | ||
2280 | { | ||
2281 | struct mem_input *mi = pipe_ctx->plane_res.mi; | ||
2282 | struct dc_plane_state *plane_state = pipe_ctx->plane_state; | ||
2283 | struct xfm_grph_csc_adjustment adjust; | ||
2284 | struct out_csc_color_matrix tbl_entry; | ||
2285 | unsigned int i; | ||
2286 | |||
2287 | memset(&adjust, 0, sizeof(adjust)); | ||
2288 | memset(&tbl_entry, 0, sizeof(tbl_entry)); | ||
2289 | adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS; | ||
2290 | |||
2291 | dce_enable_fe_clock(dc->hwseq, mi->inst, true); | ||
2292 | |||
2293 | set_default_colors(pipe_ctx); | ||
2294 | if (pipe_ctx->stream->csc_color_matrix.enable_adjustment == true) { | ||
2295 | tbl_entry.color_space = | ||
2296 | pipe_ctx->stream->output_color_space; | ||
2297 | |||
2298 | for (i = 0; i < 12; i++) | ||
2299 | tbl_entry.regval[i] = | ||
2300 | pipe_ctx->stream->csc_color_matrix.matrix[i]; | ||
2301 | |||
2302 | pipe_ctx->plane_res.xfm->funcs->opp_set_csc_adjustment | ||
2303 | (pipe_ctx->plane_res.xfm, &tbl_entry); | ||
2304 | } | ||
2305 | |||
2306 | if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) { | ||
2307 | adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW; | ||
2308 | |||
2309 | for (i = 0; i < CSC_TEMPERATURE_MATRIX_SIZE; i++) | ||
2310 | adjust.temperature_matrix[i] = | ||
2311 | pipe_ctx->stream->gamut_remap_matrix.matrix[i]; | ||
2312 | } | ||
2313 | |||
2314 | pipe_ctx->plane_res.xfm->funcs->transform_set_gamut_remap(pipe_ctx->plane_res.xfm, &adjust); | ||
2315 | |||
2316 | pipe_ctx->plane_res.scl_data.lb_params.alpha_en = pipe_ctx->bottom_pipe != 0; | ||
2317 | program_scaler(dc, pipe_ctx); | ||
2318 | |||
2319 | program_surface_visibility(dc, pipe_ctx); | ||
2320 | |||
2321 | mi->funcs->mem_input_program_surface_config( | ||
2322 | mi, | ||
2323 | plane_state->format, | ||
2324 | &plane_state->tiling_info, | ||
2325 | &plane_state->plane_size, | ||
2326 | plane_state->rotation, | ||
2327 | NULL, | ||
2328 | false); | ||
2329 | if (mi->funcs->set_blank) | ||
2330 | mi->funcs->set_blank(mi, pipe_ctx->plane_state->visible); | ||
2331 | |||
2332 | if (dc->config.gpu_vm_support) | ||
2333 | mi->funcs->mem_input_program_pte_vm( | ||
2334 | pipe_ctx->plane_res.mi, | ||
2335 | plane_state->format, | ||
2336 | &plane_state->tiling_info, | ||
2337 | plane_state->rotation); | ||
2338 | } | ||
2339 | |||
2340 | static void update_plane_addr(const struct dc *dc, | 2272 | static void update_plane_addr(const struct dc *dc, |
2341 | struct pipe_ctx *pipe_ctx) | 2273 | struct pipe_ctx *pipe_ctx) |
2342 | { | 2274 | { |
@@ -3023,7 +2955,6 @@ static const struct hw_sequencer_funcs dce110_funcs = { | |||
3023 | .init_hw = init_hw, | 2955 | .init_hw = init_hw, |
3024 | .apply_ctx_to_hw = dce110_apply_ctx_to_hw, | 2956 | .apply_ctx_to_hw = dce110_apply_ctx_to_hw, |
3025 | .apply_ctx_for_surface = dce110_apply_ctx_for_surface, | 2957 | .apply_ctx_for_surface = dce110_apply_ctx_for_surface, |
3026 | .set_plane_config = set_plane_config, | ||
3027 | .update_plane_addr = update_plane_addr, | 2958 | .update_plane_addr = update_plane_addr, |
3028 | .update_pending_status = dce110_update_pending_status, | 2959 | .update_pending_status = dce110_update_pending_status, |
3029 | .set_input_transfer_func = dce110_set_input_transfer_func, | 2960 | .set_input_transfer_func = dce110_set_input_transfer_func, |
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_transform_v.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_transform_v.c index 8ba3c12fc608..a7dce060204f 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_transform_v.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_transform_v.c | |||
@@ -373,13 +373,13 @@ static void calculate_inits( | |||
373 | struct rect *chroma_viewport) | 373 | struct rect *chroma_viewport) |
374 | { | 374 | { |
375 | inits->h_int_scale_ratio_luma = | 375 | inits->h_int_scale_ratio_luma = |
376 | dal_fixed31_32_u2d19(data->ratios.horz) << 5; | 376 | dc_fixpt_u2d19(data->ratios.horz) << 5; |
377 | inits->v_int_scale_ratio_luma = | 377 | inits->v_int_scale_ratio_luma = |
378 | dal_fixed31_32_u2d19(data->ratios.vert) << 5; | 378 | dc_fixpt_u2d19(data->ratios.vert) << 5; |
379 | inits->h_int_scale_ratio_chroma = | 379 | inits->h_int_scale_ratio_chroma = |
380 | dal_fixed31_32_u2d19(data->ratios.horz_c) << 5; | 380 | dc_fixpt_u2d19(data->ratios.horz_c) << 5; |
381 | inits->v_int_scale_ratio_chroma = | 381 | inits->v_int_scale_ratio_chroma = |
382 | dal_fixed31_32_u2d19(data->ratios.vert_c) << 5; | 382 | dc_fixpt_u2d19(data->ratios.vert_c) << 5; |
383 | 383 | ||
384 | inits->h_init_luma.integer = 1; | 384 | inits->h_init_luma.integer = 1; |
385 | inits->v_init_luma.integer = 1; | 385 | inits->v_init_luma.integer = 1; |
diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c index fda01574d1ba..2d58daccc005 100644 --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | |||
@@ -814,14 +814,25 @@ static void bw_calcs_data_update_from_pplib(struct dc *dc) | |||
814 | dm_pp_notify_wm_clock_changes(dc->ctx, &clk_ranges); | 814 | dm_pp_notify_wm_clock_changes(dc->ctx, &clk_ranges); |
815 | } | 815 | } |
816 | 816 | ||
817 | static uint32_t read_pipe_fuses(struct dc_context *ctx) | ||
818 | { | ||
819 | uint32_t value = dm_read_reg_soc15(ctx, mmCC_DC_PIPE_DIS, 0); | ||
820 | /* VG20 support max 6 pipes */ | ||
821 | value = value & 0x3f; | ||
822 | return value; | ||
823 | } | ||
824 | |||
817 | static bool construct( | 825 | static bool construct( |
818 | uint8_t num_virtual_links, | 826 | uint8_t num_virtual_links, |
819 | struct dc *dc, | 827 | struct dc *dc, |
820 | struct dce110_resource_pool *pool) | 828 | struct dce110_resource_pool *pool) |
821 | { | 829 | { |
822 | unsigned int i; | 830 | unsigned int i; |
831 | int j; | ||
823 | struct dc_context *ctx = dc->ctx; | 832 | struct dc_context *ctx = dc->ctx; |
824 | struct irq_service_init_data irq_init_data; | 833 | struct irq_service_init_data irq_init_data; |
834 | bool harvest_enabled = ASICREV_IS_VEGA20_P(ctx->asic_id.hw_internal_rev); | ||
835 | uint32_t pipe_fuses; | ||
825 | 836 | ||
826 | ctx->dc_bios->regs = &bios_regs; | 837 | ctx->dc_bios->regs = &bios_regs; |
827 | 838 | ||
@@ -915,28 +926,41 @@ static bool construct( | |||
915 | if (!pool->base.irqs) | 926 | if (!pool->base.irqs) |
916 | goto irqs_create_fail; | 927 | goto irqs_create_fail; |
917 | 928 | ||
929 | /* retrieve valid pipe fuses */ | ||
930 | if (harvest_enabled) | ||
931 | pipe_fuses = read_pipe_fuses(ctx); | ||
932 | |||
933 | /* index to valid pipe resource */ | ||
934 | j = 0; | ||
918 | for (i = 0; i < pool->base.pipe_count; i++) { | 935 | for (i = 0; i < pool->base.pipe_count; i++) { |
919 | pool->base.timing_generators[i] = | 936 | if (harvest_enabled) { |
937 | if ((pipe_fuses & (1 << i)) != 0) { | ||
938 | dm_error("DC: skip invalid pipe %d!\n", i); | ||
939 | continue; | ||
940 | } | ||
941 | } | ||
942 | |||
943 | pool->base.timing_generators[j] = | ||
920 | dce120_timing_generator_create( | 944 | dce120_timing_generator_create( |
921 | ctx, | 945 | ctx, |
922 | i, | 946 | i, |
923 | &dce120_tg_offsets[i]); | 947 | &dce120_tg_offsets[i]); |
924 | if (pool->base.timing_generators[i] == NULL) { | 948 | if (pool->base.timing_generators[j] == NULL) { |
925 | BREAK_TO_DEBUGGER(); | 949 | BREAK_TO_DEBUGGER(); |
926 | dm_error("DC: failed to create tg!\n"); | 950 | dm_error("DC: failed to create tg!\n"); |
927 | goto controller_create_fail; | 951 | goto controller_create_fail; |
928 | } | 952 | } |
929 | 953 | ||
930 | pool->base.mis[i] = dce120_mem_input_create(ctx, i); | 954 | pool->base.mis[j] = dce120_mem_input_create(ctx, i); |
931 | 955 | ||
932 | if (pool->base.mis[i] == NULL) { | 956 | if (pool->base.mis[j] == NULL) { |
933 | BREAK_TO_DEBUGGER(); | 957 | BREAK_TO_DEBUGGER(); |
934 | dm_error( | 958 | dm_error( |
935 | "DC: failed to create memory input!\n"); | 959 | "DC: failed to create memory input!\n"); |
936 | goto controller_create_fail; | 960 | goto controller_create_fail; |
937 | } | 961 | } |
938 | 962 | ||
939 | pool->base.ipps[i] = dce120_ipp_create(ctx, i); | 963 | pool->base.ipps[j] = dce120_ipp_create(ctx, i); |
940 | if (pool->base.ipps[i] == NULL) { | 964 | if (pool->base.ipps[i] == NULL) { |
941 | BREAK_TO_DEBUGGER(); | 965 | BREAK_TO_DEBUGGER(); |
942 | dm_error( | 966 | dm_error( |
@@ -944,7 +968,7 @@ static bool construct( | |||
944 | goto controller_create_fail; | 968 | goto controller_create_fail; |
945 | } | 969 | } |
946 | 970 | ||
947 | pool->base.transforms[i] = dce120_transform_create(ctx, i); | 971 | pool->base.transforms[j] = dce120_transform_create(ctx, i); |
948 | if (pool->base.transforms[i] == NULL) { | 972 | if (pool->base.transforms[i] == NULL) { |
949 | BREAK_TO_DEBUGGER(); | 973 | BREAK_TO_DEBUGGER(); |
950 | dm_error( | 974 | dm_error( |
@@ -952,16 +976,23 @@ static bool construct( | |||
952 | goto res_create_fail; | 976 | goto res_create_fail; |
953 | } | 977 | } |
954 | 978 | ||
955 | pool->base.opps[i] = dce120_opp_create( | 979 | pool->base.opps[j] = dce120_opp_create( |
956 | ctx, | 980 | ctx, |
957 | i); | 981 | i); |
958 | if (pool->base.opps[i] == NULL) { | 982 | if (pool->base.opps[j] == NULL) { |
959 | BREAK_TO_DEBUGGER(); | 983 | BREAK_TO_DEBUGGER(); |
960 | dm_error( | 984 | dm_error( |
961 | "DC: failed to create output pixel processor!\n"); | 985 | "DC: failed to create output pixel processor!\n"); |
962 | } | 986 | } |
987 | |||
988 | /* check next valid pipe */ | ||
989 | j++; | ||
963 | } | 990 | } |
964 | 991 | ||
992 | /* valid pipe num */ | ||
993 | pool->base.pipe_count = j; | ||
994 | pool->base.timing_generator_count = j; | ||
995 | |||
965 | if (!resource_construct(num_virtual_links, dc, &pool->base, | 996 | if (!resource_construct(num_virtual_links, dc, &pool->base, |
966 | &res_create_funcs)) | 997 | &res_create_funcs)) |
967 | goto res_create_fail; | 998 | goto res_create_fail; |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/Makefile b/drivers/gpu/drm/amd/display/dc/dcn10/Makefile index 5c69743a4b4f..84f52c63d95c 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn10/Makefile | |||
@@ -26,7 +26,7 @@ DCN10 = dcn10_resource.o dcn10_ipp.o dcn10_hw_sequencer.o \ | |||
26 | dcn10_dpp.o dcn10_opp.o dcn10_optc.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 dcn10_stream_encoder.o | 29 | dcn10_hubbub.o dcn10_stream_encoder.o dcn10_link_encoder.o |
30 | 30 | ||
31 | AMD_DAL_DCN10 = $(addprefix $(AMDDALPATH)/dc/dcn10/,$(DCN10)) | 31 | AMD_DAL_DCN10 = $(addprefix $(AMDDALPATH)/dc/dcn10/,$(DCN10)) |
32 | 32 | ||
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 96d5878e9ccd..5d95a997fd9f 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 | |||
@@ -169,7 +169,7 @@ bool cm_helper_convert_to_custom_float( | |||
169 | } | 169 | } |
170 | 170 | ||
171 | if (fixpoint == true) | 171 | if (fixpoint == true) |
172 | arr_points[1].custom_float_y = dal_fixed31_32_clamp_u0d14(arr_points[1].y); | 172 | arr_points[1].custom_float_y = dc_fixpt_clamp_u0d14(arr_points[1].y); |
173 | else if (!convert_to_custom_float_format(arr_points[1].y, &fmt, | 173 | else if (!convert_to_custom_float_format(arr_points[1].y, &fmt, |
174 | &arr_points[1].custom_float_y)) { | 174 | &arr_points[1].custom_float_y)) { |
175 | BREAK_TO_DEBUGGER(); | 175 | BREAK_TO_DEBUGGER(); |
@@ -327,19 +327,19 @@ bool cm_helper_translate_curve_to_hw_format( | |||
327 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; | 327 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; |
328 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; | 328 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; |
329 | 329 | ||
330 | arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | 330 | arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
331 | dal_fixed31_32_from_int(region_start)); | 331 | dc_fixpt_from_int(region_start)); |
332 | arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | 332 | arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
333 | dal_fixed31_32_from_int(region_end)); | 333 | dc_fixpt_from_int(region_end)); |
334 | 334 | ||
335 | y_r = rgb_resulted[0].red; | 335 | y_r = rgb_resulted[0].red; |
336 | y_g = rgb_resulted[0].green; | 336 | y_g = rgb_resulted[0].green; |
337 | y_b = rgb_resulted[0].blue; | 337 | y_b = rgb_resulted[0].blue; |
338 | 338 | ||
339 | y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b)); | 339 | y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b)); |
340 | 340 | ||
341 | arr_points[0].y = y1_min; | 341 | arr_points[0].y = y1_min; |
342 | arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, arr_points[0].x); | 342 | arr_points[0].slope = dc_fixpt_div(arr_points[0].y, arr_points[0].x); |
343 | y_r = rgb_resulted[hw_points - 1].red; | 343 | y_r = rgb_resulted[hw_points - 1].red; |
344 | y_g = rgb_resulted[hw_points - 1].green; | 344 | y_g = rgb_resulted[hw_points - 1].green; |
345 | y_b = rgb_resulted[hw_points - 1].blue; | 345 | y_b = rgb_resulted[hw_points - 1].blue; |
@@ -347,22 +347,22 @@ bool cm_helper_translate_curve_to_hw_format( | |||
347 | /* see comment above, m_arrPoints[1].y should be the Y value for the | 347 | /* see comment above, m_arrPoints[1].y should be the Y value for the |
348 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) | 348 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) |
349 | */ | 349 | */ |
350 | y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b)); | 350 | y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b)); |
351 | 351 | ||
352 | arr_points[1].y = y3_max; | 352 | arr_points[1].y = y3_max; |
353 | 353 | ||
354 | arr_points[1].slope = dal_fixed31_32_zero; | 354 | arr_points[1].slope = dc_fixpt_zero; |
355 | 355 | ||
356 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { | 356 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { |
357 | /* for PQ, we want to have a straight line from last HW X point, | 357 | /* for PQ, we want to have a straight line from last HW X point, |
358 | * and the slope to be such that we hit 1.0 at 10000 nits. | 358 | * and the slope to be such that we hit 1.0 at 10000 nits. |
359 | */ | 359 | */ |
360 | const struct fixed31_32 end_value = | 360 | const struct fixed31_32 end_value = |
361 | dal_fixed31_32_from_int(125); | 361 | dc_fixpt_from_int(125); |
362 | 362 | ||
363 | arr_points[1].slope = dal_fixed31_32_div( | 363 | arr_points[1].slope = dc_fixpt_div( |
364 | dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y), | 364 | dc_fixpt_sub(dc_fixpt_one, arr_points[1].y), |
365 | dal_fixed31_32_sub(end_value, arr_points[1].x)); | 365 | dc_fixpt_sub(end_value, arr_points[1].x)); |
366 | } | 366 | } |
367 | 367 | ||
368 | lut_params->hw_points_num = hw_points; | 368 | lut_params->hw_points_num = hw_points; |
@@ -386,24 +386,24 @@ bool cm_helper_translate_curve_to_hw_format( | |||
386 | 386 | ||
387 | i = 1; | 387 | i = 1; |
388 | while (i != hw_points + 1) { | 388 | while (i != hw_points + 1) { |
389 | if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red)) | 389 | if (dc_fixpt_lt(rgb_plus_1->red, rgb->red)) |
390 | rgb_plus_1->red = rgb->red; | 390 | rgb_plus_1->red = rgb->red; |
391 | if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green)) | 391 | if (dc_fixpt_lt(rgb_plus_1->green, rgb->green)) |
392 | rgb_plus_1->green = rgb->green; | 392 | rgb_plus_1->green = rgb->green; |
393 | if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue)) | 393 | if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue)) |
394 | rgb_plus_1->blue = rgb->blue; | 394 | rgb_plus_1->blue = rgb->blue; |
395 | 395 | ||
396 | rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red); | 396 | rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); |
397 | rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green); | 397 | rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); |
398 | rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue); | 398 | rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue); |
399 | 399 | ||
400 | if (fixpoint == true) { | 400 | if (fixpoint == true) { |
401 | rgb->delta_red_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_red); | 401 | rgb->delta_red_reg = dc_fixpt_clamp_u0d10(rgb->delta_red); |
402 | rgb->delta_green_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_green); | 402 | rgb->delta_green_reg = dc_fixpt_clamp_u0d10(rgb->delta_green); |
403 | rgb->delta_blue_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_blue); | 403 | rgb->delta_blue_reg = dc_fixpt_clamp_u0d10(rgb->delta_blue); |
404 | rgb->red_reg = dal_fixed31_32_clamp_u0d14(rgb->red); | 404 | rgb->red_reg = dc_fixpt_clamp_u0d14(rgb->red); |
405 | rgb->green_reg = dal_fixed31_32_clamp_u0d14(rgb->green); | 405 | rgb->green_reg = dc_fixpt_clamp_u0d14(rgb->green); |
406 | rgb->blue_reg = dal_fixed31_32_clamp_u0d14(rgb->blue); | 406 | rgb->blue_reg = dc_fixpt_clamp_u0d14(rgb->blue); |
407 | } | 407 | } |
408 | 408 | ||
409 | ++rgb_plus_1; | 409 | ++rgb_plus_1; |
@@ -489,19 +489,19 @@ bool cm_helper_translate_curve_to_degamma_hw_format( | |||
489 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; | 489 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; |
490 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; | 490 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; |
491 | 491 | ||
492 | arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | 492 | arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
493 | dal_fixed31_32_from_int(region_start)); | 493 | dc_fixpt_from_int(region_start)); |
494 | arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | 494 | arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
495 | dal_fixed31_32_from_int(region_end)); | 495 | dc_fixpt_from_int(region_end)); |
496 | 496 | ||
497 | y_r = rgb_resulted[0].red; | 497 | y_r = rgb_resulted[0].red; |
498 | y_g = rgb_resulted[0].green; | 498 | y_g = rgb_resulted[0].green; |
499 | y_b = rgb_resulted[0].blue; | 499 | y_b = rgb_resulted[0].blue; |
500 | 500 | ||
501 | y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b)); | 501 | y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b)); |
502 | 502 | ||
503 | arr_points[0].y = y1_min; | 503 | arr_points[0].y = y1_min; |
504 | arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, arr_points[0].x); | 504 | arr_points[0].slope = dc_fixpt_div(arr_points[0].y, arr_points[0].x); |
505 | y_r = rgb_resulted[hw_points - 1].red; | 505 | y_r = rgb_resulted[hw_points - 1].red; |
506 | y_g = rgb_resulted[hw_points - 1].green; | 506 | y_g = rgb_resulted[hw_points - 1].green; |
507 | y_b = rgb_resulted[hw_points - 1].blue; | 507 | y_b = rgb_resulted[hw_points - 1].blue; |
@@ -509,22 +509,22 @@ bool cm_helper_translate_curve_to_degamma_hw_format( | |||
509 | /* see comment above, m_arrPoints[1].y should be the Y value for the | 509 | /* see comment above, m_arrPoints[1].y should be the Y value for the |
510 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) | 510 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) |
511 | */ | 511 | */ |
512 | y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b)); | 512 | y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b)); |
513 | 513 | ||
514 | arr_points[1].y = y3_max; | 514 | arr_points[1].y = y3_max; |
515 | 515 | ||
516 | arr_points[1].slope = dal_fixed31_32_zero; | 516 | arr_points[1].slope = dc_fixpt_zero; |
517 | 517 | ||
518 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { | 518 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { |
519 | /* for PQ, we want to have a straight line from last HW X point, | 519 | /* for PQ, we want to have a straight line from last HW X point, |
520 | * and the slope to be such that we hit 1.0 at 10000 nits. | 520 | * and the slope to be such that we hit 1.0 at 10000 nits. |
521 | */ | 521 | */ |
522 | const struct fixed31_32 end_value = | 522 | const struct fixed31_32 end_value = |
523 | dal_fixed31_32_from_int(125); | 523 | dc_fixpt_from_int(125); |
524 | 524 | ||
525 | arr_points[1].slope = dal_fixed31_32_div( | 525 | arr_points[1].slope = dc_fixpt_div( |
526 | dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y), | 526 | dc_fixpt_sub(dc_fixpt_one, arr_points[1].y), |
527 | dal_fixed31_32_sub(end_value, arr_points[1].x)); | 527 | dc_fixpt_sub(end_value, arr_points[1].x)); |
528 | } | 528 | } |
529 | 529 | ||
530 | lut_params->hw_points_num = hw_points; | 530 | lut_params->hw_points_num = hw_points; |
@@ -548,16 +548,16 @@ bool cm_helper_translate_curve_to_degamma_hw_format( | |||
548 | 548 | ||
549 | i = 1; | 549 | i = 1; |
550 | while (i != hw_points + 1) { | 550 | while (i != hw_points + 1) { |
551 | if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red)) | 551 | if (dc_fixpt_lt(rgb_plus_1->red, rgb->red)) |
552 | rgb_plus_1->red = rgb->red; | 552 | rgb_plus_1->red = rgb->red; |
553 | if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green)) | 553 | if (dc_fixpt_lt(rgb_plus_1->green, rgb->green)) |
554 | rgb_plus_1->green = rgb->green; | 554 | rgb_plus_1->green = rgb->green; |
555 | if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue)) | 555 | if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue)) |
556 | rgb_plus_1->blue = rgb->blue; | 556 | rgb_plus_1->blue = rgb->blue; |
557 | 557 | ||
558 | rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red); | 558 | rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); |
559 | rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green); | 559 | rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); |
560 | rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue); | 560 | rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue); |
561 | 561 | ||
562 | ++rgb_plus_1; | 562 | ++rgb_plus_1; |
563 | ++rgb; | 563 | ++rgb; |
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 8c4d9e523331..46a35c7f01df 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c | |||
@@ -130,7 +130,7 @@ void dpp_set_gamut_remap_bypass(struct dcn10_dpp *dpp) | |||
130 | /* Gamut remap in bypass */ | 130 | /* Gamut remap in bypass */ |
131 | } | 131 | } |
132 | 132 | ||
133 | #define IDENTITY_RATIO(ratio) (dal_fixed31_32_u2d19(ratio) == (1 << 19)) | 133 | #define IDENTITY_RATIO(ratio) (dc_fixpt_u2d19(ratio) == (1 << 19)) |
134 | 134 | ||
135 | 135 | ||
136 | bool dpp_get_optimal_number_of_taps( | 136 | bool dpp_get_optimal_number_of_taps( |
@@ -152,6 +152,11 @@ bool dpp_get_optimal_number_of_taps( | |||
152 | scl_data->format == PIXEL_FORMAT_FP16) | 152 | scl_data->format == PIXEL_FORMAT_FP16) |
153 | return false; | 153 | return false; |
154 | 154 | ||
155 | if (scl_data->viewport.width > scl_data->h_active && | ||
156 | dpp->ctx->dc->debug.max_downscale_src_width != 0 && | ||
157 | scl_data->viewport.width > dpp->ctx->dc->debug.max_downscale_src_width) | ||
158 | return false; | ||
159 | |||
155 | /* TODO: add lb check */ | 160 | /* TODO: add lb check */ |
156 | 161 | ||
157 | /* No support for programming ratio of 4, drop to 3.99999.. */ | 162 | /* No support for programming ratio of 4, drop to 3.99999.. */ |
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 4f373c97804f..116977eb24e2 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 | |||
@@ -811,13 +811,13 @@ void dpp1_program_input_lut( | |||
811 | REG_UPDATE(CM_IGAM_LUT_RW_INDEX, CM_IGAM_LUT_RW_INDEX, 0); | 811 | REG_UPDATE(CM_IGAM_LUT_RW_INDEX, CM_IGAM_LUT_RW_INDEX, 0); |
812 | for (i = 0; i < gamma->num_entries; i++) { | 812 | for (i = 0; i < gamma->num_entries; i++) { |
813 | REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, | 813 | REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, |
814 | dal_fixed31_32_round( | 814 | dc_fixpt_round( |
815 | gamma->entries.red[i])); | 815 | gamma->entries.red[i])); |
816 | REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, | 816 | REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, |
817 | dal_fixed31_32_round( | 817 | dc_fixpt_round( |
818 | gamma->entries.green[i])); | 818 | gamma->entries.green[i])); |
819 | REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, | 819 | REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, |
820 | dal_fixed31_32_round( | 820 | dc_fixpt_round( |
821 | gamma->entries.blue[i])); | 821 | gamma->entries.blue[i])); |
822 | } | 822 | } |
823 | // Power off LUT memory | 823 | // Power off LUT memory |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c index 3eb824debf43..4ddd6273d5a5 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c | |||
@@ -169,7 +169,7 @@ static enum dscl_mode_sel dpp1_dscl_get_dscl_mode( | |||
169 | const struct scaler_data *data, | 169 | const struct scaler_data *data, |
170 | bool dbg_always_scale) | 170 | bool dbg_always_scale) |
171 | { | 171 | { |
172 | const long long one = dal_fixed31_32_one.value; | 172 | const long long one = dc_fixpt_one.value; |
173 | 173 | ||
174 | if (dpp_base->caps->dscl_data_proc_format == DSCL_DATA_PRCESSING_FIXED_FORMAT) { | 174 | if (dpp_base->caps->dscl_data_proc_format == DSCL_DATA_PRCESSING_FIXED_FORMAT) { |
175 | /* DSCL is processing data in fixed format */ | 175 | /* DSCL is processing data in fixed format */ |
@@ -464,8 +464,8 @@ static enum lb_memory_config dpp1_dscl_find_lb_memory_config(struct dcn10_dpp *d | |||
464 | int num_part_y, num_part_c; | 464 | int num_part_y, num_part_c; |
465 | int vtaps = scl_data->taps.v_taps; | 465 | int vtaps = scl_data->taps.v_taps; |
466 | int vtaps_c = scl_data->taps.v_taps_c; | 466 | int vtaps_c = scl_data->taps.v_taps_c; |
467 | int ceil_vratio = dal_fixed31_32_ceil(scl_data->ratios.vert); | 467 | int ceil_vratio = dc_fixpt_ceil(scl_data->ratios.vert); |
468 | int ceil_vratio_c = dal_fixed31_32_ceil(scl_data->ratios.vert_c); | 468 | int ceil_vratio_c = dc_fixpt_ceil(scl_data->ratios.vert_c); |
469 | enum lb_memory_config mem_cfg = LB_MEMORY_CONFIG_0; | 469 | enum lb_memory_config mem_cfg = LB_MEMORY_CONFIG_0; |
470 | 470 | ||
471 | if (dpp->base.ctx->dc->debug.use_max_lb) | 471 | if (dpp->base.ctx->dc->debug.use_max_lb) |
@@ -565,52 +565,52 @@ static void dpp1_dscl_set_manual_ratio_init( | |||
565 | uint32_t init_int = 0; | 565 | uint32_t init_int = 0; |
566 | 566 | ||
567 | REG_SET(SCL_HORZ_FILTER_SCALE_RATIO, 0, | 567 | REG_SET(SCL_HORZ_FILTER_SCALE_RATIO, 0, |
568 | SCL_H_SCALE_RATIO, dal_fixed31_32_u2d19(data->ratios.horz) << 5); | 568 | SCL_H_SCALE_RATIO, dc_fixpt_u2d19(data->ratios.horz) << 5); |
569 | 569 | ||
570 | REG_SET(SCL_VERT_FILTER_SCALE_RATIO, 0, | 570 | REG_SET(SCL_VERT_FILTER_SCALE_RATIO, 0, |
571 | SCL_V_SCALE_RATIO, dal_fixed31_32_u2d19(data->ratios.vert) << 5); | 571 | SCL_V_SCALE_RATIO, dc_fixpt_u2d19(data->ratios.vert) << 5); |
572 | 572 | ||
573 | REG_SET(SCL_HORZ_FILTER_SCALE_RATIO_C, 0, | 573 | REG_SET(SCL_HORZ_FILTER_SCALE_RATIO_C, 0, |
574 | SCL_H_SCALE_RATIO_C, dal_fixed31_32_u2d19(data->ratios.horz_c) << 5); | 574 | SCL_H_SCALE_RATIO_C, dc_fixpt_u2d19(data->ratios.horz_c) << 5); |
575 | 575 | ||
576 | REG_SET(SCL_VERT_FILTER_SCALE_RATIO_C, 0, | 576 | REG_SET(SCL_VERT_FILTER_SCALE_RATIO_C, 0, |
577 | SCL_V_SCALE_RATIO_C, dal_fixed31_32_u2d19(data->ratios.vert_c) << 5); | 577 | SCL_V_SCALE_RATIO_C, dc_fixpt_u2d19(data->ratios.vert_c) << 5); |
578 | 578 | ||
579 | /* | 579 | /* |
580 | * 0.24 format for fraction, first five bits zeroed | 580 | * 0.24 format for fraction, first five bits zeroed |
581 | */ | 581 | */ |
582 | init_frac = dal_fixed31_32_u0d19(data->inits.h) << 5; | 582 | init_frac = dc_fixpt_u0d19(data->inits.h) << 5; |
583 | init_int = dal_fixed31_32_floor(data->inits.h); | 583 | init_int = dc_fixpt_floor(data->inits.h); |
584 | REG_SET_2(SCL_HORZ_FILTER_INIT, 0, | 584 | REG_SET_2(SCL_HORZ_FILTER_INIT, 0, |
585 | SCL_H_INIT_FRAC, init_frac, | 585 | SCL_H_INIT_FRAC, init_frac, |
586 | SCL_H_INIT_INT, init_int); | 586 | SCL_H_INIT_INT, init_int); |
587 | 587 | ||
588 | init_frac = dal_fixed31_32_u0d19(data->inits.h_c) << 5; | 588 | init_frac = dc_fixpt_u0d19(data->inits.h_c) << 5; |
589 | init_int = dal_fixed31_32_floor(data->inits.h_c); | 589 | init_int = dc_fixpt_floor(data->inits.h_c); |
590 | REG_SET_2(SCL_HORZ_FILTER_INIT_C, 0, | 590 | REG_SET_2(SCL_HORZ_FILTER_INIT_C, 0, |
591 | SCL_H_INIT_FRAC_C, init_frac, | 591 | SCL_H_INIT_FRAC_C, init_frac, |
592 | SCL_H_INIT_INT_C, init_int); | 592 | SCL_H_INIT_INT_C, init_int); |
593 | 593 | ||
594 | init_frac = dal_fixed31_32_u0d19(data->inits.v) << 5; | 594 | init_frac = dc_fixpt_u0d19(data->inits.v) << 5; |
595 | init_int = dal_fixed31_32_floor(data->inits.v); | 595 | init_int = dc_fixpt_floor(data->inits.v); |
596 | REG_SET_2(SCL_VERT_FILTER_INIT, 0, | 596 | REG_SET_2(SCL_VERT_FILTER_INIT, 0, |
597 | SCL_V_INIT_FRAC, init_frac, | 597 | SCL_V_INIT_FRAC, init_frac, |
598 | SCL_V_INIT_INT, init_int); | 598 | SCL_V_INIT_INT, init_int); |
599 | 599 | ||
600 | init_frac = dal_fixed31_32_u0d19(data->inits.v_bot) << 5; | 600 | init_frac = dc_fixpt_u0d19(data->inits.v_bot) << 5; |
601 | init_int = dal_fixed31_32_floor(data->inits.v_bot); | 601 | init_int = dc_fixpt_floor(data->inits.v_bot); |
602 | REG_SET_2(SCL_VERT_FILTER_INIT_BOT, 0, | 602 | REG_SET_2(SCL_VERT_FILTER_INIT_BOT, 0, |
603 | SCL_V_INIT_FRAC_BOT, init_frac, | 603 | SCL_V_INIT_FRAC_BOT, init_frac, |
604 | SCL_V_INIT_INT_BOT, init_int); | 604 | SCL_V_INIT_INT_BOT, init_int); |
605 | 605 | ||
606 | init_frac = dal_fixed31_32_u0d19(data->inits.v_c) << 5; | 606 | init_frac = dc_fixpt_u0d19(data->inits.v_c) << 5; |
607 | init_int = dal_fixed31_32_floor(data->inits.v_c); | 607 | init_int = dc_fixpt_floor(data->inits.v_c); |
608 | REG_SET_2(SCL_VERT_FILTER_INIT_C, 0, | 608 | REG_SET_2(SCL_VERT_FILTER_INIT_C, 0, |
609 | SCL_V_INIT_FRAC_C, init_frac, | 609 | SCL_V_INIT_FRAC_C, init_frac, |
610 | SCL_V_INIT_INT_C, init_int); | 610 | SCL_V_INIT_INT_C, init_int); |
611 | 611 | ||
612 | init_frac = dal_fixed31_32_u0d19(data->inits.v_c_bot) << 5; | 612 | init_frac = dc_fixpt_u0d19(data->inits.v_c_bot) << 5; |
613 | init_int = dal_fixed31_32_floor(data->inits.v_c_bot); | 613 | init_int = dc_fixpt_floor(data->inits.v_c_bot); |
614 | REG_SET_2(SCL_VERT_FILTER_INIT_BOT_C, 0, | 614 | REG_SET_2(SCL_VERT_FILTER_INIT_BOT_C, 0, |
615 | SCL_V_INIT_FRAC_BOT_C, init_frac, | 615 | SCL_V_INIT_FRAC_BOT_C, init_frac, |
616 | SCL_V_INIT_INT_BOT_C, init_int); | 616 | SCL_V_INIT_INT_BOT_C, init_int); |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c index b9fb14a3224b..943143efbb82 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c | |||
@@ -476,6 +476,14 @@ void hubbub1_toggle_watermark_change_req(struct hubbub *hubbub) | |||
476 | DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, watermark_change_req); | 476 | DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, watermark_change_req); |
477 | } | 477 | } |
478 | 478 | ||
479 | void hubbub1_soft_reset(struct hubbub *hubbub, bool reset) | ||
480 | { | ||
481 | uint32_t reset_en = reset ? 1 : 0; | ||
482 | |||
483 | REG_UPDATE(DCHUBBUB_SOFT_RESET, | ||
484 | DCHUBBUB_GLOBAL_SOFT_RESET, reset_en); | ||
485 | } | ||
486 | |||
479 | static bool hubbub1_dcc_support_swizzle( | 487 | static bool hubbub1_dcc_support_swizzle( |
480 | enum swizzle_mode_values swizzle, | 488 | enum swizzle_mode_values swizzle, |
481 | unsigned int bytes_per_element, | 489 | unsigned int bytes_per_element, |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h index f479f54e5bb2..6315a0e6b0d6 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h | |||
@@ -48,7 +48,8 @@ | |||
48 | SR(DCHUBBUB_ARB_DF_REQ_OUTSTAND),\ | 48 | SR(DCHUBBUB_ARB_DF_REQ_OUTSTAND),\ |
49 | SR(DCHUBBUB_GLOBAL_TIMER_CNTL), \ | 49 | SR(DCHUBBUB_GLOBAL_TIMER_CNTL), \ |
50 | SR(DCHUBBUB_TEST_DEBUG_INDEX), \ | 50 | SR(DCHUBBUB_TEST_DEBUG_INDEX), \ |
51 | SR(DCHUBBUB_TEST_DEBUG_DATA) | 51 | SR(DCHUBBUB_TEST_DEBUG_DATA),\ |
52 | SR(DCHUBBUB_SOFT_RESET) | ||
52 | 53 | ||
53 | #define HUBBUB_SR_WATERMARK_REG_LIST()\ | 54 | #define HUBBUB_SR_WATERMARK_REG_LIST()\ |
54 | SR(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_A),\ | 55 | SR(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_A),\ |
@@ -105,6 +106,7 @@ struct dcn_hubbub_registers { | |||
105 | uint32_t DCHUBBUB_SDPIF_AGP_BOT; | 106 | uint32_t DCHUBBUB_SDPIF_AGP_BOT; |
106 | uint32_t DCHUBBUB_SDPIF_AGP_TOP; | 107 | uint32_t DCHUBBUB_SDPIF_AGP_TOP; |
107 | uint32_t DCHUBBUB_CRC_CTRL; | 108 | uint32_t DCHUBBUB_CRC_CTRL; |
109 | uint32_t DCHUBBUB_SOFT_RESET; | ||
108 | }; | 110 | }; |
109 | 111 | ||
110 | /* set field name */ | 112 | /* set field name */ |
@@ -114,6 +116,7 @@ struct dcn_hubbub_registers { | |||
114 | 116 | ||
115 | #define HUBBUB_MASK_SH_LIST_DCN(mask_sh)\ | 117 | #define HUBBUB_MASK_SH_LIST_DCN(mask_sh)\ |
116 | HUBBUB_SF(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_ENABLE, mask_sh), \ | 118 | HUBBUB_SF(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_ENABLE, mask_sh), \ |
119 | HUBBUB_SF(DCHUBBUB_SOFT_RESET, DCHUBBUB_GLOBAL_SOFT_RESET, mask_sh), \ | ||
117 | HUBBUB_SF(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL, DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, mask_sh), \ | 120 | HUBBUB_SF(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL, DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, mask_sh), \ |
118 | HUBBUB_SF(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL, DCHUBBUB_ARB_WATERMARK_CHANGE_DONE_INTERRUPT_DISABLE, mask_sh), \ | 121 | HUBBUB_SF(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL, DCHUBBUB_ARB_WATERMARK_CHANGE_DONE_INTERRUPT_DISABLE, mask_sh), \ |
119 | HUBBUB_SF(DCHUBBUB_ARB_DRAM_STATE_CNTL, DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_VALUE, mask_sh), \ | 122 | HUBBUB_SF(DCHUBBUB_ARB_DRAM_STATE_CNTL, DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_VALUE, mask_sh), \ |
@@ -143,6 +146,7 @@ struct dcn_hubbub_registers { | |||
143 | type DCHUBBUB_ARB_SAT_LEVEL;\ | 146 | type DCHUBBUB_ARB_SAT_LEVEL;\ |
144 | type DCHUBBUB_ARB_MIN_REQ_OUTSTAND;\ | 147 | type DCHUBBUB_ARB_MIN_REQ_OUTSTAND;\ |
145 | type DCHUBBUB_GLOBAL_TIMER_REFDIV;\ | 148 | type DCHUBBUB_GLOBAL_TIMER_REFDIV;\ |
149 | type DCHUBBUB_GLOBAL_SOFT_RESET; \ | ||
146 | type SDPIF_FB_TOP;\ | 150 | type SDPIF_FB_TOP;\ |
147 | type SDPIF_FB_BASE;\ | 151 | type SDPIF_FB_BASE;\ |
148 | type SDPIF_FB_OFFSET;\ | 152 | type SDPIF_FB_OFFSET;\ |
@@ -201,6 +205,7 @@ void hubbub1_toggle_watermark_change_req( | |||
201 | void hubbub1_wm_read_state(struct hubbub *hubbub, | 205 | void hubbub1_wm_read_state(struct hubbub *hubbub, |
202 | struct dcn_hubbub_wm *wm); | 206 | struct dcn_hubbub_wm *wm); |
203 | 207 | ||
208 | void hubbub1_soft_reset(struct hubbub *hubbub, bool reset); | ||
204 | void hubbub1_construct(struct hubbub *hubbub, | 209 | void hubbub1_construct(struct hubbub *hubbub, |
205 | struct dc_context *ctx, | 210 | struct dc_context *ctx, |
206 | const struct dcn_hubbub_registers *hubbub_regs, | 211 | const struct dcn_hubbub_registers *hubbub_regs, |
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 0cbc83edd37f..d2ab78b35a7a 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | |||
@@ -78,6 +78,27 @@ static void hubp1_disconnect(struct hubp *hubp) | |||
78 | CURSOR_ENABLE, 0); | 78 | CURSOR_ENABLE, 0); |
79 | } | 79 | } |
80 | 80 | ||
81 | static void hubp1_disable_control(struct hubp *hubp, bool disable_hubp) | ||
82 | { | ||
83 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); | ||
84 | uint32_t disable = disable_hubp ? 1 : 0; | ||
85 | |||
86 | REG_UPDATE(DCHUBP_CNTL, | ||
87 | HUBP_DISABLE, disable); | ||
88 | } | ||
89 | |||
90 | static unsigned int hubp1_get_underflow_status(struct hubp *hubp) | ||
91 | { | ||
92 | uint32_t hubp_underflow = 0; | ||
93 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); | ||
94 | |||
95 | REG_GET(DCHUBP_CNTL, | ||
96 | HUBP_UNDERFLOW_STATUS, | ||
97 | &hubp_underflow); | ||
98 | |||
99 | return hubp_underflow; | ||
100 | } | ||
101 | |||
81 | static void hubp1_set_hubp_blank_en(struct hubp *hubp, bool blank) | 102 | static void hubp1_set_hubp_blank_en(struct hubp *hubp, bool blank) |
82 | { | 103 | { |
83 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); | 104 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); |
@@ -1054,8 +1075,8 @@ void hubp1_cursor_set_position( | |||
1054 | ASSERT(param->h_scale_ratio.value); | 1075 | ASSERT(param->h_scale_ratio.value); |
1055 | 1076 | ||
1056 | if (param->h_scale_ratio.value) | 1077 | if (param->h_scale_ratio.value) |
1057 | dst_x_offset = dal_fixed31_32_floor(dal_fixed31_32_div( | 1078 | dst_x_offset = dc_fixpt_floor(dc_fixpt_div( |
1058 | dal_fixed31_32_from_int(dst_x_offset), | 1079 | dc_fixpt_from_int(dst_x_offset), |
1059 | param->h_scale_ratio)); | 1080 | param->h_scale_ratio)); |
1060 | 1081 | ||
1061 | if (src_x_offset >= (int)param->viewport_width) | 1082 | if (src_x_offset >= (int)param->viewport_width) |
@@ -1117,6 +1138,9 @@ static struct hubp_funcs dcn10_hubp_funcs = { | |||
1117 | .hubp_clk_cntl = hubp1_clk_cntl, | 1138 | .hubp_clk_cntl = hubp1_clk_cntl, |
1118 | .hubp_vtg_sel = hubp1_vtg_sel, | 1139 | .hubp_vtg_sel = hubp1_vtg_sel, |
1119 | .hubp_read_state = hubp1_read_state, | 1140 | .hubp_read_state = hubp1_read_state, |
1141 | .hubp_disable_control = hubp1_disable_control, | ||
1142 | .hubp_get_underflow_status = hubp1_get_underflow_status, | ||
1143 | |||
1120 | }; | 1144 | }; |
1121 | 1145 | ||
1122 | /*****************************************/ | 1146 | /*****************************************/ |
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 fe9b8c4a91ca..af384034398f 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h | |||
@@ -253,6 +253,7 @@ | |||
253 | HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_UNDERFLOW_STATUS, mask_sh),\ | 253 | HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_UNDERFLOW_STATUS, mask_sh),\ |
254 | HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_NO_OUTSTANDING_REQ, mask_sh),\ | 254 | HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_NO_OUTSTANDING_REQ, mask_sh),\ |
255 | HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_VTG_SEL, mask_sh),\ | 255 | HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_VTG_SEL, mask_sh),\ |
256 | HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_DISABLE, mask_sh),\ | ||
256 | HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, NUM_PIPES, mask_sh),\ | 257 | HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, NUM_PIPES, mask_sh),\ |
257 | HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, NUM_BANKS, mask_sh),\ | 258 | HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, NUM_BANKS, mask_sh),\ |
258 | HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, PIPE_INTERLEAVE, mask_sh),\ | 259 | HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, PIPE_INTERLEAVE, mask_sh),\ |
@@ -421,6 +422,7 @@ | |||
421 | 422 | ||
422 | #define DCN_HUBP_REG_FIELD_LIST(type) \ | 423 | #define DCN_HUBP_REG_FIELD_LIST(type) \ |
423 | type HUBP_BLANK_EN;\ | 424 | type HUBP_BLANK_EN;\ |
425 | type HUBP_DISABLE;\ | ||
424 | type HUBP_TTU_DISABLE;\ | 426 | type HUBP_TTU_DISABLE;\ |
425 | type HUBP_NO_OUTSTANDING_REQ;\ | 427 | type HUBP_NO_OUTSTANDING_REQ;\ |
426 | type HUBP_VTG_SEL;\ | 428 | type HUBP_VTG_SEL;\ |
@@ -723,4 +725,5 @@ void hubp1_read_state(struct hubp *hubp); | |||
723 | 725 | ||
724 | enum cursor_pitch hubp1_get_cursor_pitch(unsigned int pitch); | 726 | enum cursor_pitch hubp1_get_cursor_pitch(unsigned int pitch); |
725 | 727 | ||
728 | |||
726 | #endif | 729 | #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 572fa601a0eb..f8e0576af6e0 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 | |||
@@ -127,24 +127,26 @@ static void dcn10_log_hubp_states(struct dc *dc) | |||
127 | 127 | ||
128 | hubp->funcs->hubp_read_state(hubp); | 128 | hubp->funcs->hubp_read_state(hubp); |
129 | 129 | ||
130 | DTN_INFO("[%2d]: %5xh %6xh %5d %6d %2xh %2xh %6xh" | 130 | if (!s->blank_en) { |
131 | " %6d %8d %7d %8xh", | 131 | DTN_INFO("[%2d]: %5xh %6xh %5d %6d %2xh %2xh %6xh" |
132 | hubp->inst, | 132 | " %6d %8d %7d %8xh", |
133 | s->pixel_format, | 133 | hubp->inst, |
134 | s->inuse_addr_hi, | 134 | s->pixel_format, |
135 | s->viewport_width, | 135 | s->inuse_addr_hi, |
136 | s->viewport_height, | 136 | s->viewport_width, |
137 | s->rotation_angle, | 137 | s->viewport_height, |
138 | s->h_mirror_en, | 138 | s->rotation_angle, |
139 | s->sw_mode, | 139 | s->h_mirror_en, |
140 | s->dcc_en, | 140 | s->sw_mode, |
141 | s->blank_en, | 141 | s->dcc_en, |
142 | s->ttu_disable, | 142 | s->blank_en, |
143 | s->underflow_status); | 143 | s->ttu_disable, |
144 | DTN_INFO_MICRO_SEC(s->min_ttu_vblank); | 144 | s->underflow_status); |
145 | DTN_INFO_MICRO_SEC(s->qos_level_low_wm); | 145 | DTN_INFO_MICRO_SEC(s->min_ttu_vblank); |
146 | DTN_INFO_MICRO_SEC(s->qos_level_high_wm); | 146 | DTN_INFO_MICRO_SEC(s->qos_level_low_wm); |
147 | DTN_INFO("\n"); | 147 | DTN_INFO_MICRO_SEC(s->qos_level_high_wm); |
148 | DTN_INFO("\n"); | ||
149 | } | ||
148 | } | 150 | } |
149 | 151 | ||
150 | DTN_INFO("\n=========RQ========\n"); | 152 | DTN_INFO("\n=========RQ========\n"); |
@@ -155,16 +157,17 @@ static void dcn10_log_hubp_states(struct dc *dc) | |||
155 | struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); | 157 | struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); |
156 | struct _vcs_dpi_display_rq_regs_st *rq_regs = &s->rq_regs; | 158 | struct _vcs_dpi_display_rq_regs_st *rq_regs = &s->rq_regs; |
157 | 159 | ||
158 | DTN_INFO("[%2d]: %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh\n", | 160 | if (!s->blank_en) |
159 | i, rq_regs->drq_expansion_mode, rq_regs->prq_expansion_mode, rq_regs->mrq_expansion_mode, | 161 | DTN_INFO("[%2d]: %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh\n", |
160 | rq_regs->crq_expansion_mode, rq_regs->plane1_base_address, rq_regs->rq_regs_l.chunk_size, | 162 | pool->hubps[i]->inst, rq_regs->drq_expansion_mode, rq_regs->prq_expansion_mode, rq_regs->mrq_expansion_mode, |
161 | rq_regs->rq_regs_l.min_chunk_size, rq_regs->rq_regs_l.meta_chunk_size, | 163 | rq_regs->crq_expansion_mode, rq_regs->plane1_base_address, rq_regs->rq_regs_l.chunk_size, |
162 | rq_regs->rq_regs_l.min_meta_chunk_size, rq_regs->rq_regs_l.dpte_group_size, | 164 | rq_regs->rq_regs_l.min_chunk_size, rq_regs->rq_regs_l.meta_chunk_size, |
163 | rq_regs->rq_regs_l.mpte_group_size, rq_regs->rq_regs_l.swath_height, | 165 | rq_regs->rq_regs_l.min_meta_chunk_size, rq_regs->rq_regs_l.dpte_group_size, |
164 | rq_regs->rq_regs_l.pte_row_height_linear, rq_regs->rq_regs_c.chunk_size, rq_regs->rq_regs_c.min_chunk_size, | 166 | rq_regs->rq_regs_l.mpte_group_size, rq_regs->rq_regs_l.swath_height, |
165 | rq_regs->rq_regs_c.meta_chunk_size, rq_regs->rq_regs_c.min_meta_chunk_size, | 167 | rq_regs->rq_regs_l.pte_row_height_linear, rq_regs->rq_regs_c.chunk_size, rq_regs->rq_regs_c.min_chunk_size, |
166 | rq_regs->rq_regs_c.dpte_group_size, rq_regs->rq_regs_c.mpte_group_size, | 168 | rq_regs->rq_regs_c.meta_chunk_size, rq_regs->rq_regs_c.min_meta_chunk_size, |
167 | rq_regs->rq_regs_c.swath_height, rq_regs->rq_regs_c.pte_row_height_linear); | 169 | rq_regs->rq_regs_c.dpte_group_size, rq_regs->rq_regs_c.mpte_group_size, |
170 | rq_regs->rq_regs_c.swath_height, rq_regs->rq_regs_c.pte_row_height_linear); | ||
168 | } | 171 | } |
169 | 172 | ||
170 | DTN_INFO("========DLG========\n"); | 173 | DTN_INFO("========DLG========\n"); |
@@ -179,27 +182,28 @@ static void dcn10_log_hubp_states(struct dc *dc) | |||
179 | struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); | 182 | struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); |
180 | struct _vcs_dpi_display_dlg_regs_st *dlg_regs = &s->dlg_attr; | 183 | struct _vcs_dpi_display_dlg_regs_st *dlg_regs = &s->dlg_attr; |
181 | 184 | ||
182 | DTN_INFO("[%2d]: %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh" | 185 | if (!s->blank_en) |
183 | "% 8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh" | 186 | DTN_INFO("[%2d]: %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh" |
184 | " %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh\n", | 187 | "% 8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh" |
185 | i, dlg_regs->refcyc_h_blank_end, dlg_regs->dlg_vblank_end, dlg_regs->min_dst_y_next_start, | 188 | " %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh\n", |
186 | dlg_regs->refcyc_per_htotal, dlg_regs->refcyc_x_after_scaler, dlg_regs->dst_y_after_scaler, | 189 | pool->hubps[i]->inst, dlg_regs->refcyc_h_blank_end, dlg_regs->dlg_vblank_end, dlg_regs->min_dst_y_next_start, |
187 | dlg_regs->dst_y_prefetch, dlg_regs->dst_y_per_vm_vblank, dlg_regs->dst_y_per_row_vblank, | 190 | dlg_regs->refcyc_per_htotal, dlg_regs->refcyc_x_after_scaler, dlg_regs->dst_y_after_scaler, |
188 | dlg_regs->dst_y_per_vm_flip, dlg_regs->dst_y_per_row_flip, dlg_regs->ref_freq_to_pix_freq, | 191 | dlg_regs->dst_y_prefetch, dlg_regs->dst_y_per_vm_vblank, dlg_regs->dst_y_per_row_vblank, |
189 | dlg_regs->vratio_prefetch, dlg_regs->vratio_prefetch_c, dlg_regs->refcyc_per_pte_group_vblank_l, | 192 | dlg_regs->dst_y_per_vm_flip, dlg_regs->dst_y_per_row_flip, dlg_regs->ref_freq_to_pix_freq, |
190 | dlg_regs->refcyc_per_pte_group_vblank_c, dlg_regs->refcyc_per_meta_chunk_vblank_l, | 193 | dlg_regs->vratio_prefetch, dlg_regs->vratio_prefetch_c, dlg_regs->refcyc_per_pte_group_vblank_l, |
191 | dlg_regs->refcyc_per_meta_chunk_vblank_c, dlg_regs->refcyc_per_pte_group_flip_l, | 194 | dlg_regs->refcyc_per_pte_group_vblank_c, dlg_regs->refcyc_per_meta_chunk_vblank_l, |
192 | dlg_regs->refcyc_per_pte_group_flip_c, dlg_regs->refcyc_per_meta_chunk_flip_l, | 195 | dlg_regs->refcyc_per_meta_chunk_vblank_c, dlg_regs->refcyc_per_pte_group_flip_l, |
193 | dlg_regs->refcyc_per_meta_chunk_flip_c, dlg_regs->dst_y_per_pte_row_nom_l, | 196 | dlg_regs->refcyc_per_pte_group_flip_c, dlg_regs->refcyc_per_meta_chunk_flip_l, |
194 | dlg_regs->dst_y_per_pte_row_nom_c, dlg_regs->refcyc_per_pte_group_nom_l, | 197 | dlg_regs->refcyc_per_meta_chunk_flip_c, dlg_regs->dst_y_per_pte_row_nom_l, |
195 | dlg_regs->refcyc_per_pte_group_nom_c, dlg_regs->dst_y_per_meta_row_nom_l, | 198 | dlg_regs->dst_y_per_pte_row_nom_c, dlg_regs->refcyc_per_pte_group_nom_l, |
196 | dlg_regs->dst_y_per_meta_row_nom_c, dlg_regs->refcyc_per_meta_chunk_nom_l, | 199 | dlg_regs->refcyc_per_pte_group_nom_c, dlg_regs->dst_y_per_meta_row_nom_l, |
197 | dlg_regs->refcyc_per_meta_chunk_nom_c, dlg_regs->refcyc_per_line_delivery_pre_l, | 200 | dlg_regs->dst_y_per_meta_row_nom_c, dlg_regs->refcyc_per_meta_chunk_nom_l, |
198 | dlg_regs->refcyc_per_line_delivery_pre_c, dlg_regs->refcyc_per_line_delivery_l, | 201 | dlg_regs->refcyc_per_meta_chunk_nom_c, dlg_regs->refcyc_per_line_delivery_pre_l, |
199 | dlg_regs->refcyc_per_line_delivery_c, dlg_regs->chunk_hdl_adjust_cur0, dlg_regs->dst_y_offset_cur1, | 202 | dlg_regs->refcyc_per_line_delivery_pre_c, dlg_regs->refcyc_per_line_delivery_l, |
200 | dlg_regs->chunk_hdl_adjust_cur1, dlg_regs->vready_after_vcount0, dlg_regs->dst_y_delta_drq_limit, | 203 | dlg_regs->refcyc_per_line_delivery_c, dlg_regs->chunk_hdl_adjust_cur0, dlg_regs->dst_y_offset_cur1, |
201 | dlg_regs->xfc_reg_transfer_delay, dlg_regs->xfc_reg_precharge_delay, | 204 | dlg_regs->chunk_hdl_adjust_cur1, dlg_regs->vready_after_vcount0, dlg_regs->dst_y_delta_drq_limit, |
202 | dlg_regs->xfc_reg_remote_surface_flip_latency); | 205 | dlg_regs->xfc_reg_transfer_delay, dlg_regs->xfc_reg_precharge_delay, |
206 | dlg_regs->xfc_reg_remote_surface_flip_latency); | ||
203 | } | 207 | } |
204 | 208 | ||
205 | DTN_INFO("========TTU========\n"); | 209 | DTN_INFO("========TTU========\n"); |
@@ -210,14 +214,15 @@ static void dcn10_log_hubp_states(struct dc *dc) | |||
210 | struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); | 214 | struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); |
211 | struct _vcs_dpi_display_ttu_regs_st *ttu_regs = &s->ttu_attr; | 215 | struct _vcs_dpi_display_ttu_regs_st *ttu_regs = &s->ttu_attr; |
212 | 216 | ||
213 | DTN_INFO("[%2d]: %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh\n", | 217 | if (!s->blank_en) |
214 | i, ttu_regs->qos_level_low_wm, ttu_regs->qos_level_high_wm, ttu_regs->min_ttu_vblank, | 218 | DTN_INFO("[%2d]: %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh %8xh\n", |
215 | ttu_regs->qos_level_flip, ttu_regs->refcyc_per_req_delivery_pre_l, ttu_regs->refcyc_per_req_delivery_l, | 219 | pool->hubps[i]->inst, ttu_regs->qos_level_low_wm, ttu_regs->qos_level_high_wm, ttu_regs->min_ttu_vblank, |
216 | ttu_regs->refcyc_per_req_delivery_pre_c, ttu_regs->refcyc_per_req_delivery_c, ttu_regs->refcyc_per_req_delivery_cur0, | 220 | ttu_regs->qos_level_flip, ttu_regs->refcyc_per_req_delivery_pre_l, ttu_regs->refcyc_per_req_delivery_l, |
217 | ttu_regs->refcyc_per_req_delivery_pre_cur0, ttu_regs->refcyc_per_req_delivery_cur1, | 221 | ttu_regs->refcyc_per_req_delivery_pre_c, ttu_regs->refcyc_per_req_delivery_c, ttu_regs->refcyc_per_req_delivery_cur0, |
218 | ttu_regs->refcyc_per_req_delivery_pre_cur1, ttu_regs->qos_level_fixed_l, ttu_regs->qos_ramp_disable_l, | 222 | ttu_regs->refcyc_per_req_delivery_pre_cur0, ttu_regs->refcyc_per_req_delivery_cur1, |
219 | ttu_regs->qos_level_fixed_c, ttu_regs->qos_ramp_disable_c, ttu_regs->qos_level_fixed_cur0, | 223 | ttu_regs->refcyc_per_req_delivery_pre_cur1, ttu_regs->qos_level_fixed_l, ttu_regs->qos_ramp_disable_l, |
220 | ttu_regs->qos_ramp_disable_cur0, ttu_regs->qos_level_fixed_cur1, ttu_regs->qos_ramp_disable_cur1); | 224 | ttu_regs->qos_level_fixed_c, ttu_regs->qos_ramp_disable_c, ttu_regs->qos_level_fixed_cur0, |
225 | ttu_regs->qos_ramp_disable_cur0, ttu_regs->qos_level_fixed_cur1, ttu_regs->qos_ramp_disable_cur1); | ||
221 | } | 226 | } |
222 | DTN_INFO("\n"); | 227 | DTN_INFO("\n"); |
223 | } | 228 | } |
@@ -321,6 +326,12 @@ void dcn10_log_hw_state(struct dc *dc) | |||
321 | s.h_total, | 326 | s.h_total, |
322 | s.v_total, | 327 | s.v_total, |
323 | s.underflow_occurred_status); | 328 | s.underflow_occurred_status); |
329 | |||
330 | // Clear underflow for debug purposes | ||
331 | // We want to keep underflow sticky bit on for the longevity tests outside of test environment. | ||
332 | // This function is called only from Windows or Diags test environment, hence it's safe to clear | ||
333 | // it from here without affecting the original intent. | ||
334 | tg->funcs->clear_optc_underflow(tg); | ||
324 | } | 335 | } |
325 | DTN_INFO("\n"); | 336 | DTN_INFO("\n"); |
326 | 337 | ||
@@ -747,6 +758,90 @@ static void reset_back_end_for_pipe( | |||
747 | pipe_ctx->pipe_idx, pipe_ctx->stream_res.tg->inst); | 758 | pipe_ctx->pipe_idx, pipe_ctx->stream_res.tg->inst); |
748 | } | 759 | } |
749 | 760 | ||
761 | static bool dcn10_hw_wa_force_recovery(struct dc *dc) | ||
762 | { | ||
763 | struct hubp *hubp ; | ||
764 | unsigned int i; | ||
765 | bool need_recover = true; | ||
766 | |||
767 | if (!dc->debug.recovery_enabled) | ||
768 | return false; | ||
769 | |||
770 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | ||
771 | struct pipe_ctx *pipe_ctx = | ||
772 | &dc->current_state->res_ctx.pipe_ctx[i]; | ||
773 | if (pipe_ctx != NULL) { | ||
774 | hubp = pipe_ctx->plane_res.hubp; | ||
775 | if (hubp != NULL) { | ||
776 | if (hubp->funcs->hubp_get_underflow_status(hubp) != 0) { | ||
777 | /* one pipe underflow, we will reset all the pipes*/ | ||
778 | need_recover = true; | ||
779 | } | ||
780 | } | ||
781 | } | ||
782 | } | ||
783 | if (!need_recover) | ||
784 | return false; | ||
785 | /* | ||
786 | DCHUBP_CNTL:HUBP_BLANK_EN=1 | ||
787 | DCHUBBUB_SOFT_RESET:DCHUBBUB_GLOBAL_SOFT_RESET=1 | ||
788 | DCHUBP_CNTL:HUBP_DISABLE=1 | ||
789 | DCHUBP_CNTL:HUBP_DISABLE=0 | ||
790 | DCHUBBUB_SOFT_RESET:DCHUBBUB_GLOBAL_SOFT_RESET=0 | ||
791 | DCSURF_PRIMARY_SURFACE_ADDRESS | ||
792 | DCHUBP_CNTL:HUBP_BLANK_EN=0 | ||
793 | */ | ||
794 | |||
795 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | ||
796 | struct pipe_ctx *pipe_ctx = | ||
797 | &dc->current_state->res_ctx.pipe_ctx[i]; | ||
798 | if (pipe_ctx != NULL) { | ||
799 | hubp = pipe_ctx->plane_res.hubp; | ||
800 | /*DCHUBP_CNTL:HUBP_BLANK_EN=1*/ | ||
801 | if (hubp != NULL) | ||
802 | hubp->funcs->set_hubp_blank_en(hubp, true); | ||
803 | } | ||
804 | } | ||
805 | /*DCHUBBUB_SOFT_RESET:DCHUBBUB_GLOBAL_SOFT_RESET=1*/ | ||
806 | hubbub1_soft_reset(dc->res_pool->hubbub, true); | ||
807 | |||
808 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | ||
809 | struct pipe_ctx *pipe_ctx = | ||
810 | &dc->current_state->res_ctx.pipe_ctx[i]; | ||
811 | if (pipe_ctx != NULL) { | ||
812 | hubp = pipe_ctx->plane_res.hubp; | ||
813 | /*DCHUBP_CNTL:HUBP_DISABLE=1*/ | ||
814 | if (hubp != NULL) | ||
815 | hubp->funcs->hubp_disable_control(hubp, true); | ||
816 | } | ||
817 | } | ||
818 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | ||
819 | struct pipe_ctx *pipe_ctx = | ||
820 | &dc->current_state->res_ctx.pipe_ctx[i]; | ||
821 | if (pipe_ctx != NULL) { | ||
822 | hubp = pipe_ctx->plane_res.hubp; | ||
823 | /*DCHUBP_CNTL:HUBP_DISABLE=0*/ | ||
824 | if (hubp != NULL) | ||
825 | hubp->funcs->hubp_disable_control(hubp, true); | ||
826 | } | ||
827 | } | ||
828 | /*DCHUBBUB_SOFT_RESET:DCHUBBUB_GLOBAL_SOFT_RESET=0*/ | ||
829 | hubbub1_soft_reset(dc->res_pool->hubbub, false); | ||
830 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | ||
831 | struct pipe_ctx *pipe_ctx = | ||
832 | &dc->current_state->res_ctx.pipe_ctx[i]; | ||
833 | if (pipe_ctx != NULL) { | ||
834 | hubp = pipe_ctx->plane_res.hubp; | ||
835 | /*DCHUBP_CNTL:HUBP_BLANK_EN=0*/ | ||
836 | if (hubp != NULL) | ||
837 | hubp->funcs->set_hubp_blank_en(hubp, true); | ||
838 | } | ||
839 | } | ||
840 | return true; | ||
841 | |||
842 | } | ||
843 | |||
844 | |||
750 | static void dcn10_verify_allow_pstate_change_high(struct dc *dc) | 845 | static void dcn10_verify_allow_pstate_change_high(struct dc *dc) |
751 | { | 846 | { |
752 | static bool should_log_hw_state; /* prevent hw state log by default */ | 847 | static bool should_log_hw_state; /* prevent hw state log by default */ |
@@ -755,13 +850,17 @@ static void dcn10_verify_allow_pstate_change_high(struct dc *dc) | |||
755 | if (should_log_hw_state) { | 850 | if (should_log_hw_state) { |
756 | dcn10_log_hw_state(dc); | 851 | dcn10_log_hw_state(dc); |
757 | } | 852 | } |
758 | |||
759 | BREAK_TO_DEBUGGER(); | 853 | BREAK_TO_DEBUGGER(); |
854 | if (dcn10_hw_wa_force_recovery(dc)) { | ||
855 | /*check again*/ | ||
856 | if (!hubbub1_verify_allow_pstate_change_high(dc->res_pool->hubbub)) | ||
857 | BREAK_TO_DEBUGGER(); | ||
858 | } | ||
760 | } | 859 | } |
761 | } | 860 | } |
762 | 861 | ||
763 | /* trigger HW to start disconnect plane from stream on the next vsync */ | 862 | /* trigger HW to start disconnect plane from stream on the next vsync */ |
764 | static void plane_atomic_disconnect(struct dc *dc, struct pipe_ctx *pipe_ctx) | 863 | void hwss1_plane_atomic_disconnect(struct dc *dc, struct pipe_ctx *pipe_ctx) |
765 | { | 864 | { |
766 | struct hubp *hubp = pipe_ctx->plane_res.hubp; | 865 | struct hubp *hubp = pipe_ctx->plane_res.hubp; |
767 | int dpp_id = pipe_ctx->plane_res.dpp->inst; | 866 | int dpp_id = pipe_ctx->plane_res.dpp->inst; |
@@ -944,7 +1043,7 @@ static void dcn10_init_hw(struct dc *dc) | |||
944 | dc->res_pool->opps[i]->mpcc_disconnect_pending[pipe_ctx->plane_res.mpcc_inst] = true; | 1043 | dc->res_pool->opps[i]->mpcc_disconnect_pending[pipe_ctx->plane_res.mpcc_inst] = true; |
945 | pipe_ctx->stream_res.opp = dc->res_pool->opps[i]; | 1044 | pipe_ctx->stream_res.opp = dc->res_pool->opps[i]; |
946 | 1045 | ||
947 | plane_atomic_disconnect(dc, pipe_ctx); | 1046 | hwss1_plane_atomic_disconnect(dc, pipe_ctx); |
948 | } | 1047 | } |
949 | 1048 | ||
950 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | 1049 | for (i = 0; i < dc->res_pool->pipe_count; i++) { |
@@ -1685,22 +1784,22 @@ static uint16_t fixed_point_to_int_frac( | |||
1685 | 1784 | ||
1686 | uint16_t result; | 1785 | uint16_t result; |
1687 | 1786 | ||
1688 | uint16_t d = (uint16_t)dal_fixed31_32_floor( | 1787 | uint16_t d = (uint16_t)dc_fixpt_floor( |
1689 | dal_fixed31_32_abs( | 1788 | dc_fixpt_abs( |
1690 | arg)); | 1789 | arg)); |
1691 | 1790 | ||
1692 | if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor)) | 1791 | if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor)) |
1693 | numerator = (uint16_t)dal_fixed31_32_floor( | 1792 | numerator = (uint16_t)dc_fixpt_floor( |
1694 | dal_fixed31_32_mul_int( | 1793 | dc_fixpt_mul_int( |
1695 | arg, | 1794 | arg, |
1696 | divisor)); | 1795 | divisor)); |
1697 | else { | 1796 | else { |
1698 | numerator = dal_fixed31_32_floor( | 1797 | numerator = dc_fixpt_floor( |
1699 | dal_fixed31_32_sub( | 1798 | dc_fixpt_sub( |
1700 | dal_fixed31_32_from_int( | 1799 | dc_fixpt_from_int( |
1701 | 1LL << integer_bits), | 1800 | 1LL << integer_bits), |
1702 | dal_fixed31_32_recip( | 1801 | dc_fixpt_recip( |
1703 | dal_fixed31_32_from_int( | 1802 | dc_fixpt_from_int( |
1704 | divisor)))); | 1803 | divisor)))); |
1705 | } | 1804 | } |
1706 | 1805 | ||
@@ -1710,8 +1809,8 @@ static uint16_t fixed_point_to_int_frac( | |||
1710 | result = (uint16_t)( | 1809 | result = (uint16_t)( |
1711 | (1 << (integer_bits + fractional_bits + 1)) + numerator); | 1810 | (1 << (integer_bits + fractional_bits + 1)) + numerator); |
1712 | 1811 | ||
1713 | if ((result != 0) && dal_fixed31_32_lt( | 1812 | if ((result != 0) && dc_fixpt_lt( |
1714 | arg, dal_fixed31_32_zero)) | 1813 | arg, dc_fixpt_zero)) |
1715 | result |= 1 << (integer_bits + fractional_bits); | 1814 | result |= 1 << (integer_bits + fractional_bits); |
1716 | 1815 | ||
1717 | return result; | 1816 | return result; |
@@ -1725,8 +1824,8 @@ void build_prescale_params(struct dc_bias_and_scale *bias_and_scale, | |||
1725 | && plane_state->input_csc_color_matrix.enable_adjustment | 1824 | && plane_state->input_csc_color_matrix.enable_adjustment |
1726 | && plane_state->coeff_reduction_factor.value != 0) { | 1825 | && plane_state->coeff_reduction_factor.value != 0) { |
1727 | bias_and_scale->scale_blue = fixed_point_to_int_frac( | 1826 | bias_and_scale->scale_blue = fixed_point_to_int_frac( |
1728 | dal_fixed31_32_mul(plane_state->coeff_reduction_factor, | 1827 | dc_fixpt_mul(plane_state->coeff_reduction_factor, |
1729 | dal_fixed31_32_from_fraction(256, 255)), | 1828 | dc_fixpt_from_fraction(256, 255)), |
1730 | 2, | 1829 | 2, |
1731 | 13); | 1830 | 13); |
1732 | bias_and_scale->scale_red = bias_and_scale->scale_blue; | 1831 | bias_and_scale->scale_red = bias_and_scale->scale_blue; |
@@ -1995,7 +2094,7 @@ static void dcn10_blank_pixel_data( | |||
1995 | 2094 | ||
1996 | static void set_hdr_multiplier(struct pipe_ctx *pipe_ctx) | 2095 | static void set_hdr_multiplier(struct pipe_ctx *pipe_ctx) |
1997 | { | 2096 | { |
1998 | struct fixed31_32 multiplier = dal_fixed31_32_from_fraction( | 2097 | struct fixed31_32 multiplier = dc_fixpt_from_fraction( |
1999 | pipe_ctx->plane_state->sdr_white_level, 80); | 2098 | pipe_ctx->plane_state->sdr_white_level, 80); |
2000 | uint32_t hw_mult = 0x1f000; // 1.0 default multiplier | 2099 | uint32_t hw_mult = 0x1f000; // 1.0 default multiplier |
2001 | struct custom_float_format fmt; | 2100 | struct custom_float_format fmt; |
@@ -2179,7 +2278,7 @@ static void dcn10_apply_ctx_for_surface( | |||
2179 | old_pipe_ctx->plane_state && | 2278 | old_pipe_ctx->plane_state && |
2180 | old_pipe_ctx->stream_res.tg == tg) { | 2279 | old_pipe_ctx->stream_res.tg == tg) { |
2181 | 2280 | ||
2182 | plane_atomic_disconnect(dc, old_pipe_ctx); | 2281 | hwss1_plane_atomic_disconnect(dc, old_pipe_ctx); |
2183 | removed_pipe[i] = true; | 2282 | removed_pipe[i] = true; |
2184 | 2283 | ||
2185 | DC_LOG_DC( | 2284 | DC_LOG_DC( |
@@ -2487,15 +2586,6 @@ static void set_static_screen_control(struct pipe_ctx **pipe_ctx, | |||
2487 | set_static_screen_control(pipe_ctx[i]->stream_res.tg, value); | 2586 | set_static_screen_control(pipe_ctx[i]->stream_res.tg, value); |
2488 | } | 2587 | } |
2489 | 2588 | ||
2490 | static void set_plane_config( | ||
2491 | const struct dc *dc, | ||
2492 | struct pipe_ctx *pipe_ctx, | ||
2493 | struct resource_context *res_ctx) | ||
2494 | { | ||
2495 | /* TODO */ | ||
2496 | program_gamut_remap(pipe_ctx); | ||
2497 | } | ||
2498 | |||
2499 | static void dcn10_config_stereo_parameters( | 2589 | static void dcn10_config_stereo_parameters( |
2500 | struct dc_stream_state *stream, struct crtc_stereo_flags *flags) | 2590 | struct dc_stream_state *stream, struct crtc_stereo_flags *flags) |
2501 | { | 2591 | { |
@@ -2673,7 +2763,6 @@ static const struct hw_sequencer_funcs dcn10_funcs = { | |||
2673 | .init_hw = dcn10_init_hw, | 2763 | .init_hw = dcn10_init_hw, |
2674 | .apply_ctx_to_hw = dce110_apply_ctx_to_hw, | 2764 | .apply_ctx_to_hw = dce110_apply_ctx_to_hw, |
2675 | .apply_ctx_for_surface = dcn10_apply_ctx_for_surface, | 2765 | .apply_ctx_for_surface = dcn10_apply_ctx_for_surface, |
2676 | .set_plane_config = set_plane_config, | ||
2677 | .update_plane_addr = dcn10_update_plane_addr, | 2766 | .update_plane_addr = dcn10_update_plane_addr, |
2678 | .update_dchub = dcn10_update_dchub, | 2767 | .update_dchub = dcn10_update_dchub, |
2679 | .update_pending_status = dcn10_update_pending_status, | 2768 | .update_pending_status = dcn10_update_pending_status, |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h index 6c526b5095d9..44f734b73f9e 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h | |||
@@ -37,4 +37,6 @@ extern void fill_display_configs( | |||
37 | 37 | ||
38 | bool is_rgb_cspace(enum dc_color_space output_color_space); | 38 | bool is_rgb_cspace(enum dc_color_space output_color_space); |
39 | 39 | ||
40 | void hwss1_plane_atomic_disconnect(struct dc *dc, struct pipe_ctx *pipe_ctx); | ||
41 | |||
40 | #endif /* __DC_HWSS_DCN10_H__ */ | 42 | #endif /* __DC_HWSS_DCN10_H__ */ |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c new file mode 100644 index 000000000000..21fa40ac0786 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c | |||
@@ -0,0 +1,1362 @@ | |||
1 | /* | ||
2 | * Copyright 2012-15 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 | * Authors: AMD | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #include "reg_helper.h" | ||
27 | |||
28 | #include "core_types.h" | ||
29 | #include "link_encoder.h" | ||
30 | #include "dcn10_link_encoder.h" | ||
31 | #include "stream_encoder.h" | ||
32 | #include "i2caux_interface.h" | ||
33 | #include "dc_bios_types.h" | ||
34 | |||
35 | #include "gpio_service_interface.h" | ||
36 | |||
37 | #define CTX \ | ||
38 | enc10->base.ctx | ||
39 | #define DC_LOGGER \ | ||
40 | enc10->base.ctx->logger | ||
41 | |||
42 | #define REG(reg)\ | ||
43 | (enc10->link_regs->reg) | ||
44 | |||
45 | #undef FN | ||
46 | #define FN(reg_name, field_name) \ | ||
47 | enc10->link_shift->field_name, enc10->link_mask->field_name | ||
48 | |||
49 | |||
50 | /* | ||
51 | * @brief | ||
52 | * Trigger Source Select | ||
53 | * ASIC-dependent, actual values for register programming | ||
54 | */ | ||
55 | #define DCN10_DIG_FE_SOURCE_SELECT_INVALID 0x0 | ||
56 | #define DCN10_DIG_FE_SOURCE_SELECT_DIGA 0x1 | ||
57 | #define DCN10_DIG_FE_SOURCE_SELECT_DIGB 0x2 | ||
58 | #define DCN10_DIG_FE_SOURCE_SELECT_DIGC 0x4 | ||
59 | #define DCN10_DIG_FE_SOURCE_SELECT_DIGD 0x08 | ||
60 | #define DCN10_DIG_FE_SOURCE_SELECT_DIGE 0x10 | ||
61 | #define DCN10_DIG_FE_SOURCE_SELECT_DIGF 0x20 | ||
62 | #define DCN10_DIG_FE_SOURCE_SELECT_DIGG 0x40 | ||
63 | |||
64 | enum { | ||
65 | DP_MST_UPDATE_MAX_RETRY = 50 | ||
66 | }; | ||
67 | |||
68 | |||
69 | |||
70 | static void aux_initialize(struct dcn10_link_encoder *enc10); | ||
71 | |||
72 | |||
73 | static const struct link_encoder_funcs dcn10_lnk_enc_funcs = { | ||
74 | .validate_output_with_stream = | ||
75 | dcn10_link_encoder_validate_output_with_stream, | ||
76 | .hw_init = dcn10_link_encoder_hw_init, | ||
77 | .setup = dcn10_link_encoder_setup, | ||
78 | .enable_tmds_output = dcn10_link_encoder_enable_tmds_output, | ||
79 | .enable_dp_output = dcn10_link_encoder_enable_dp_output, | ||
80 | .enable_dp_mst_output = dcn10_link_encoder_enable_dp_mst_output, | ||
81 | .disable_output = dcn10_link_encoder_disable_output, | ||
82 | .dp_set_lane_settings = dcn10_link_encoder_dp_set_lane_settings, | ||
83 | .dp_set_phy_pattern = dcn10_link_encoder_dp_set_phy_pattern, | ||
84 | .update_mst_stream_allocation_table = | ||
85 | dcn10_link_encoder_update_mst_stream_allocation_table, | ||
86 | .psr_program_dp_dphy_fast_training = | ||
87 | dcn10_psr_program_dp_dphy_fast_training, | ||
88 | .psr_program_secondary_packet = dcn10_psr_program_secondary_packet, | ||
89 | .connect_dig_be_to_fe = dcn10_link_encoder_connect_dig_be_to_fe, | ||
90 | .enable_hpd = dcn10_link_encoder_enable_hpd, | ||
91 | .disable_hpd = dcn10_link_encoder_disable_hpd, | ||
92 | .is_dig_enabled = dcn10_is_dig_enabled, | ||
93 | .destroy = dcn10_link_encoder_destroy | ||
94 | }; | ||
95 | |||
96 | static enum bp_result link_transmitter_control( | ||
97 | struct dcn10_link_encoder *enc10, | ||
98 | struct bp_transmitter_control *cntl) | ||
99 | { | ||
100 | enum bp_result result; | ||
101 | struct dc_bios *bp = enc10->base.ctx->dc_bios; | ||
102 | |||
103 | result = bp->funcs->transmitter_control(bp, cntl); | ||
104 | |||
105 | return result; | ||
106 | } | ||
107 | |||
108 | static void enable_phy_bypass_mode( | ||
109 | struct dcn10_link_encoder *enc10, | ||
110 | bool enable) | ||
111 | { | ||
112 | /* This register resides in DP back end block; | ||
113 | * transmitter is used for the offset | ||
114 | */ | ||
115 | REG_UPDATE(DP_DPHY_CNTL, DPHY_BYPASS, enable); | ||
116 | |||
117 | } | ||
118 | |||
119 | static void disable_prbs_symbols( | ||
120 | struct dcn10_link_encoder *enc10, | ||
121 | bool disable) | ||
122 | { | ||
123 | /* This register resides in DP back end block; | ||
124 | * transmitter is used for the offset | ||
125 | */ | ||
126 | REG_UPDATE_4(DP_DPHY_CNTL, | ||
127 | DPHY_ATEST_SEL_LANE0, disable, | ||
128 | DPHY_ATEST_SEL_LANE1, disable, | ||
129 | DPHY_ATEST_SEL_LANE2, disable, | ||
130 | DPHY_ATEST_SEL_LANE3, disable); | ||
131 | } | ||
132 | |||
133 | static void disable_prbs_mode( | ||
134 | struct dcn10_link_encoder *enc10) | ||
135 | { | ||
136 | REG_UPDATE(DP_DPHY_PRBS_CNTL, DPHY_PRBS_EN, 0); | ||
137 | } | ||
138 | |||
139 | static void program_pattern_symbols( | ||
140 | struct dcn10_link_encoder *enc10, | ||
141 | uint16_t pattern_symbols[8]) | ||
142 | { | ||
143 | /* This register resides in DP back end block; | ||
144 | * transmitter is used for the offset | ||
145 | */ | ||
146 | REG_SET_3(DP_DPHY_SYM0, 0, | ||
147 | DPHY_SYM1, pattern_symbols[0], | ||
148 | DPHY_SYM2, pattern_symbols[1], | ||
149 | DPHY_SYM3, pattern_symbols[2]); | ||
150 | |||
151 | /* This register resides in DP back end block; | ||
152 | * transmitter is used for the offset | ||
153 | */ | ||
154 | REG_SET_3(DP_DPHY_SYM1, 0, | ||
155 | DPHY_SYM4, pattern_symbols[3], | ||
156 | DPHY_SYM5, pattern_symbols[4], | ||
157 | DPHY_SYM6, pattern_symbols[5]); | ||
158 | |||
159 | /* This register resides in DP back end block; | ||
160 | * transmitter is used for the offset | ||
161 | */ | ||
162 | REG_SET_2(DP_DPHY_SYM2, 0, | ||
163 | DPHY_SYM7, pattern_symbols[6], | ||
164 | DPHY_SYM8, pattern_symbols[7]); | ||
165 | } | ||
166 | |||
167 | static void set_dp_phy_pattern_d102( | ||
168 | struct dcn10_link_encoder *enc10) | ||
169 | { | ||
170 | /* Disable PHY Bypass mode to setup the test pattern */ | ||
171 | enable_phy_bypass_mode(enc10, false); | ||
172 | |||
173 | /* For 10-bit PRBS or debug symbols | ||
174 | * please use the following sequence: | ||
175 | * | ||
176 | * Enable debug symbols on the lanes | ||
177 | */ | ||
178 | disable_prbs_symbols(enc10, true); | ||
179 | |||
180 | /* Disable PRBS mode */ | ||
181 | disable_prbs_mode(enc10); | ||
182 | |||
183 | /* Program debug symbols to be output */ | ||
184 | { | ||
185 | uint16_t pattern_symbols[8] = { | ||
186 | 0x2AA, 0x2AA, 0x2AA, 0x2AA, | ||
187 | 0x2AA, 0x2AA, 0x2AA, 0x2AA | ||
188 | }; | ||
189 | |||
190 | program_pattern_symbols(enc10, pattern_symbols); | ||
191 | } | ||
192 | |||
193 | /* Enable phy bypass mode to enable the test pattern */ | ||
194 | |||
195 | enable_phy_bypass_mode(enc10, true); | ||
196 | } | ||
197 | |||
198 | static void set_link_training_complete( | ||
199 | struct dcn10_link_encoder *enc10, | ||
200 | bool complete) | ||
201 | { | ||
202 | /* This register resides in DP back end block; | ||
203 | * transmitter is used for the offset | ||
204 | */ | ||
205 | REG_UPDATE(DP_LINK_CNTL, DP_LINK_TRAINING_COMPLETE, complete); | ||
206 | |||
207 | } | ||
208 | |||
209 | void dcn10_link_encoder_set_dp_phy_pattern_training_pattern( | ||
210 | struct link_encoder *enc, | ||
211 | uint32_t index) | ||
212 | { | ||
213 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
214 | /* Write Training Pattern */ | ||
215 | |||
216 | REG_WRITE(DP_DPHY_TRAINING_PATTERN_SEL, index); | ||
217 | |||
218 | /* Set HW Register Training Complete to false */ | ||
219 | |||
220 | set_link_training_complete(enc10, false); | ||
221 | |||
222 | /* Disable PHY Bypass mode to output Training Pattern */ | ||
223 | |||
224 | enable_phy_bypass_mode(enc10, false); | ||
225 | |||
226 | /* Disable PRBS mode */ | ||
227 | disable_prbs_mode(enc10); | ||
228 | } | ||
229 | |||
230 | static void setup_panel_mode( | ||
231 | struct dcn10_link_encoder *enc10, | ||
232 | enum dp_panel_mode panel_mode) | ||
233 | { | ||
234 | uint32_t value; | ||
235 | |||
236 | ASSERT(REG(DP_DPHY_INTERNAL_CTRL)); | ||
237 | value = REG_READ(DP_DPHY_INTERNAL_CTRL); | ||
238 | |||
239 | switch (panel_mode) { | ||
240 | case DP_PANEL_MODE_EDP: | ||
241 | value = 0x1; | ||
242 | break; | ||
243 | case DP_PANEL_MODE_SPECIAL: | ||
244 | value = 0x11; | ||
245 | break; | ||
246 | default: | ||
247 | value = 0x0; | ||
248 | break; | ||
249 | } | ||
250 | |||
251 | REG_WRITE(DP_DPHY_INTERNAL_CTRL, value); | ||
252 | } | ||
253 | |||
254 | static void set_dp_phy_pattern_symbol_error( | ||
255 | struct dcn10_link_encoder *enc10) | ||
256 | { | ||
257 | /* Disable PHY Bypass mode to setup the test pattern */ | ||
258 | enable_phy_bypass_mode(enc10, false); | ||
259 | |||
260 | /* program correct panel mode*/ | ||
261 | setup_panel_mode(enc10, DP_PANEL_MODE_DEFAULT); | ||
262 | |||
263 | /* A PRBS23 pattern is used for most DP electrical measurements. */ | ||
264 | |||
265 | /* Enable PRBS symbols on the lanes */ | ||
266 | disable_prbs_symbols(enc10, false); | ||
267 | |||
268 | /* For PRBS23 Set bit DPHY_PRBS_SEL=1 and Set bit DPHY_PRBS_EN=1 */ | ||
269 | REG_UPDATE_2(DP_DPHY_PRBS_CNTL, | ||
270 | DPHY_PRBS_SEL, 1, | ||
271 | DPHY_PRBS_EN, 1); | ||
272 | |||
273 | /* Enable phy bypass mode to enable the test pattern */ | ||
274 | enable_phy_bypass_mode(enc10, true); | ||
275 | } | ||
276 | |||
277 | static void set_dp_phy_pattern_prbs7( | ||
278 | struct dcn10_link_encoder *enc10) | ||
279 | { | ||
280 | /* Disable PHY Bypass mode to setup the test pattern */ | ||
281 | enable_phy_bypass_mode(enc10, false); | ||
282 | |||
283 | /* A PRBS7 pattern is used for most DP electrical measurements. */ | ||
284 | |||
285 | /* Enable PRBS symbols on the lanes */ | ||
286 | disable_prbs_symbols(enc10, false); | ||
287 | |||
288 | /* For PRBS7 Set bit DPHY_PRBS_SEL=0 and Set bit DPHY_PRBS_EN=1 */ | ||
289 | REG_UPDATE_2(DP_DPHY_PRBS_CNTL, | ||
290 | DPHY_PRBS_SEL, 0, | ||
291 | DPHY_PRBS_EN, 1); | ||
292 | |||
293 | /* Enable phy bypass mode to enable the test pattern */ | ||
294 | enable_phy_bypass_mode(enc10, true); | ||
295 | } | ||
296 | |||
297 | static void set_dp_phy_pattern_80bit_custom( | ||
298 | struct dcn10_link_encoder *enc10, | ||
299 | const uint8_t *pattern) | ||
300 | { | ||
301 | /* Disable PHY Bypass mode to setup the test pattern */ | ||
302 | enable_phy_bypass_mode(enc10, false); | ||
303 | |||
304 | /* Enable debug symbols on the lanes */ | ||
305 | |||
306 | disable_prbs_symbols(enc10, true); | ||
307 | |||
308 | /* Enable PHY bypass mode to enable the test pattern */ | ||
309 | /* TODO is it really needed ? */ | ||
310 | |||
311 | enable_phy_bypass_mode(enc10, true); | ||
312 | |||
313 | /* Program 80 bit custom pattern */ | ||
314 | { | ||
315 | uint16_t pattern_symbols[8]; | ||
316 | |||
317 | pattern_symbols[0] = | ||
318 | ((pattern[1] & 0x03) << 8) | pattern[0]; | ||
319 | pattern_symbols[1] = | ||
320 | ((pattern[2] & 0x0f) << 6) | ((pattern[1] >> 2) & 0x3f); | ||
321 | pattern_symbols[2] = | ||
322 | ((pattern[3] & 0x3f) << 4) | ((pattern[2] >> 4) & 0x0f); | ||
323 | pattern_symbols[3] = | ||
324 | (pattern[4] << 2) | ((pattern[3] >> 6) & 0x03); | ||
325 | pattern_symbols[4] = | ||
326 | ((pattern[6] & 0x03) << 8) | pattern[5]; | ||
327 | pattern_symbols[5] = | ||
328 | ((pattern[7] & 0x0f) << 6) | ((pattern[6] >> 2) & 0x3f); | ||
329 | pattern_symbols[6] = | ||
330 | ((pattern[8] & 0x3f) << 4) | ((pattern[7] >> 4) & 0x0f); | ||
331 | pattern_symbols[7] = | ||
332 | (pattern[9] << 2) | ((pattern[8] >> 6) & 0x03); | ||
333 | |||
334 | program_pattern_symbols(enc10, pattern_symbols); | ||
335 | } | ||
336 | |||
337 | /* Enable phy bypass mode to enable the test pattern */ | ||
338 | |||
339 | enable_phy_bypass_mode(enc10, true); | ||
340 | } | ||
341 | |||
342 | static void set_dp_phy_pattern_hbr2_compliance_cp2520_2( | ||
343 | struct dcn10_link_encoder *enc10, | ||
344 | unsigned int cp2520_pattern) | ||
345 | { | ||
346 | |||
347 | /* previously there is a register DP_HBR2_EYE_PATTERN | ||
348 | * that is enabled to get the pattern. | ||
349 | * But it does not work with the latest spec change, | ||
350 | * so we are programming the following registers manually. | ||
351 | * | ||
352 | * The following settings have been confirmed | ||
353 | * by Nick Chorney and Sandra Liu | ||
354 | */ | ||
355 | |||
356 | /* Disable PHY Bypass mode to setup the test pattern */ | ||
357 | |||
358 | enable_phy_bypass_mode(enc10, false); | ||
359 | |||
360 | /* Setup DIG encoder in DP SST mode */ | ||
361 | enc10->base.funcs->setup(&enc10->base, SIGNAL_TYPE_DISPLAY_PORT); | ||
362 | |||
363 | /* ensure normal panel mode. */ | ||
364 | setup_panel_mode(enc10, DP_PANEL_MODE_DEFAULT); | ||
365 | |||
366 | /* no vbid after BS (SR) | ||
367 | * DP_LINK_FRAMING_CNTL changed history Sandra Liu | ||
368 | * 11000260 / 11000104 / 110000FC | ||
369 | */ | ||
370 | REG_UPDATE_3(DP_LINK_FRAMING_CNTL, | ||
371 | DP_IDLE_BS_INTERVAL, 0xFC, | ||
372 | DP_VBID_DISABLE, 1, | ||
373 | DP_VID_ENHANCED_FRAME_MODE, 1); | ||
374 | |||
375 | /* swap every BS with SR */ | ||
376 | REG_UPDATE(DP_DPHY_SCRAM_CNTL, DPHY_SCRAMBLER_BS_COUNT, 0); | ||
377 | |||
378 | /* select cp2520 patterns */ | ||
379 | if (REG(DP_DPHY_HBR2_PATTERN_CONTROL)) | ||
380 | REG_UPDATE(DP_DPHY_HBR2_PATTERN_CONTROL, | ||
381 | DP_DPHY_HBR2_PATTERN_CONTROL, cp2520_pattern); | ||
382 | else | ||
383 | /* pre-DCE11 can only generate CP2520 pattern 2 */ | ||
384 | ASSERT(cp2520_pattern == 2); | ||
385 | |||
386 | /* set link training complete */ | ||
387 | set_link_training_complete(enc10, true); | ||
388 | |||
389 | /* disable video stream */ | ||
390 | REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, 0); | ||
391 | |||
392 | /* Disable PHY Bypass mode to setup the test pattern */ | ||
393 | enable_phy_bypass_mode(enc10, false); | ||
394 | } | ||
395 | |||
396 | static void set_dp_phy_pattern_passthrough_mode( | ||
397 | struct dcn10_link_encoder *enc10, | ||
398 | enum dp_panel_mode panel_mode) | ||
399 | { | ||
400 | /* program correct panel mode */ | ||
401 | setup_panel_mode(enc10, panel_mode); | ||
402 | |||
403 | /* restore LINK_FRAMING_CNTL and DPHY_SCRAMBLER_BS_COUNT | ||
404 | * in case we were doing HBR2 compliance pattern before | ||
405 | */ | ||
406 | REG_UPDATE_3(DP_LINK_FRAMING_CNTL, | ||
407 | DP_IDLE_BS_INTERVAL, 0x2000, | ||
408 | DP_VBID_DISABLE, 0, | ||
409 | DP_VID_ENHANCED_FRAME_MODE, 1); | ||
410 | |||
411 | REG_UPDATE(DP_DPHY_SCRAM_CNTL, DPHY_SCRAMBLER_BS_COUNT, 0x1FF); | ||
412 | |||
413 | /* set link training complete */ | ||
414 | set_link_training_complete(enc10, true); | ||
415 | |||
416 | /* Disable PHY Bypass mode to setup the test pattern */ | ||
417 | enable_phy_bypass_mode(enc10, false); | ||
418 | |||
419 | /* Disable PRBS mode */ | ||
420 | disable_prbs_mode(enc10); | ||
421 | } | ||
422 | |||
423 | /* return value is bit-vector */ | ||
424 | static uint8_t get_frontend_source( | ||
425 | enum engine_id engine) | ||
426 | { | ||
427 | switch (engine) { | ||
428 | case ENGINE_ID_DIGA: | ||
429 | return DCN10_DIG_FE_SOURCE_SELECT_DIGA; | ||
430 | case ENGINE_ID_DIGB: | ||
431 | return DCN10_DIG_FE_SOURCE_SELECT_DIGB; | ||
432 | case ENGINE_ID_DIGC: | ||
433 | return DCN10_DIG_FE_SOURCE_SELECT_DIGC; | ||
434 | case ENGINE_ID_DIGD: | ||
435 | return DCN10_DIG_FE_SOURCE_SELECT_DIGD; | ||
436 | case ENGINE_ID_DIGE: | ||
437 | return DCN10_DIG_FE_SOURCE_SELECT_DIGE; | ||
438 | case ENGINE_ID_DIGF: | ||
439 | return DCN10_DIG_FE_SOURCE_SELECT_DIGF; | ||
440 | case ENGINE_ID_DIGG: | ||
441 | return DCN10_DIG_FE_SOURCE_SELECT_DIGG; | ||
442 | default: | ||
443 | ASSERT_CRITICAL(false); | ||
444 | return DCN10_DIG_FE_SOURCE_SELECT_INVALID; | ||
445 | } | ||
446 | } | ||
447 | |||
448 | static void configure_encoder( | ||
449 | struct dcn10_link_encoder *enc10, | ||
450 | const struct dc_link_settings *link_settings) | ||
451 | { | ||
452 | /* set number of lanes */ | ||
453 | |||
454 | REG_SET(DP_CONFIG, 0, | ||
455 | DP_UDI_LANES, link_settings->lane_count - LANE_COUNT_ONE); | ||
456 | |||
457 | /* setup scrambler */ | ||
458 | REG_UPDATE(DP_DPHY_SCRAM_CNTL, DPHY_SCRAMBLER_ADVANCE, 1); | ||
459 | } | ||
460 | |||
461 | void dcn10_psr_program_dp_dphy_fast_training(struct link_encoder *enc, | ||
462 | bool exit_link_training_required) | ||
463 | { | ||
464 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
465 | |||
466 | if (exit_link_training_required) | ||
467 | REG_UPDATE(DP_DPHY_FAST_TRAINING, | ||
468 | DPHY_RX_FAST_TRAINING_CAPABLE, 1); | ||
469 | else { | ||
470 | REG_UPDATE(DP_DPHY_FAST_TRAINING, | ||
471 | DPHY_RX_FAST_TRAINING_CAPABLE, 0); | ||
472 | /*In DCE 11, we are able to pre-program a Force SR register | ||
473 | * to be able to trigger SR symbol after 5 idle patterns | ||
474 | * transmitted. Upon PSR Exit, DMCU can trigger | ||
475 | * DPHY_LOAD_BS_COUNT_START = 1. Upon writing 1 to | ||
476 | * DPHY_LOAD_BS_COUNT_START and the internal counter | ||
477 | * reaches DPHY_LOAD_BS_COUNT, the next BS symbol will be | ||
478 | * replaced by SR symbol once. | ||
479 | */ | ||
480 | |||
481 | REG_UPDATE(DP_DPHY_BS_SR_SWAP_CNTL, DPHY_LOAD_BS_COUNT, 0x5); | ||
482 | } | ||
483 | } | ||
484 | |||
485 | void dcn10_psr_program_secondary_packet(struct link_encoder *enc, | ||
486 | unsigned int sdp_transmit_line_num_deadline) | ||
487 | { | ||
488 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
489 | |||
490 | REG_UPDATE_2(DP_SEC_CNTL1, | ||
491 | DP_SEC_GSP0_LINE_NUM, sdp_transmit_line_num_deadline, | ||
492 | DP_SEC_GSP0_PRIORITY, 1); | ||
493 | } | ||
494 | |||
495 | bool dcn10_is_dig_enabled(struct link_encoder *enc) | ||
496 | { | ||
497 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
498 | uint32_t value; | ||
499 | |||
500 | REG_GET(DIG_BE_EN_CNTL, DIG_ENABLE, &value); | ||
501 | return value; | ||
502 | } | ||
503 | |||
504 | static void link_encoder_disable(struct dcn10_link_encoder *enc10) | ||
505 | { | ||
506 | /* reset training pattern */ | ||
507 | REG_SET(DP_DPHY_TRAINING_PATTERN_SEL, 0, | ||
508 | DPHY_TRAINING_PATTERN_SEL, 0); | ||
509 | |||
510 | /* reset training complete */ | ||
511 | REG_UPDATE(DP_LINK_CNTL, DP_LINK_TRAINING_COMPLETE, 0); | ||
512 | |||
513 | /* reset panel mode */ | ||
514 | setup_panel_mode(enc10, DP_PANEL_MODE_DEFAULT); | ||
515 | } | ||
516 | |||
517 | static void hpd_initialize( | ||
518 | struct dcn10_link_encoder *enc10) | ||
519 | { | ||
520 | /* Associate HPD with DIG_BE */ | ||
521 | enum hpd_source_id hpd_source = enc10->base.hpd_source; | ||
522 | |||
523 | REG_UPDATE(DIG_BE_CNTL, DIG_HPD_SELECT, hpd_source); | ||
524 | } | ||
525 | |||
526 | bool dcn10_link_encoder_validate_dvi_output( | ||
527 | const struct dcn10_link_encoder *enc10, | ||
528 | enum signal_type connector_signal, | ||
529 | enum signal_type signal, | ||
530 | const struct dc_crtc_timing *crtc_timing) | ||
531 | { | ||
532 | uint32_t max_pixel_clock = TMDS_MAX_PIXEL_CLOCK; | ||
533 | |||
534 | if (signal == SIGNAL_TYPE_DVI_DUAL_LINK) | ||
535 | max_pixel_clock *= 2; | ||
536 | |||
537 | /* This handles the case of HDMI downgrade to DVI we don't want to | ||
538 | * we don't want to cap the pixel clock if the DDI is not DVI. | ||
539 | */ | ||
540 | if (connector_signal != SIGNAL_TYPE_DVI_DUAL_LINK && | ||
541 | connector_signal != SIGNAL_TYPE_DVI_SINGLE_LINK) | ||
542 | max_pixel_clock = enc10->base.features.max_hdmi_pixel_clock; | ||
543 | |||
544 | /* DVI only support RGB pixel encoding */ | ||
545 | if (crtc_timing->pixel_encoding != PIXEL_ENCODING_RGB) | ||
546 | return false; | ||
547 | |||
548 | /*connect DVI via adpater's HDMI connector*/ | ||
549 | if ((connector_signal == SIGNAL_TYPE_DVI_SINGLE_LINK || | ||
550 | connector_signal == SIGNAL_TYPE_HDMI_TYPE_A) && | ||
551 | signal != SIGNAL_TYPE_HDMI_TYPE_A && | ||
552 | crtc_timing->pix_clk_khz > TMDS_MAX_PIXEL_CLOCK) | ||
553 | return false; | ||
554 | if (crtc_timing->pix_clk_khz < TMDS_MIN_PIXEL_CLOCK) | ||
555 | return false; | ||
556 | |||
557 | if (crtc_timing->pix_clk_khz > max_pixel_clock) | ||
558 | return false; | ||
559 | |||
560 | /* DVI supports 6/8bpp single-link and 10/16bpp dual-link */ | ||
561 | switch (crtc_timing->display_color_depth) { | ||
562 | case COLOR_DEPTH_666: | ||
563 | case COLOR_DEPTH_888: | ||
564 | break; | ||
565 | case COLOR_DEPTH_101010: | ||
566 | case COLOR_DEPTH_161616: | ||
567 | if (signal != SIGNAL_TYPE_DVI_DUAL_LINK) | ||
568 | return false; | ||
569 | break; | ||
570 | default: | ||
571 | return false; | ||
572 | } | ||
573 | |||
574 | return true; | ||
575 | } | ||
576 | |||
577 | static bool dcn10_link_encoder_validate_hdmi_output( | ||
578 | const struct dcn10_link_encoder *enc10, | ||
579 | const struct dc_crtc_timing *crtc_timing, | ||
580 | int adjusted_pix_clk_khz) | ||
581 | { | ||
582 | enum dc_color_depth max_deep_color = | ||
583 | enc10->base.features.max_hdmi_deep_color; | ||
584 | |||
585 | if (max_deep_color < crtc_timing->display_color_depth) | ||
586 | return false; | ||
587 | |||
588 | if (crtc_timing->display_color_depth < COLOR_DEPTH_888) | ||
589 | return false; | ||
590 | if (adjusted_pix_clk_khz < TMDS_MIN_PIXEL_CLOCK) | ||
591 | return false; | ||
592 | |||
593 | if ((adjusted_pix_clk_khz == 0) || | ||
594 | (adjusted_pix_clk_khz > enc10->base.features.max_hdmi_pixel_clock)) | ||
595 | return false; | ||
596 | |||
597 | /* DCE11 HW does not support 420 */ | ||
598 | if (!enc10->base.features.ycbcr420_supported && | ||
599 | crtc_timing->pixel_encoding == PIXEL_ENCODING_YCBCR420) | ||
600 | return false; | ||
601 | |||
602 | if (!enc10->base.features.flags.bits.HDMI_6GB_EN && | ||
603 | adjusted_pix_clk_khz >= 300000) | ||
604 | return false; | ||
605 | return true; | ||
606 | } | ||
607 | |||
608 | bool dcn10_link_encoder_validate_dp_output( | ||
609 | const struct dcn10_link_encoder *enc10, | ||
610 | const struct dc_crtc_timing *crtc_timing) | ||
611 | { | ||
612 | /* default RGB only */ | ||
613 | if (crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) | ||
614 | return true; | ||
615 | |||
616 | if (enc10->base.features.flags.bits.IS_YCBCR_CAPABLE) | ||
617 | return true; | ||
618 | |||
619 | /* for DCE 8.x or later DP Y-only feature, | ||
620 | * we need ASIC cap + FeatureSupportDPYonly, not support 666 | ||
621 | */ | ||
622 | if (crtc_timing->flags.Y_ONLY && | ||
623 | enc10->base.features.flags.bits.IS_YCBCR_CAPABLE && | ||
624 | crtc_timing->display_color_depth != COLOR_DEPTH_666) | ||
625 | return true; | ||
626 | |||
627 | return false; | ||
628 | } | ||
629 | |||
630 | void dcn10_link_encoder_construct( | ||
631 | struct dcn10_link_encoder *enc10, | ||
632 | const struct encoder_init_data *init_data, | ||
633 | const struct encoder_feature_support *enc_features, | ||
634 | const struct dcn10_link_enc_registers *link_regs, | ||
635 | const struct dcn10_link_enc_aux_registers *aux_regs, | ||
636 | const struct dcn10_link_enc_hpd_registers *hpd_regs, | ||
637 | const struct dcn10_link_enc_shift *link_shift, | ||
638 | const struct dcn10_link_enc_mask *link_mask) | ||
639 | { | ||
640 | struct bp_encoder_cap_info bp_cap_info = {0}; | ||
641 | const struct dc_vbios_funcs *bp_funcs = init_data->ctx->dc_bios->funcs; | ||
642 | enum bp_result result = BP_RESULT_OK; | ||
643 | |||
644 | enc10->base.funcs = &dcn10_lnk_enc_funcs; | ||
645 | enc10->base.ctx = init_data->ctx; | ||
646 | enc10->base.id = init_data->encoder; | ||
647 | |||
648 | enc10->base.hpd_source = init_data->hpd_source; | ||
649 | enc10->base.connector = init_data->connector; | ||
650 | |||
651 | enc10->base.preferred_engine = ENGINE_ID_UNKNOWN; | ||
652 | |||
653 | enc10->base.features = *enc_features; | ||
654 | |||
655 | enc10->base.transmitter = init_data->transmitter; | ||
656 | |||
657 | /* set the flag to indicate whether driver poll the I2C data pin | ||
658 | * while doing the DP sink detect | ||
659 | */ | ||
660 | |||
661 | /* if (dal_adapter_service_is_feature_supported(as, | ||
662 | FEATURE_DP_SINK_DETECT_POLL_DATA_PIN)) | ||
663 | enc10->base.features.flags.bits. | ||
664 | DP_SINK_DETECT_POLL_DATA_PIN = true;*/ | ||
665 | |||
666 | enc10->base.output_signals = | ||
667 | SIGNAL_TYPE_DVI_SINGLE_LINK | | ||
668 | SIGNAL_TYPE_DVI_DUAL_LINK | | ||
669 | SIGNAL_TYPE_LVDS | | ||
670 | SIGNAL_TYPE_DISPLAY_PORT | | ||
671 | SIGNAL_TYPE_DISPLAY_PORT_MST | | ||
672 | SIGNAL_TYPE_EDP | | ||
673 | SIGNAL_TYPE_HDMI_TYPE_A; | ||
674 | |||
675 | /* For DCE 8.0 and 8.1, by design, UNIPHY is hardwired to DIG_BE. | ||
676 | * SW always assign DIG_FE 1:1 mapped to DIG_FE for non-MST UNIPHY. | ||
677 | * SW assign DIG_FE to non-MST UNIPHY first and MST last. So prefer | ||
678 | * DIG is per UNIPHY and used by SST DP, eDP, HDMI, DVI and LVDS. | ||
679 | * Prefer DIG assignment is decided by board design. | ||
680 | * For DCE 8.0, there are only max 6 UNIPHYs, we assume board design | ||
681 | * and VBIOS will filter out 7 UNIPHY for DCE 8.0. | ||
682 | * By this, adding DIGG should not hurt DCE 8.0. | ||
683 | * This will let DCE 8.1 share DCE 8.0 as much as possible | ||
684 | */ | ||
685 | |||
686 | enc10->link_regs = link_regs; | ||
687 | enc10->aux_regs = aux_regs; | ||
688 | enc10->hpd_regs = hpd_regs; | ||
689 | enc10->link_shift = link_shift; | ||
690 | enc10->link_mask = link_mask; | ||
691 | |||
692 | switch (enc10->base.transmitter) { | ||
693 | case TRANSMITTER_UNIPHY_A: | ||
694 | enc10->base.preferred_engine = ENGINE_ID_DIGA; | ||
695 | break; | ||
696 | case TRANSMITTER_UNIPHY_B: | ||
697 | enc10->base.preferred_engine = ENGINE_ID_DIGB; | ||
698 | break; | ||
699 | case TRANSMITTER_UNIPHY_C: | ||
700 | enc10->base.preferred_engine = ENGINE_ID_DIGC; | ||
701 | break; | ||
702 | case TRANSMITTER_UNIPHY_D: | ||
703 | enc10->base.preferred_engine = ENGINE_ID_DIGD; | ||
704 | break; | ||
705 | case TRANSMITTER_UNIPHY_E: | ||
706 | enc10->base.preferred_engine = ENGINE_ID_DIGE; | ||
707 | break; | ||
708 | case TRANSMITTER_UNIPHY_F: | ||
709 | enc10->base.preferred_engine = ENGINE_ID_DIGF; | ||
710 | break; | ||
711 | case TRANSMITTER_UNIPHY_G: | ||
712 | enc10->base.preferred_engine = ENGINE_ID_DIGG; | ||
713 | break; | ||
714 | default: | ||
715 | ASSERT_CRITICAL(false); | ||
716 | enc10->base.preferred_engine = ENGINE_ID_UNKNOWN; | ||
717 | } | ||
718 | |||
719 | /* default to one to mirror Windows behavior */ | ||
720 | enc10->base.features.flags.bits.HDMI_6GB_EN = 1; | ||
721 | |||
722 | result = bp_funcs->get_encoder_cap_info(enc10->base.ctx->dc_bios, | ||
723 | enc10->base.id, &bp_cap_info); | ||
724 | |||
725 | /* Override features with DCE-specific values */ | ||
726 | if (result == BP_RESULT_OK) { | ||
727 | enc10->base.features.flags.bits.IS_HBR2_CAPABLE = | ||
728 | bp_cap_info.DP_HBR2_EN; | ||
729 | enc10->base.features.flags.bits.IS_HBR3_CAPABLE = | ||
730 | bp_cap_info.DP_HBR3_EN; | ||
731 | enc10->base.features.flags.bits.HDMI_6GB_EN = bp_cap_info.HDMI_6GB_EN; | ||
732 | } else { | ||
733 | DC_LOG_WARNING("%s: Failed to get encoder_cap_info from VBIOS with error code %d!\n", | ||
734 | __func__, | ||
735 | result); | ||
736 | } | ||
737 | } | ||
738 | |||
739 | bool dcn10_link_encoder_validate_output_with_stream( | ||
740 | struct link_encoder *enc, | ||
741 | const struct dc_stream_state *stream) | ||
742 | { | ||
743 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
744 | bool is_valid; | ||
745 | |||
746 | switch (stream->signal) { | ||
747 | case SIGNAL_TYPE_DVI_SINGLE_LINK: | ||
748 | case SIGNAL_TYPE_DVI_DUAL_LINK: | ||
749 | is_valid = dcn10_link_encoder_validate_dvi_output( | ||
750 | enc10, | ||
751 | stream->sink->link->connector_signal, | ||
752 | stream->signal, | ||
753 | &stream->timing); | ||
754 | break; | ||
755 | case SIGNAL_TYPE_HDMI_TYPE_A: | ||
756 | is_valid = dcn10_link_encoder_validate_hdmi_output( | ||
757 | enc10, | ||
758 | &stream->timing, | ||
759 | stream->phy_pix_clk); | ||
760 | break; | ||
761 | case SIGNAL_TYPE_DISPLAY_PORT: | ||
762 | case SIGNAL_TYPE_DISPLAY_PORT_MST: | ||
763 | is_valid = dcn10_link_encoder_validate_dp_output( | ||
764 | enc10, &stream->timing); | ||
765 | break; | ||
766 | case SIGNAL_TYPE_EDP: | ||
767 | is_valid = (stream->timing.pixel_encoding == PIXEL_ENCODING_RGB) ? true : false; | ||
768 | break; | ||
769 | case SIGNAL_TYPE_VIRTUAL: | ||
770 | is_valid = true; | ||
771 | break; | ||
772 | default: | ||
773 | is_valid = false; | ||
774 | break; | ||
775 | } | ||
776 | |||
777 | return is_valid; | ||
778 | } | ||
779 | |||
780 | void dcn10_link_encoder_hw_init( | ||
781 | struct link_encoder *enc) | ||
782 | { | ||
783 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
784 | struct bp_transmitter_control cntl = { 0 }; | ||
785 | enum bp_result result; | ||
786 | |||
787 | cntl.action = TRANSMITTER_CONTROL_INIT; | ||
788 | cntl.engine_id = ENGINE_ID_UNKNOWN; | ||
789 | cntl.transmitter = enc10->base.transmitter; | ||
790 | cntl.connector_obj_id = enc10->base.connector; | ||
791 | cntl.lanes_number = LANE_COUNT_FOUR; | ||
792 | cntl.coherent = false; | ||
793 | cntl.hpd_sel = enc10->base.hpd_source; | ||
794 | |||
795 | if (enc10->base.connector.id == CONNECTOR_ID_EDP) | ||
796 | cntl.signal = SIGNAL_TYPE_EDP; | ||
797 | |||
798 | result = link_transmitter_control(enc10, &cntl); | ||
799 | |||
800 | if (result != BP_RESULT_OK) { | ||
801 | DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n", | ||
802 | __func__); | ||
803 | BREAK_TO_DEBUGGER(); | ||
804 | return; | ||
805 | } | ||
806 | |||
807 | if (enc10->base.connector.id == CONNECTOR_ID_LVDS) { | ||
808 | cntl.action = TRANSMITTER_CONTROL_BACKLIGHT_BRIGHTNESS; | ||
809 | |||
810 | result = link_transmitter_control(enc10, &cntl); | ||
811 | |||
812 | ASSERT(result == BP_RESULT_OK); | ||
813 | |||
814 | } | ||
815 | aux_initialize(enc10); | ||
816 | |||
817 | /* reinitialize HPD. | ||
818 | * hpd_initialize() will pass DIG_FE id to HW context. | ||
819 | * All other routine within HW context will use fe_engine_offset | ||
820 | * as DIG_FE id even caller pass DIG_FE id. | ||
821 | * So this routine must be called first. | ||
822 | */ | ||
823 | hpd_initialize(enc10); | ||
824 | } | ||
825 | |||
826 | void dcn10_link_encoder_destroy(struct link_encoder **enc) | ||
827 | { | ||
828 | kfree(TO_DCN10_LINK_ENC(*enc)); | ||
829 | *enc = NULL; | ||
830 | } | ||
831 | |||
832 | void dcn10_link_encoder_setup( | ||
833 | struct link_encoder *enc, | ||
834 | enum signal_type signal) | ||
835 | { | ||
836 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
837 | |||
838 | switch (signal) { | ||
839 | case SIGNAL_TYPE_EDP: | ||
840 | case SIGNAL_TYPE_DISPLAY_PORT: | ||
841 | /* DP SST */ | ||
842 | REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 0); | ||
843 | break; | ||
844 | case SIGNAL_TYPE_LVDS: | ||
845 | /* LVDS */ | ||
846 | REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 1); | ||
847 | break; | ||
848 | case SIGNAL_TYPE_DVI_SINGLE_LINK: | ||
849 | case SIGNAL_TYPE_DVI_DUAL_LINK: | ||
850 | /* TMDS-DVI */ | ||
851 | REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 2); | ||
852 | break; | ||
853 | case SIGNAL_TYPE_HDMI_TYPE_A: | ||
854 | /* TMDS-HDMI */ | ||
855 | REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 3); | ||
856 | break; | ||
857 | case SIGNAL_TYPE_DISPLAY_PORT_MST: | ||
858 | /* DP MST */ | ||
859 | REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 5); | ||
860 | break; | ||
861 | default: | ||
862 | ASSERT_CRITICAL(false); | ||
863 | /* invalid mode ! */ | ||
864 | break; | ||
865 | } | ||
866 | |||
867 | } | ||
868 | |||
869 | /* TODO: still need depth or just pass in adjusted pixel clock? */ | ||
870 | void dcn10_link_encoder_enable_tmds_output( | ||
871 | struct link_encoder *enc, | ||
872 | enum clock_source_id clock_source, | ||
873 | enum dc_color_depth color_depth, | ||
874 | enum signal_type signal, | ||
875 | uint32_t pixel_clock) | ||
876 | { | ||
877 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
878 | struct bp_transmitter_control cntl = { 0 }; | ||
879 | enum bp_result result; | ||
880 | |||
881 | /* Enable the PHY */ | ||
882 | |||
883 | cntl.action = TRANSMITTER_CONTROL_ENABLE; | ||
884 | cntl.engine_id = enc->preferred_engine; | ||
885 | cntl.transmitter = enc10->base.transmitter; | ||
886 | cntl.pll_id = clock_source; | ||
887 | cntl.signal = signal; | ||
888 | if (cntl.signal == SIGNAL_TYPE_DVI_DUAL_LINK) | ||
889 | cntl.lanes_number = 8; | ||
890 | else | ||
891 | cntl.lanes_number = 4; | ||
892 | |||
893 | cntl.hpd_sel = enc10->base.hpd_source; | ||
894 | |||
895 | cntl.pixel_clock = pixel_clock; | ||
896 | cntl.color_depth = color_depth; | ||
897 | |||
898 | result = link_transmitter_control(enc10, &cntl); | ||
899 | |||
900 | if (result != BP_RESULT_OK) { | ||
901 | DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n", | ||
902 | __func__); | ||
903 | BREAK_TO_DEBUGGER(); | ||
904 | } | ||
905 | } | ||
906 | |||
907 | /* enables DP PHY output */ | ||
908 | void dcn10_link_encoder_enable_dp_output( | ||
909 | struct link_encoder *enc, | ||
910 | const struct dc_link_settings *link_settings, | ||
911 | enum clock_source_id clock_source) | ||
912 | { | ||
913 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
914 | struct bp_transmitter_control cntl = { 0 }; | ||
915 | enum bp_result result; | ||
916 | |||
917 | /* Enable the PHY */ | ||
918 | |||
919 | /* number_of_lanes is used for pixel clock adjust, | ||
920 | * but it's not passed to asic_control. | ||
921 | * We need to set number of lanes manually. | ||
922 | */ | ||
923 | configure_encoder(enc10, link_settings); | ||
924 | |||
925 | cntl.action = TRANSMITTER_CONTROL_ENABLE; | ||
926 | cntl.engine_id = enc->preferred_engine; | ||
927 | cntl.transmitter = enc10->base.transmitter; | ||
928 | cntl.pll_id = clock_source; | ||
929 | cntl.signal = SIGNAL_TYPE_DISPLAY_PORT; | ||
930 | cntl.lanes_number = link_settings->lane_count; | ||
931 | cntl.hpd_sel = enc10->base.hpd_source; | ||
932 | cntl.pixel_clock = link_settings->link_rate | ||
933 | * LINK_RATE_REF_FREQ_IN_KHZ; | ||
934 | /* TODO: check if undefined works */ | ||
935 | cntl.color_depth = COLOR_DEPTH_UNDEFINED; | ||
936 | |||
937 | result = link_transmitter_control(enc10, &cntl); | ||
938 | |||
939 | if (result != BP_RESULT_OK) { | ||
940 | DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n", | ||
941 | __func__); | ||
942 | BREAK_TO_DEBUGGER(); | ||
943 | } | ||
944 | } | ||
945 | |||
946 | /* enables DP PHY output in MST mode */ | ||
947 | void dcn10_link_encoder_enable_dp_mst_output( | ||
948 | struct link_encoder *enc, | ||
949 | const struct dc_link_settings *link_settings, | ||
950 | enum clock_source_id clock_source) | ||
951 | { | ||
952 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
953 | struct bp_transmitter_control cntl = { 0 }; | ||
954 | enum bp_result result; | ||
955 | |||
956 | /* Enable the PHY */ | ||
957 | |||
958 | /* number_of_lanes is used for pixel clock adjust, | ||
959 | * but it's not passed to asic_control. | ||
960 | * We need to set number of lanes manually. | ||
961 | */ | ||
962 | configure_encoder(enc10, link_settings); | ||
963 | |||
964 | cntl.action = TRANSMITTER_CONTROL_ENABLE; | ||
965 | cntl.engine_id = ENGINE_ID_UNKNOWN; | ||
966 | cntl.transmitter = enc10->base.transmitter; | ||
967 | cntl.pll_id = clock_source; | ||
968 | cntl.signal = SIGNAL_TYPE_DISPLAY_PORT_MST; | ||
969 | cntl.lanes_number = link_settings->lane_count; | ||
970 | cntl.hpd_sel = enc10->base.hpd_source; | ||
971 | cntl.pixel_clock = link_settings->link_rate | ||
972 | * LINK_RATE_REF_FREQ_IN_KHZ; | ||
973 | /* TODO: check if undefined works */ | ||
974 | cntl.color_depth = COLOR_DEPTH_UNDEFINED; | ||
975 | |||
976 | result = link_transmitter_control(enc10, &cntl); | ||
977 | |||
978 | if (result != BP_RESULT_OK) { | ||
979 | DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n", | ||
980 | __func__); | ||
981 | BREAK_TO_DEBUGGER(); | ||
982 | } | ||
983 | } | ||
984 | /* | ||
985 | * @brief | ||
986 | * Disable transmitter and its encoder | ||
987 | */ | ||
988 | void dcn10_link_encoder_disable_output( | ||
989 | struct link_encoder *enc, | ||
990 | enum signal_type signal) | ||
991 | { | ||
992 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
993 | struct bp_transmitter_control cntl = { 0 }; | ||
994 | enum bp_result result; | ||
995 | |||
996 | if (!dcn10_is_dig_enabled(enc)) { | ||
997 | /* OF_SKIP_POWER_DOWN_INACTIVE_ENCODER */ | ||
998 | return; | ||
999 | } | ||
1000 | /* Power-down RX and disable GPU PHY should be paired. | ||
1001 | * Disabling PHY without powering down RX may cause | ||
1002 | * symbol lock loss, on which we will get DP Sink interrupt. | ||
1003 | */ | ||
1004 | |||
1005 | /* There is a case for the DP active dongles | ||
1006 | * where we want to disable the PHY but keep RX powered, | ||
1007 | * for those we need to ignore DP Sink interrupt | ||
1008 | * by checking lane count that has been set | ||
1009 | * on the last do_enable_output(). | ||
1010 | */ | ||
1011 | |||
1012 | /* disable transmitter */ | ||
1013 | cntl.action = TRANSMITTER_CONTROL_DISABLE; | ||
1014 | cntl.transmitter = enc10->base.transmitter; | ||
1015 | cntl.hpd_sel = enc10->base.hpd_source; | ||
1016 | cntl.signal = signal; | ||
1017 | cntl.connector_obj_id = enc10->base.connector; | ||
1018 | |||
1019 | result = link_transmitter_control(enc10, &cntl); | ||
1020 | |||
1021 | if (result != BP_RESULT_OK) { | ||
1022 | DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n", | ||
1023 | __func__); | ||
1024 | BREAK_TO_DEBUGGER(); | ||
1025 | return; | ||
1026 | } | ||
1027 | |||
1028 | /* disable encoder */ | ||
1029 | if (dc_is_dp_signal(signal)) | ||
1030 | link_encoder_disable(enc10); | ||
1031 | } | ||
1032 | |||
1033 | void dcn10_link_encoder_dp_set_lane_settings( | ||
1034 | struct link_encoder *enc, | ||
1035 | const struct link_training_settings *link_settings) | ||
1036 | { | ||
1037 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
1038 | union dpcd_training_lane_set training_lane_set = { { 0 } }; | ||
1039 | int32_t lane = 0; | ||
1040 | struct bp_transmitter_control cntl = { 0 }; | ||
1041 | |||
1042 | if (!link_settings) { | ||
1043 | BREAK_TO_DEBUGGER(); | ||
1044 | return; | ||
1045 | } | ||
1046 | |||
1047 | cntl.action = TRANSMITTER_CONTROL_SET_VOLTAGE_AND_PREEMPASIS; | ||
1048 | cntl.transmitter = enc10->base.transmitter; | ||
1049 | cntl.connector_obj_id = enc10->base.connector; | ||
1050 | cntl.lanes_number = link_settings->link_settings.lane_count; | ||
1051 | cntl.hpd_sel = enc10->base.hpd_source; | ||
1052 | cntl.pixel_clock = link_settings->link_settings.link_rate * | ||
1053 | LINK_RATE_REF_FREQ_IN_KHZ; | ||
1054 | |||
1055 | for (lane = 0; lane < link_settings->link_settings.lane_count; lane++) { | ||
1056 | /* translate lane settings */ | ||
1057 | |||
1058 | training_lane_set.bits.VOLTAGE_SWING_SET = | ||
1059 | link_settings->lane_settings[lane].VOLTAGE_SWING; | ||
1060 | training_lane_set.bits.PRE_EMPHASIS_SET = | ||
1061 | link_settings->lane_settings[lane].PRE_EMPHASIS; | ||
1062 | |||
1063 | /* post cursor 2 setting only applies to HBR2 link rate */ | ||
1064 | if (link_settings->link_settings.link_rate == LINK_RATE_HIGH2) { | ||
1065 | /* this is passed to VBIOS | ||
1066 | * to program post cursor 2 level | ||
1067 | */ | ||
1068 | training_lane_set.bits.POST_CURSOR2_SET = | ||
1069 | link_settings->lane_settings[lane].POST_CURSOR2; | ||
1070 | } | ||
1071 | |||
1072 | cntl.lane_select = lane; | ||
1073 | cntl.lane_settings = training_lane_set.raw; | ||
1074 | |||
1075 | /* call VBIOS table to set voltage swing and pre-emphasis */ | ||
1076 | link_transmitter_control(enc10, &cntl); | ||
1077 | } | ||
1078 | } | ||
1079 | |||
1080 | /* set DP PHY test and training patterns */ | ||
1081 | void dcn10_link_encoder_dp_set_phy_pattern( | ||
1082 | struct link_encoder *enc, | ||
1083 | const struct encoder_set_dp_phy_pattern_param *param) | ||
1084 | { | ||
1085 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
1086 | |||
1087 | switch (param->dp_phy_pattern) { | ||
1088 | case DP_TEST_PATTERN_TRAINING_PATTERN1: | ||
1089 | dcn10_link_encoder_set_dp_phy_pattern_training_pattern(enc, 0); | ||
1090 | break; | ||
1091 | case DP_TEST_PATTERN_TRAINING_PATTERN2: | ||
1092 | dcn10_link_encoder_set_dp_phy_pattern_training_pattern(enc, 1); | ||
1093 | break; | ||
1094 | case DP_TEST_PATTERN_TRAINING_PATTERN3: | ||
1095 | dcn10_link_encoder_set_dp_phy_pattern_training_pattern(enc, 2); | ||
1096 | break; | ||
1097 | case DP_TEST_PATTERN_TRAINING_PATTERN4: | ||
1098 | dcn10_link_encoder_set_dp_phy_pattern_training_pattern(enc, 3); | ||
1099 | break; | ||
1100 | case DP_TEST_PATTERN_D102: | ||
1101 | set_dp_phy_pattern_d102(enc10); | ||
1102 | break; | ||
1103 | case DP_TEST_PATTERN_SYMBOL_ERROR: | ||
1104 | set_dp_phy_pattern_symbol_error(enc10); | ||
1105 | break; | ||
1106 | case DP_TEST_PATTERN_PRBS7: | ||
1107 | set_dp_phy_pattern_prbs7(enc10); | ||
1108 | break; | ||
1109 | case DP_TEST_PATTERN_80BIT_CUSTOM: | ||
1110 | set_dp_phy_pattern_80bit_custom( | ||
1111 | enc10, param->custom_pattern); | ||
1112 | break; | ||
1113 | case DP_TEST_PATTERN_CP2520_1: | ||
1114 | set_dp_phy_pattern_hbr2_compliance_cp2520_2(enc10, 1); | ||
1115 | break; | ||
1116 | case DP_TEST_PATTERN_CP2520_2: | ||
1117 | set_dp_phy_pattern_hbr2_compliance_cp2520_2(enc10, 2); | ||
1118 | break; | ||
1119 | case DP_TEST_PATTERN_CP2520_3: | ||
1120 | set_dp_phy_pattern_hbr2_compliance_cp2520_2(enc10, 3); | ||
1121 | break; | ||
1122 | case DP_TEST_PATTERN_VIDEO_MODE: { | ||
1123 | set_dp_phy_pattern_passthrough_mode( | ||
1124 | enc10, param->dp_panel_mode); | ||
1125 | break; | ||
1126 | } | ||
1127 | |||
1128 | default: | ||
1129 | /* invalid phy pattern */ | ||
1130 | ASSERT_CRITICAL(false); | ||
1131 | break; | ||
1132 | } | ||
1133 | } | ||
1134 | |||
1135 | static void fill_stream_allocation_row_info( | ||
1136 | const struct link_mst_stream_allocation *stream_allocation, | ||
1137 | uint32_t *src, | ||
1138 | uint32_t *slots) | ||
1139 | { | ||
1140 | const struct stream_encoder *stream_enc = stream_allocation->stream_enc; | ||
1141 | |||
1142 | if (stream_enc) { | ||
1143 | *src = stream_enc->id; | ||
1144 | *slots = stream_allocation->slot_count; | ||
1145 | } else { | ||
1146 | *src = 0; | ||
1147 | *slots = 0; | ||
1148 | } | ||
1149 | } | ||
1150 | |||
1151 | /* programs DP MST VC payload allocation */ | ||
1152 | void dcn10_link_encoder_update_mst_stream_allocation_table( | ||
1153 | struct link_encoder *enc, | ||
1154 | const struct link_mst_stream_allocation_table *table) | ||
1155 | { | ||
1156 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
1157 | uint32_t value0 = 0; | ||
1158 | uint32_t value1 = 0; | ||
1159 | uint32_t value2 = 0; | ||
1160 | uint32_t slots = 0; | ||
1161 | uint32_t src = 0; | ||
1162 | uint32_t retries = 0; | ||
1163 | |||
1164 | /* For CZ, there are only 3 pipes. So Virtual channel is up 3.*/ | ||
1165 | |||
1166 | /* --- Set MSE Stream Attribute - | ||
1167 | * Setup VC Payload Table on Tx Side, | ||
1168 | * Issue allocation change trigger | ||
1169 | * to commit payload on both tx and rx side | ||
1170 | */ | ||
1171 | |||
1172 | /* we should clean-up table each time */ | ||
1173 | |||
1174 | if (table->stream_count >= 1) { | ||
1175 | fill_stream_allocation_row_info( | ||
1176 | &table->stream_allocations[0], | ||
1177 | &src, | ||
1178 | &slots); | ||
1179 | } else { | ||
1180 | src = 0; | ||
1181 | slots = 0; | ||
1182 | } | ||
1183 | |||
1184 | REG_UPDATE_2(DP_MSE_SAT0, | ||
1185 | DP_MSE_SAT_SRC0, src, | ||
1186 | DP_MSE_SAT_SLOT_COUNT0, slots); | ||
1187 | |||
1188 | if (table->stream_count >= 2) { | ||
1189 | fill_stream_allocation_row_info( | ||
1190 | &table->stream_allocations[1], | ||
1191 | &src, | ||
1192 | &slots); | ||
1193 | } else { | ||
1194 | src = 0; | ||
1195 | slots = 0; | ||
1196 | } | ||
1197 | |||
1198 | REG_UPDATE_2(DP_MSE_SAT0, | ||
1199 | DP_MSE_SAT_SRC1, src, | ||
1200 | DP_MSE_SAT_SLOT_COUNT1, slots); | ||
1201 | |||
1202 | if (table->stream_count >= 3) { | ||
1203 | fill_stream_allocation_row_info( | ||
1204 | &table->stream_allocations[2], | ||
1205 | &src, | ||
1206 | &slots); | ||
1207 | } else { | ||
1208 | src = 0; | ||
1209 | slots = 0; | ||
1210 | } | ||
1211 | |||
1212 | REG_UPDATE_2(DP_MSE_SAT1, | ||
1213 | DP_MSE_SAT_SRC2, src, | ||
1214 | DP_MSE_SAT_SLOT_COUNT2, slots); | ||
1215 | |||
1216 | if (table->stream_count >= 4) { | ||
1217 | fill_stream_allocation_row_info( | ||
1218 | &table->stream_allocations[3], | ||
1219 | &src, | ||
1220 | &slots); | ||
1221 | } else { | ||
1222 | src = 0; | ||
1223 | slots = 0; | ||
1224 | } | ||
1225 | |||
1226 | REG_UPDATE_2(DP_MSE_SAT1, | ||
1227 | DP_MSE_SAT_SRC3, src, | ||
1228 | DP_MSE_SAT_SLOT_COUNT3, slots); | ||
1229 | |||
1230 | /* --- wait for transaction finish */ | ||
1231 | |||
1232 | /* send allocation change trigger (ACT) ? | ||
1233 | * this step first sends the ACT, | ||
1234 | * then double buffers the SAT into the hardware | ||
1235 | * making the new allocation active on the DP MST mode link | ||
1236 | */ | ||
1237 | |||
1238 | /* DP_MSE_SAT_UPDATE: | ||
1239 | * 0 - No Action | ||
1240 | * 1 - Update SAT with trigger | ||
1241 | * 2 - Update SAT without trigger | ||
1242 | */ | ||
1243 | REG_UPDATE(DP_MSE_SAT_UPDATE, | ||
1244 | DP_MSE_SAT_UPDATE, 1); | ||
1245 | |||
1246 | /* wait for update to complete | ||
1247 | * (i.e. DP_MSE_SAT_UPDATE field is reset to 0) | ||
1248 | * then wait for the transmission | ||
1249 | * of at least 16 MTP headers on immediate local link. | ||
1250 | * i.e. DP_MSE_16_MTP_KEEPOUT field (read only) is reset to 0 | ||
1251 | * a value of 1 indicates that DP MST mode | ||
1252 | * is in the 16 MTP keepout region after a VC has been added. | ||
1253 | * MST stream bandwidth (VC rate) can be configured | ||
1254 | * after this bit is cleared | ||
1255 | */ | ||
1256 | do { | ||
1257 | udelay(10); | ||
1258 | |||
1259 | value0 = REG_READ(DP_MSE_SAT_UPDATE); | ||
1260 | |||
1261 | REG_GET(DP_MSE_SAT_UPDATE, | ||
1262 | DP_MSE_SAT_UPDATE, &value1); | ||
1263 | |||
1264 | REG_GET(DP_MSE_SAT_UPDATE, | ||
1265 | DP_MSE_16_MTP_KEEPOUT, &value2); | ||
1266 | |||
1267 | /* bit field DP_MSE_SAT_UPDATE is set to 1 already */ | ||
1268 | if (!value1 && !value2) | ||
1269 | break; | ||
1270 | ++retries; | ||
1271 | } while (retries < DP_MST_UPDATE_MAX_RETRY); | ||
1272 | } | ||
1273 | |||
1274 | void dcn10_link_encoder_connect_dig_be_to_fe( | ||
1275 | struct link_encoder *enc, | ||
1276 | enum engine_id engine, | ||
1277 | bool connect) | ||
1278 | { | ||
1279 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
1280 | uint32_t field; | ||
1281 | |||
1282 | if (engine != ENGINE_ID_UNKNOWN) { | ||
1283 | |||
1284 | REG_GET(DIG_BE_CNTL, DIG_FE_SOURCE_SELECT, &field); | ||
1285 | |||
1286 | if (connect) | ||
1287 | field |= get_frontend_source(engine); | ||
1288 | else | ||
1289 | field &= ~get_frontend_source(engine); | ||
1290 | |||
1291 | REG_UPDATE(DIG_BE_CNTL, DIG_FE_SOURCE_SELECT, field); | ||
1292 | } | ||
1293 | } | ||
1294 | |||
1295 | |||
1296 | #define HPD_REG(reg)\ | ||
1297 | (enc10->hpd_regs->reg) | ||
1298 | |||
1299 | #define HPD_REG_READ(reg_name) \ | ||
1300 | dm_read_reg(CTX, HPD_REG(reg_name)) | ||
1301 | |||
1302 | #define HPD_REG_UPDATE_N(reg_name, n, ...) \ | ||
1303 | generic_reg_update_ex(CTX, \ | ||
1304 | HPD_REG(reg_name), \ | ||
1305 | HPD_REG_READ(reg_name), \ | ||
1306 | n, __VA_ARGS__) | ||
1307 | |||
1308 | #define HPD_REG_UPDATE(reg_name, field, val) \ | ||
1309 | HPD_REG_UPDATE_N(reg_name, 1, \ | ||
1310 | FN(reg_name, field), val) | ||
1311 | |||
1312 | void dcn10_link_encoder_enable_hpd(struct link_encoder *enc) | ||
1313 | { | ||
1314 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
1315 | |||
1316 | HPD_REG_UPDATE(DC_HPD_CONTROL, | ||
1317 | DC_HPD_EN, 1); | ||
1318 | } | ||
1319 | |||
1320 | void dcn10_link_encoder_disable_hpd(struct link_encoder *enc) | ||
1321 | { | ||
1322 | struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc); | ||
1323 | |||
1324 | HPD_REG_UPDATE(DC_HPD_CONTROL, | ||
1325 | DC_HPD_EN, 0); | ||
1326 | } | ||
1327 | |||
1328 | |||
1329 | #define AUX_REG(reg)\ | ||
1330 | (enc10->aux_regs->reg) | ||
1331 | |||
1332 | #define AUX_REG_READ(reg_name) \ | ||
1333 | dm_read_reg(CTX, AUX_REG(reg_name)) | ||
1334 | |||
1335 | #define AUX_REG_UPDATE_N(reg_name, n, ...) \ | ||
1336 | generic_reg_update_ex(CTX, \ | ||
1337 | AUX_REG(reg_name), \ | ||
1338 | AUX_REG_READ(reg_name), \ | ||
1339 | n, __VA_ARGS__) | ||
1340 | |||
1341 | #define AUX_REG_UPDATE(reg_name, field, val) \ | ||
1342 | AUX_REG_UPDATE_N(reg_name, 1, \ | ||
1343 | FN(reg_name, field), val) | ||
1344 | |||
1345 | #define AUX_REG_UPDATE_2(reg, f1, v1, f2, v2) \ | ||
1346 | AUX_REG_UPDATE_N(reg, 2,\ | ||
1347 | FN(reg, f1), v1,\ | ||
1348 | FN(reg, f2), v2) | ||
1349 | |||
1350 | static void aux_initialize( | ||
1351 | struct dcn10_link_encoder *enc10) | ||
1352 | { | ||
1353 | enum hpd_source_id hpd_source = enc10->base.hpd_source; | ||
1354 | |||
1355 | AUX_REG_UPDATE_2(AUX_CONTROL, | ||
1356 | AUX_HPD_SEL, hpd_source, | ||
1357 | AUX_LS_READ_EN, 0); | ||
1358 | |||
1359 | /* 1/4 window (the maximum allowed) */ | ||
1360 | AUX_REG_UPDATE(AUX_DPHY_RX_CONTROL0, | ||
1361 | AUX_RX_RECEIVE_WINDOW, 1); | ||
1362 | } | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h new file mode 100644 index 000000000000..2a97cdb2cfbb --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h | |||
@@ -0,0 +1,330 @@ | |||
1 | /* | ||
2 | * Copyright 2012-15 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 | * Authors: AMD | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #ifndef __DC_LINK_ENCODER__DCN10_H__ | ||
27 | #define __DC_LINK_ENCODER__DCN10_H__ | ||
28 | |||
29 | #include "link_encoder.h" | ||
30 | |||
31 | #define TO_DCN10_LINK_ENC(link_encoder)\ | ||
32 | container_of(link_encoder, struct dcn10_link_encoder, base) | ||
33 | |||
34 | |||
35 | #define AUX_REG_LIST(id)\ | ||
36 | SRI(AUX_CONTROL, DP_AUX, id), \ | ||
37 | SRI(AUX_DPHY_RX_CONTROL0, DP_AUX, id) | ||
38 | |||
39 | #define HPD_REG_LIST(id)\ | ||
40 | SRI(DC_HPD_CONTROL, HPD, id) | ||
41 | |||
42 | #define LE_DCN_COMMON_REG_LIST(id) \ | ||
43 | SRI(DIG_BE_CNTL, DIG, id), \ | ||
44 | SRI(DIG_BE_EN_CNTL, DIG, id), \ | ||
45 | SRI(DP_CONFIG, DP, id), \ | ||
46 | SRI(DP_DPHY_CNTL, DP, id), \ | ||
47 | SRI(DP_DPHY_PRBS_CNTL, DP, id), \ | ||
48 | SRI(DP_DPHY_SCRAM_CNTL, DP, id),\ | ||
49 | SRI(DP_DPHY_SYM0, DP, id), \ | ||
50 | SRI(DP_DPHY_SYM1, DP, id), \ | ||
51 | SRI(DP_DPHY_SYM2, DP, id), \ | ||
52 | SRI(DP_DPHY_TRAINING_PATTERN_SEL, DP, id), \ | ||
53 | SRI(DP_LINK_CNTL, DP, id), \ | ||
54 | SRI(DP_LINK_FRAMING_CNTL, DP, id), \ | ||
55 | SRI(DP_MSE_SAT0, DP, id), \ | ||
56 | SRI(DP_MSE_SAT1, DP, id), \ | ||
57 | SRI(DP_MSE_SAT2, DP, id), \ | ||
58 | SRI(DP_MSE_SAT_UPDATE, DP, id), \ | ||
59 | SRI(DP_SEC_CNTL, DP, id), \ | ||
60 | SRI(DP_VID_STREAM_CNTL, DP, id), \ | ||
61 | SRI(DP_DPHY_FAST_TRAINING, DP, id), \ | ||
62 | SRI(DP_SEC_CNTL1, DP, id), \ | ||
63 | SRI(DP_DPHY_BS_SR_SWAP_CNTL, DP, id), \ | ||
64 | SRI(DP_DPHY_INTERNAL_CTRL, DP, id), \ | ||
65 | SRI(DP_DPHY_HBR2_PATTERN_CONTROL, DP, id) | ||
66 | |||
67 | #define LE_DCN10_REG_LIST(id)\ | ||
68 | LE_DCN_COMMON_REG_LIST(id) | ||
69 | |||
70 | struct dcn10_link_enc_aux_registers { | ||
71 | uint32_t AUX_CONTROL; | ||
72 | uint32_t AUX_DPHY_RX_CONTROL0; | ||
73 | }; | ||
74 | |||
75 | struct dcn10_link_enc_hpd_registers { | ||
76 | uint32_t DC_HPD_CONTROL; | ||
77 | }; | ||
78 | |||
79 | struct dcn10_link_enc_registers { | ||
80 | uint32_t DIG_BE_CNTL; | ||
81 | uint32_t DIG_BE_EN_CNTL; | ||
82 | uint32_t DP_CONFIG; | ||
83 | uint32_t DP_DPHY_CNTL; | ||
84 | uint32_t DP_DPHY_INTERNAL_CTRL; | ||
85 | uint32_t DP_DPHY_PRBS_CNTL; | ||
86 | uint32_t DP_DPHY_SCRAM_CNTL; | ||
87 | uint32_t DP_DPHY_SYM0; | ||
88 | uint32_t DP_DPHY_SYM1; | ||
89 | uint32_t DP_DPHY_SYM2; | ||
90 | uint32_t DP_DPHY_TRAINING_PATTERN_SEL; | ||
91 | uint32_t DP_LINK_CNTL; | ||
92 | uint32_t DP_LINK_FRAMING_CNTL; | ||
93 | uint32_t DP_MSE_SAT0; | ||
94 | uint32_t DP_MSE_SAT1; | ||
95 | uint32_t DP_MSE_SAT2; | ||
96 | uint32_t DP_MSE_SAT_UPDATE; | ||
97 | uint32_t DP_SEC_CNTL; | ||
98 | uint32_t DP_VID_STREAM_CNTL; | ||
99 | uint32_t DP_DPHY_FAST_TRAINING; | ||
100 | uint32_t DP_DPHY_BS_SR_SWAP_CNTL; | ||
101 | uint32_t DP_DPHY_HBR2_PATTERN_CONTROL; | ||
102 | uint32_t DP_SEC_CNTL1; | ||
103 | }; | ||
104 | |||
105 | #define LE_SF(reg_name, field_name, post_fix)\ | ||
106 | .field_name = reg_name ## __ ## field_name ## post_fix | ||
107 | |||
108 | #define LINK_ENCODER_MASK_SH_LIST_DCN10(mask_sh)\ | ||
109 | LE_SF(DIG0_DIG_BE_EN_CNTL, DIG_ENABLE, mask_sh),\ | ||
110 | LE_SF(DIG0_DIG_BE_CNTL, DIG_HPD_SELECT, mask_sh),\ | ||
111 | LE_SF(DIG0_DIG_BE_CNTL, DIG_MODE, mask_sh),\ | ||
112 | LE_SF(DIG0_DIG_BE_CNTL, DIG_FE_SOURCE_SELECT, mask_sh),\ | ||
113 | LE_SF(DP0_DP_DPHY_CNTL, DPHY_BYPASS, mask_sh),\ | ||
114 | LE_SF(DP0_DP_DPHY_CNTL, DPHY_ATEST_SEL_LANE0, mask_sh),\ | ||
115 | LE_SF(DP0_DP_DPHY_CNTL, DPHY_ATEST_SEL_LANE1, mask_sh),\ | ||
116 | LE_SF(DP0_DP_DPHY_CNTL, DPHY_ATEST_SEL_LANE2, mask_sh),\ | ||
117 | LE_SF(DP0_DP_DPHY_CNTL, DPHY_ATEST_SEL_LANE3, mask_sh),\ | ||
118 | LE_SF(DP0_DP_DPHY_PRBS_CNTL, DPHY_PRBS_EN, mask_sh),\ | ||
119 | LE_SF(DP0_DP_DPHY_PRBS_CNTL, DPHY_PRBS_SEL, mask_sh),\ | ||
120 | LE_SF(DP0_DP_DPHY_SYM0, DPHY_SYM1, mask_sh),\ | ||
121 | LE_SF(DP0_DP_DPHY_SYM0, DPHY_SYM2, mask_sh),\ | ||
122 | LE_SF(DP0_DP_DPHY_SYM0, DPHY_SYM3, mask_sh),\ | ||
123 | LE_SF(DP0_DP_DPHY_SYM1, DPHY_SYM4, mask_sh),\ | ||
124 | LE_SF(DP0_DP_DPHY_SYM1, DPHY_SYM5, mask_sh),\ | ||
125 | LE_SF(DP0_DP_DPHY_SYM1, DPHY_SYM6, mask_sh),\ | ||
126 | LE_SF(DP0_DP_DPHY_SYM2, DPHY_SYM7, mask_sh),\ | ||
127 | LE_SF(DP0_DP_DPHY_SYM2, DPHY_SYM8, mask_sh),\ | ||
128 | LE_SF(DP0_DP_DPHY_SCRAM_CNTL, DPHY_SCRAMBLER_BS_COUNT, mask_sh),\ | ||
129 | LE_SF(DP0_DP_DPHY_SCRAM_CNTL, DPHY_SCRAMBLER_ADVANCE, mask_sh),\ | ||
130 | LE_SF(DP0_DP_DPHY_FAST_TRAINING, DPHY_RX_FAST_TRAINING_CAPABLE, mask_sh),\ | ||
131 | LE_SF(DP0_DP_DPHY_BS_SR_SWAP_CNTL, DPHY_LOAD_BS_COUNT, mask_sh),\ | ||
132 | LE_SF(DP0_DP_DPHY_TRAINING_PATTERN_SEL, DPHY_TRAINING_PATTERN_SEL, mask_sh),\ | ||
133 | LE_SF(DP0_DP_DPHY_HBR2_PATTERN_CONTROL, DP_DPHY_HBR2_PATTERN_CONTROL, mask_sh),\ | ||
134 | LE_SF(DP0_DP_LINK_CNTL, DP_LINK_TRAINING_COMPLETE, mask_sh),\ | ||
135 | LE_SF(DP0_DP_LINK_FRAMING_CNTL, DP_IDLE_BS_INTERVAL, mask_sh),\ | ||
136 | LE_SF(DP0_DP_LINK_FRAMING_CNTL, DP_VBID_DISABLE, mask_sh),\ | ||
137 | LE_SF(DP0_DP_LINK_FRAMING_CNTL, DP_VID_ENHANCED_FRAME_MODE, mask_sh),\ | ||
138 | LE_SF(DP0_DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, mask_sh),\ | ||
139 | LE_SF(DP0_DP_CONFIG, DP_UDI_LANES, mask_sh),\ | ||
140 | LE_SF(DP0_DP_SEC_CNTL1, DP_SEC_GSP0_LINE_NUM, mask_sh),\ | ||
141 | LE_SF(DP0_DP_SEC_CNTL1, DP_SEC_GSP0_PRIORITY, mask_sh),\ | ||
142 | LE_SF(DP0_DP_MSE_SAT0, DP_MSE_SAT_SRC0, mask_sh),\ | ||
143 | LE_SF(DP0_DP_MSE_SAT0, DP_MSE_SAT_SRC1, mask_sh),\ | ||
144 | LE_SF(DP0_DP_MSE_SAT0, DP_MSE_SAT_SLOT_COUNT0, mask_sh),\ | ||
145 | LE_SF(DP0_DP_MSE_SAT0, DP_MSE_SAT_SLOT_COUNT1, mask_sh),\ | ||
146 | LE_SF(DP0_DP_MSE_SAT1, DP_MSE_SAT_SRC2, mask_sh),\ | ||
147 | LE_SF(DP0_DP_MSE_SAT1, DP_MSE_SAT_SRC3, mask_sh),\ | ||
148 | LE_SF(DP0_DP_MSE_SAT1, DP_MSE_SAT_SLOT_COUNT2, mask_sh),\ | ||
149 | LE_SF(DP0_DP_MSE_SAT1, DP_MSE_SAT_SLOT_COUNT3, mask_sh),\ | ||
150 | LE_SF(DP0_DP_MSE_SAT_UPDATE, DP_MSE_SAT_UPDATE, mask_sh),\ | ||
151 | LE_SF(DP0_DP_MSE_SAT_UPDATE, DP_MSE_16_MTP_KEEPOUT, mask_sh),\ | ||
152 | LE_SF(DP_AUX0_AUX_CONTROL, AUX_HPD_SEL, mask_sh),\ | ||
153 | LE_SF(DP_AUX0_AUX_CONTROL, AUX_LS_READ_EN, mask_sh),\ | ||
154 | LE_SF(DP_AUX0_AUX_DPHY_RX_CONTROL0, AUX_RX_RECEIVE_WINDOW, mask_sh),\ | ||
155 | LE_SF(HPD0_DC_HPD_CONTROL, DC_HPD_EN, mask_sh) | ||
156 | |||
157 | #define DCN_LINK_ENCODER_REG_FIELD_LIST(type) \ | ||
158 | type DIG_ENABLE;\ | ||
159 | type DIG_HPD_SELECT;\ | ||
160 | type DIG_MODE;\ | ||
161 | type DIG_FE_SOURCE_SELECT;\ | ||
162 | type DPHY_BYPASS;\ | ||
163 | type DPHY_ATEST_SEL_LANE0;\ | ||
164 | type DPHY_ATEST_SEL_LANE1;\ | ||
165 | type DPHY_ATEST_SEL_LANE2;\ | ||
166 | type DPHY_ATEST_SEL_LANE3;\ | ||
167 | type DPHY_PRBS_EN;\ | ||
168 | type DPHY_PRBS_SEL;\ | ||
169 | type DPHY_SYM1;\ | ||
170 | type DPHY_SYM2;\ | ||
171 | type DPHY_SYM3;\ | ||
172 | type DPHY_SYM4;\ | ||
173 | type DPHY_SYM5;\ | ||
174 | type DPHY_SYM6;\ | ||
175 | type DPHY_SYM7;\ | ||
176 | type DPHY_SYM8;\ | ||
177 | type DPHY_SCRAMBLER_BS_COUNT;\ | ||
178 | type DPHY_SCRAMBLER_ADVANCE;\ | ||
179 | type DPHY_RX_FAST_TRAINING_CAPABLE;\ | ||
180 | type DPHY_LOAD_BS_COUNT;\ | ||
181 | type DPHY_TRAINING_PATTERN_SEL;\ | ||
182 | type DP_DPHY_HBR2_PATTERN_CONTROL;\ | ||
183 | type DP_LINK_TRAINING_COMPLETE;\ | ||
184 | type DP_IDLE_BS_INTERVAL;\ | ||
185 | type DP_VBID_DISABLE;\ | ||
186 | type DP_VID_ENHANCED_FRAME_MODE;\ | ||
187 | type DP_VID_STREAM_ENABLE;\ | ||
188 | type DP_UDI_LANES;\ | ||
189 | type DP_SEC_GSP0_LINE_NUM;\ | ||
190 | type DP_SEC_GSP0_PRIORITY;\ | ||
191 | type DP_MSE_SAT_SRC0;\ | ||
192 | type DP_MSE_SAT_SRC1;\ | ||
193 | type DP_MSE_SAT_SRC2;\ | ||
194 | type DP_MSE_SAT_SRC3;\ | ||
195 | type DP_MSE_SAT_SLOT_COUNT0;\ | ||
196 | type DP_MSE_SAT_SLOT_COUNT1;\ | ||
197 | type DP_MSE_SAT_SLOT_COUNT2;\ | ||
198 | type DP_MSE_SAT_SLOT_COUNT3;\ | ||
199 | type DP_MSE_SAT_UPDATE;\ | ||
200 | type DP_MSE_16_MTP_KEEPOUT;\ | ||
201 | type AUX_HPD_SEL;\ | ||
202 | type AUX_LS_READ_EN;\ | ||
203 | type AUX_RX_RECEIVE_WINDOW;\ | ||
204 | type DC_HPD_EN | ||
205 | |||
206 | struct dcn10_link_enc_shift { | ||
207 | DCN_LINK_ENCODER_REG_FIELD_LIST(uint8_t); | ||
208 | }; | ||
209 | |||
210 | struct dcn10_link_enc_mask { | ||
211 | DCN_LINK_ENCODER_REG_FIELD_LIST(uint32_t); | ||
212 | }; | ||
213 | |||
214 | struct dcn10_link_encoder { | ||
215 | struct link_encoder base; | ||
216 | const struct dcn10_link_enc_registers *link_regs; | ||
217 | const struct dcn10_link_enc_aux_registers *aux_regs; | ||
218 | const struct dcn10_link_enc_hpd_registers *hpd_regs; | ||
219 | const struct dcn10_link_enc_shift *link_shift; | ||
220 | const struct dcn10_link_enc_mask *link_mask; | ||
221 | }; | ||
222 | |||
223 | |||
224 | void dcn10_link_encoder_construct( | ||
225 | struct dcn10_link_encoder *enc10, | ||
226 | const struct encoder_init_data *init_data, | ||
227 | const struct encoder_feature_support *enc_features, | ||
228 | const struct dcn10_link_enc_registers *link_regs, | ||
229 | const struct dcn10_link_enc_aux_registers *aux_regs, | ||
230 | const struct dcn10_link_enc_hpd_registers *hpd_regs, | ||
231 | const struct dcn10_link_enc_shift *link_shift, | ||
232 | const struct dcn10_link_enc_mask *link_mask); | ||
233 | |||
234 | bool dcn10_link_encoder_validate_dvi_output( | ||
235 | const struct dcn10_link_encoder *enc10, | ||
236 | enum signal_type connector_signal, | ||
237 | enum signal_type signal, | ||
238 | const struct dc_crtc_timing *crtc_timing); | ||
239 | |||
240 | bool dcn10_link_encoder_validate_rgb_output( | ||
241 | const struct dcn10_link_encoder *enc10, | ||
242 | const struct dc_crtc_timing *crtc_timing); | ||
243 | |||
244 | bool dcn10_link_encoder_validate_dp_output( | ||
245 | const struct dcn10_link_encoder *enc10, | ||
246 | const struct dc_crtc_timing *crtc_timing); | ||
247 | |||
248 | bool dcn10_link_encoder_validate_wireless_output( | ||
249 | const struct dcn10_link_encoder *enc10, | ||
250 | const struct dc_crtc_timing *crtc_timing); | ||
251 | |||
252 | bool dcn10_link_encoder_validate_output_with_stream( | ||
253 | struct link_encoder *enc, | ||
254 | const struct dc_stream_state *stream); | ||
255 | |||
256 | /****************** HW programming ************************/ | ||
257 | |||
258 | /* initialize HW */ /* why do we initialze aux in here? */ | ||
259 | void dcn10_link_encoder_hw_init(struct link_encoder *enc); | ||
260 | |||
261 | void dcn10_link_encoder_destroy(struct link_encoder **enc); | ||
262 | |||
263 | /* program DIG_MODE in DIG_BE */ | ||
264 | /* TODO can this be combined with enable_output? */ | ||
265 | void dcn10_link_encoder_setup( | ||
266 | struct link_encoder *enc, | ||
267 | enum signal_type signal); | ||
268 | |||
269 | /* enables TMDS PHY output */ | ||
270 | /* TODO: still need depth or just pass in adjusted pixel clock? */ | ||
271 | void dcn10_link_encoder_enable_tmds_output( | ||
272 | struct link_encoder *enc, | ||
273 | enum clock_source_id clock_source, | ||
274 | enum dc_color_depth color_depth, | ||
275 | enum signal_type signal, | ||
276 | uint32_t pixel_clock); | ||
277 | |||
278 | /* enables DP PHY output */ | ||
279 | void dcn10_link_encoder_enable_dp_output( | ||
280 | struct link_encoder *enc, | ||
281 | const struct dc_link_settings *link_settings, | ||
282 | enum clock_source_id clock_source); | ||
283 | |||
284 | /* enables DP PHY output in MST mode */ | ||
285 | void dcn10_link_encoder_enable_dp_mst_output( | ||
286 | struct link_encoder *enc, | ||
287 | const struct dc_link_settings *link_settings, | ||
288 | enum clock_source_id clock_source); | ||
289 | |||
290 | /* disable PHY output */ | ||
291 | void dcn10_link_encoder_disable_output( | ||
292 | struct link_encoder *enc, | ||
293 | enum signal_type signal); | ||
294 | |||
295 | /* set DP lane settings */ | ||
296 | void dcn10_link_encoder_dp_set_lane_settings( | ||
297 | struct link_encoder *enc, | ||
298 | const struct link_training_settings *link_settings); | ||
299 | |||
300 | void dcn10_link_encoder_dp_set_phy_pattern( | ||
301 | struct link_encoder *enc, | ||
302 | const struct encoder_set_dp_phy_pattern_param *param); | ||
303 | |||
304 | /* programs DP MST VC payload allocation */ | ||
305 | void dcn10_link_encoder_update_mst_stream_allocation_table( | ||
306 | struct link_encoder *enc, | ||
307 | const struct link_mst_stream_allocation_table *table); | ||
308 | |||
309 | void dcn10_link_encoder_connect_dig_be_to_fe( | ||
310 | struct link_encoder *enc, | ||
311 | enum engine_id engine, | ||
312 | bool connect); | ||
313 | |||
314 | void dcn10_link_encoder_set_dp_phy_pattern_training_pattern( | ||
315 | struct link_encoder *enc, | ||
316 | uint32_t index); | ||
317 | |||
318 | void dcn10_link_encoder_enable_hpd(struct link_encoder *enc); | ||
319 | |||
320 | void dcn10_link_encoder_disable_hpd(struct link_encoder *enc); | ||
321 | |||
322 | void dcn10_psr_program_dp_dphy_fast_training(struct link_encoder *enc, | ||
323 | bool exit_link_training_required); | ||
324 | |||
325 | void dcn10_psr_program_secondary_packet(struct link_encoder *enc, | ||
326 | unsigned int sdp_transmit_line_num_deadline); | ||
327 | |||
328 | bool dcn10_is_dig_enabled(struct link_encoder *enc); | ||
329 | |||
330 | #endif /* __DC_LINK_ENCODER__DCN10_H__ */ | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c index c734b7fa5835..f2fbce0e3fc5 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c | |||
@@ -360,7 +360,7 @@ void optc1_program_timing( | |||
360 | 360 | ||
361 | } | 361 | } |
362 | 362 | ||
363 | static void optc1_set_blank_data_double_buffer(struct timing_generator *optc, bool enable) | 363 | void optc1_set_blank_data_double_buffer(struct timing_generator *optc, bool enable) |
364 | { | 364 | { |
365 | struct optc *optc1 = DCN10TG_FROM_TG(optc); | 365 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
366 | 366 | ||
@@ -1257,20 +1257,20 @@ void optc1_read_otg_state(struct optc *optc1, | |||
1257 | OPTC_UNDERFLOW_OCCURRED_STATUS, &s->underflow_occurred_status); | 1257 | OPTC_UNDERFLOW_OCCURRED_STATUS, &s->underflow_occurred_status); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | static void optc1_clear_optc_underflow(struct timing_generator *optc) | 1260 | void optc1_clear_optc_underflow(struct timing_generator *optc) |
1261 | { | 1261 | { |
1262 | struct optc *optc1 = DCN10TG_FROM_TG(optc); | 1262 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
1263 | 1263 | ||
1264 | REG_UPDATE(OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_CLEAR, 1); | 1264 | REG_UPDATE(OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_CLEAR, 1); |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | static void optc1_tg_init(struct timing_generator *optc) | 1267 | void optc1_tg_init(struct timing_generator *optc) |
1268 | { | 1268 | { |
1269 | optc1_set_blank_data_double_buffer(optc, true); | 1269 | optc1_set_blank_data_double_buffer(optc, true); |
1270 | optc1_clear_optc_underflow(optc); | 1270 | optc1_clear_optc_underflow(optc); |
1271 | } | 1271 | } |
1272 | 1272 | ||
1273 | static bool optc1_is_tg_enabled(struct timing_generator *optc) | 1273 | bool optc1_is_tg_enabled(struct timing_generator *optc) |
1274 | { | 1274 | { |
1275 | struct optc *optc1 = DCN10TG_FROM_TG(optc); | 1275 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
1276 | uint32_t otg_enabled = 0; | 1276 | uint32_t otg_enabled = 0; |
@@ -1281,7 +1281,7 @@ static bool optc1_is_tg_enabled(struct timing_generator *optc) | |||
1281 | 1281 | ||
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | static bool optc1_is_optc_underflow_occurred(struct timing_generator *optc) | 1284 | bool optc1_is_optc_underflow_occurred(struct timing_generator *optc) |
1285 | { | 1285 | { |
1286 | struct optc *optc1 = DCN10TG_FROM_TG(optc); | 1286 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
1287 | uint32_t underflow_occurred = 0; | 1287 | uint32_t underflow_occurred = 0; |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.h index 89e09e5327a2..c62052f46460 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.h | |||
@@ -497,4 +497,14 @@ void optc1_program_stereo(struct timing_generator *optc, | |||
497 | 497 | ||
498 | bool optc1_is_stereo_left_eye(struct timing_generator *optc); | 498 | bool optc1_is_stereo_left_eye(struct timing_generator *optc); |
499 | 499 | ||
500 | void optc1_clear_optc_underflow(struct timing_generator *optc); | ||
501 | |||
502 | void optc1_tg_init(struct timing_generator *optc); | ||
503 | |||
504 | bool optc1_is_tg_enabled(struct timing_generator *optc); | ||
505 | |||
506 | bool optc1_is_optc_underflow_occurred(struct timing_generator *optc); | ||
507 | |||
508 | void optc1_set_blank_data_double_buffer(struct timing_generator *optc, bool enable); | ||
509 | |||
500 | #endif /* __DC_TIMING_GENERATOR_DCN10_H__ */ | 510 | #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 2c0a3150bf2d..df5cb2d1d164 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | |||
@@ -38,7 +38,7 @@ | |||
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" |
41 | #include "dce/dce_link_encoder.h" | 41 | #include "dcn10/dcn10_link_encoder.h" |
42 | #include "dcn10/dcn10_stream_encoder.h" | 42 | #include "dcn10/dcn10_stream_encoder.h" |
43 | #include "dce/dce_clocks.h" | 43 | #include "dce/dce_clocks.h" |
44 | #include "dce/dce_clock_source.h" | 44 | #include "dce/dce_clock_source.h" |
@@ -214,13 +214,11 @@ static const struct dce_aduio_mask audio_mask = { | |||
214 | AUX_REG_LIST(id)\ | 214 | AUX_REG_LIST(id)\ |
215 | } | 215 | } |
216 | 216 | ||
217 | static const struct dce110_link_enc_aux_registers link_enc_aux_regs[] = { | 217 | static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = { |
218 | aux_regs(0), | 218 | aux_regs(0), |
219 | aux_regs(1), | 219 | aux_regs(1), |
220 | aux_regs(2), | 220 | aux_regs(2), |
221 | aux_regs(3), | 221 | aux_regs(3) |
222 | aux_regs(4), | ||
223 | aux_regs(5) | ||
224 | }; | 222 | }; |
225 | 223 | ||
226 | #define hpd_regs(id)\ | 224 | #define hpd_regs(id)\ |
@@ -228,13 +226,11 @@ static const struct dce110_link_enc_aux_registers link_enc_aux_regs[] = { | |||
228 | HPD_REG_LIST(id)\ | 226 | HPD_REG_LIST(id)\ |
229 | } | 227 | } |
230 | 228 | ||
231 | static const struct dce110_link_enc_hpd_registers link_enc_hpd_regs[] = { | 229 | static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = { |
232 | hpd_regs(0), | 230 | hpd_regs(0), |
233 | hpd_regs(1), | 231 | hpd_regs(1), |
234 | hpd_regs(2), | 232 | hpd_regs(2), |
235 | hpd_regs(3), | 233 | hpd_regs(3) |
236 | hpd_regs(4), | ||
237 | hpd_regs(5) | ||
238 | }; | 234 | }; |
239 | 235 | ||
240 | #define link_regs(id)\ | 236 | #define link_regs(id)\ |
@@ -243,14 +239,19 @@ static const struct dce110_link_enc_hpd_registers link_enc_hpd_regs[] = { | |||
243 | SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \ | 239 | SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \ |
244 | } | 240 | } |
245 | 241 | ||
246 | static const struct dce110_link_enc_registers link_enc_regs[] = { | 242 | static const struct dcn10_link_enc_registers link_enc_regs[] = { |
247 | link_regs(0), | 243 | link_regs(0), |
248 | link_regs(1), | 244 | link_regs(1), |
249 | link_regs(2), | 245 | link_regs(2), |
250 | link_regs(3), | 246 | link_regs(3) |
251 | link_regs(4), | 247 | }; |
252 | link_regs(5), | 248 | |
253 | link_regs(6), | 249 | static const struct dcn10_link_enc_shift le_shift = { |
250 | LINK_ENCODER_MASK_SH_LIST_DCN10(__SHIFT) | ||
251 | }; | ||
252 | |||
253 | static const struct dcn10_link_enc_mask le_mask = { | ||
254 | LINK_ENCODER_MASK_SH_LIST_DCN10(_MASK) | ||
254 | }; | 255 | }; |
255 | 256 | ||
256 | #define ipp_regs(id)\ | 257 | #define ipp_regs(id)\ |
@@ -446,6 +447,8 @@ static const struct dc_debug debug_defaults_drv = { | |||
446 | .vsr_support = true, | 447 | .vsr_support = true, |
447 | .performance_trace = false, | 448 | .performance_trace = false, |
448 | .az_endpoint_mute_only = true, | 449 | .az_endpoint_mute_only = true, |
450 | .recovery_enabled = false, /*enable this by default after testing.*/ | ||
451 | .max_downscale_src_width = 3840, | ||
449 | }; | 452 | }; |
450 | 453 | ||
451 | static const struct dc_debug debug_defaults_diags = { | 454 | static const struct dc_debug debug_defaults_diags = { |
@@ -581,20 +584,22 @@ static const struct encoder_feature_support link_enc_feature = { | |||
581 | struct link_encoder *dcn10_link_encoder_create( | 584 | struct link_encoder *dcn10_link_encoder_create( |
582 | const struct encoder_init_data *enc_init_data) | 585 | const struct encoder_init_data *enc_init_data) |
583 | { | 586 | { |
584 | struct dce110_link_encoder *enc110 = | 587 | struct dcn10_link_encoder *enc10 = |
585 | kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL); | 588 | kzalloc(sizeof(struct dcn10_link_encoder), GFP_KERNEL); |
586 | 589 | ||
587 | if (!enc110) | 590 | if (!enc10) |
588 | return NULL; | 591 | return NULL; |
589 | 592 | ||
590 | dce110_link_encoder_construct(enc110, | 593 | dcn10_link_encoder_construct(enc10, |
591 | enc_init_data, | 594 | enc_init_data, |
592 | &link_enc_feature, | 595 | &link_enc_feature, |
593 | &link_enc_regs[enc_init_data->transmitter], | 596 | &link_enc_regs[enc_init_data->transmitter], |
594 | &link_enc_aux_regs[enc_init_data->channel - 1], | 597 | &link_enc_aux_regs[enc_init_data->channel - 1], |
595 | &link_enc_hpd_regs[enc_init_data->hpd_source]); | 598 | &link_enc_hpd_regs[enc_init_data->hpd_source], |
599 | &le_shift, | ||
600 | &le_mask); | ||
596 | 601 | ||
597 | return &enc110->base; | 602 | return &enc10->base; |
598 | } | 603 | } |
599 | 604 | ||
600 | struct clock_source *dcn10_clock_source_create( | 605 | struct clock_source *dcn10_clock_source_create( |
@@ -1021,6 +1026,7 @@ static bool construct( | |||
1021 | dc->caps.max_cursor_size = 256; | 1026 | dc->caps.max_cursor_size = 256; |
1022 | dc->caps.max_slave_planes = 1; | 1027 | dc->caps.max_slave_planes = 1; |
1023 | dc->caps.is_apu = true; | 1028 | dc->caps.is_apu = true; |
1029 | dc->caps.post_blend_color_processing = false; | ||
1024 | 1030 | ||
1025 | if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV) | 1031 | if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV) |
1026 | dc->debug = debug_defaults_drv; | 1032 | dc->debug = debug_defaults_drv; |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c index befd8639ad55..653b7b2efe2e 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c | |||
@@ -603,11 +603,11 @@ void enc1_stream_encoder_set_mst_bandwidth( | |||
603 | struct fixed31_32 avg_time_slots_per_mtp) | 603 | struct fixed31_32 avg_time_slots_per_mtp) |
604 | { | 604 | { |
605 | struct dcn10_stream_encoder *enc1 = DCN10STRENC_FROM_STRENC(enc); | 605 | struct dcn10_stream_encoder *enc1 = DCN10STRENC_FROM_STRENC(enc); |
606 | uint32_t x = dal_fixed31_32_floor( | 606 | uint32_t x = dc_fixpt_floor( |
607 | avg_time_slots_per_mtp); | 607 | avg_time_slots_per_mtp); |
608 | uint32_t y = dal_fixed31_32_ceil( | 608 | uint32_t y = dc_fixpt_ceil( |
609 | dal_fixed31_32_shl( | 609 | dc_fixpt_shl( |
610 | dal_fixed31_32_sub_int( | 610 | dc_fixpt_sub_int( |
611 | avg_time_slots_per_mtp, | 611 | avg_time_slots_per_mtp, |
612 | x), | 612 | x), |
613 | 26)); | 613 | 26)); |
diff --git a/drivers/gpu/drm/amd/display/dc/dm_services.h b/drivers/gpu/drm/amd/display/dc/dm_services.h index 8eafe1af8a5e..4ff9b2bba178 100644 --- a/drivers/gpu/drm/amd/display/dc/dm_services.h +++ b/drivers/gpu/drm/amd/display/dc/dm_services.h | |||
@@ -355,10 +355,6 @@ void dm_perf_trace_timestamp(const char *func_name, unsigned int line); | |||
355 | /* | 355 | /* |
356 | * Debug and verification hooks | 356 | * Debug and verification hooks |
357 | */ | 357 | */ |
358 | bool dm_helpers_dc_conn_log( | ||
359 | struct dc_context *ctx, | ||
360 | struct log_entry *entry, | ||
361 | enum dc_log_type event); | ||
362 | 358 | ||
363 | void dm_dtn_log_begin(struct dc_context *ctx); | 359 | void dm_dtn_log_begin(struct dc_context *ctx); |
364 | void dm_dtn_log_append_v(struct dc_context *ctx, const char *msg, ...); | 360 | void dm_dtn_log_append_v(struct dc_context *ctx, const char *msg, ...); |
diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h b/drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h index b1ad3553f900..47c19f8fe7d1 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h +++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h | |||
@@ -108,4 +108,17 @@ enum output_standard { | |||
108 | dm_std_uninitialized = 0, dm_std_cvtr2, dm_std_cvt | 108 | dm_std_uninitialized = 0, dm_std_cvtr2, dm_std_cvt |
109 | }; | 109 | }; |
110 | 110 | ||
111 | enum mpc_combine_affinity { | ||
112 | dm_mpc_always_when_possible, | ||
113 | dm_mpc_reduce_voltage, | ||
114 | dm_mpc_reduce_voltage_and_clocks | ||
115 | }; | ||
116 | |||
117 | enum self_refresh_affinity { | ||
118 | dm_try_to_allow_self_refresh_and_mclk_switch, | ||
119 | dm_allow_self_refresh_and_mclk_switch, | ||
120 | dm_allow_self_refresh, | ||
121 | dm_neither_self_refresh_nor_mclk_switch | ||
122 | }; | ||
123 | |||
111 | #endif | 124 | #endif |
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 ce750edc1e5f..7fa0375939ae 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 | |||
@@ -25,39 +25,39 @@ | |||
25 | #ifndef __DISPLAY_MODE_STRUCTS_H__ | 25 | #ifndef __DISPLAY_MODE_STRUCTS_H__ |
26 | #define __DISPLAY_MODE_STRUCTS_H__ | 26 | #define __DISPLAY_MODE_STRUCTS_H__ |
27 | 27 | ||
28 | typedef struct _vcs_dpi_voltage_scaling_st voltage_scaling_st; | 28 | typedef struct _vcs_dpi_voltage_scaling_st voltage_scaling_st; |
29 | typedef struct _vcs_dpi_soc_bounding_box_st soc_bounding_box_st; | 29 | typedef struct _vcs_dpi_soc_bounding_box_st soc_bounding_box_st; |
30 | typedef struct _vcs_dpi_ip_params_st ip_params_st; | 30 | typedef struct _vcs_dpi_ip_params_st ip_params_st; |
31 | typedef struct _vcs_dpi_display_pipe_source_params_st display_pipe_source_params_st; | 31 | typedef struct _vcs_dpi_display_pipe_source_params_st display_pipe_source_params_st; |
32 | typedef struct _vcs_dpi_display_output_params_st display_output_params_st; | 32 | typedef struct _vcs_dpi_display_output_params_st display_output_params_st; |
33 | typedef struct _vcs_dpi_display_bandwidth_st display_bandwidth_st; | 33 | typedef struct _vcs_dpi_display_bandwidth_st display_bandwidth_st; |
34 | typedef struct _vcs_dpi_scaler_ratio_depth_st scaler_ratio_depth_st; | 34 | typedef struct _vcs_dpi_scaler_ratio_depth_st scaler_ratio_depth_st; |
35 | typedef struct _vcs_dpi_scaler_taps_st scaler_taps_st; | 35 | typedef struct _vcs_dpi_scaler_taps_st scaler_taps_st; |
36 | typedef struct _vcs_dpi_display_pipe_dest_params_st display_pipe_dest_params_st; | 36 | typedef struct _vcs_dpi_display_pipe_dest_params_st display_pipe_dest_params_st; |
37 | typedef struct _vcs_dpi_display_pipe_params_st display_pipe_params_st; | 37 | typedef struct _vcs_dpi_display_pipe_params_st display_pipe_params_st; |
38 | typedef struct _vcs_dpi_display_clocks_and_cfg_st display_clocks_and_cfg_st; | 38 | typedef struct _vcs_dpi_display_clocks_and_cfg_st display_clocks_and_cfg_st; |
39 | typedef struct _vcs_dpi_display_e2e_pipe_params_st display_e2e_pipe_params_st; | 39 | typedef struct _vcs_dpi_display_e2e_pipe_params_st display_e2e_pipe_params_st; |
40 | typedef struct _vcs_dpi_dchub_buffer_sizing_st dchub_buffer_sizing_st; | 40 | typedef struct _vcs_dpi_dchub_buffer_sizing_st dchub_buffer_sizing_st; |
41 | typedef struct _vcs_dpi_watermarks_perf_st watermarks_perf_st; | 41 | typedef struct _vcs_dpi_watermarks_perf_st watermarks_perf_st; |
42 | typedef struct _vcs_dpi_cstate_pstate_watermarks_st cstate_pstate_watermarks_st; | 42 | typedef struct _vcs_dpi_cstate_pstate_watermarks_st cstate_pstate_watermarks_st; |
43 | typedef struct _vcs_dpi_wm_calc_pipe_params_st wm_calc_pipe_params_st; | 43 | typedef struct _vcs_dpi_wm_calc_pipe_params_st wm_calc_pipe_params_st; |
44 | typedef struct _vcs_dpi_vratio_pre_st vratio_pre_st; | 44 | typedef struct _vcs_dpi_vratio_pre_st vratio_pre_st; |
45 | typedef struct _vcs_dpi_display_data_rq_misc_params_st display_data_rq_misc_params_st; | 45 | typedef struct _vcs_dpi_display_data_rq_misc_params_st display_data_rq_misc_params_st; |
46 | typedef struct _vcs_dpi_display_data_rq_sizing_params_st display_data_rq_sizing_params_st; | 46 | typedef struct _vcs_dpi_display_data_rq_sizing_params_st display_data_rq_sizing_params_st; |
47 | typedef struct _vcs_dpi_display_data_rq_dlg_params_st display_data_rq_dlg_params_st; | 47 | typedef struct _vcs_dpi_display_data_rq_dlg_params_st display_data_rq_dlg_params_st; |
48 | typedef struct _vcs_dpi_display_cur_rq_dlg_params_st display_cur_rq_dlg_params_st; | 48 | typedef struct _vcs_dpi_display_cur_rq_dlg_params_st display_cur_rq_dlg_params_st; |
49 | typedef struct _vcs_dpi_display_rq_dlg_params_st display_rq_dlg_params_st; | 49 | typedef struct _vcs_dpi_display_rq_dlg_params_st display_rq_dlg_params_st; |
50 | typedef struct _vcs_dpi_display_rq_sizing_params_st display_rq_sizing_params_st; | 50 | typedef struct _vcs_dpi_display_rq_sizing_params_st display_rq_sizing_params_st; |
51 | typedef struct _vcs_dpi_display_rq_misc_params_st display_rq_misc_params_st; | 51 | typedef struct _vcs_dpi_display_rq_misc_params_st display_rq_misc_params_st; |
52 | typedef struct _vcs_dpi_display_rq_params_st display_rq_params_st; | 52 | typedef struct _vcs_dpi_display_rq_params_st display_rq_params_st; |
53 | typedef struct _vcs_dpi_display_dlg_regs_st display_dlg_regs_st; | 53 | typedef struct _vcs_dpi_display_dlg_regs_st display_dlg_regs_st; |
54 | typedef struct _vcs_dpi_display_ttu_regs_st display_ttu_regs_st; | 54 | typedef struct _vcs_dpi_display_ttu_regs_st display_ttu_regs_st; |
55 | typedef struct _vcs_dpi_display_data_rq_regs_st display_data_rq_regs_st; | 55 | typedef struct _vcs_dpi_display_data_rq_regs_st display_data_rq_regs_st; |
56 | typedef struct _vcs_dpi_display_rq_regs_st display_rq_regs_st; | 56 | typedef struct _vcs_dpi_display_rq_regs_st display_rq_regs_st; |
57 | typedef struct _vcs_dpi_display_dlg_sys_params_st display_dlg_sys_params_st; | 57 | typedef struct _vcs_dpi_display_dlg_sys_params_st display_dlg_sys_params_st; |
58 | typedef struct _vcs_dpi_display_dlg_prefetch_param_st display_dlg_prefetch_param_st; | 58 | typedef struct _vcs_dpi_display_dlg_prefetch_param_st display_dlg_prefetch_param_st; |
59 | typedef struct _vcs_dpi_display_pipe_clock_st display_pipe_clock_st; | 59 | typedef struct _vcs_dpi_display_pipe_clock_st display_pipe_clock_st; |
60 | typedef struct _vcs_dpi_display_arb_params_st display_arb_params_st; | 60 | typedef struct _vcs_dpi_display_arb_params_st display_arb_params_st; |
61 | 61 | ||
62 | struct _vcs_dpi_voltage_scaling_st { | 62 | struct _vcs_dpi_voltage_scaling_st { |
63 | int state; | 63 | int state; |
@@ -72,89 +72,107 @@ struct _vcs_dpi_voltage_scaling_st { | |||
72 | double dppclk_mhz; | 72 | double dppclk_mhz; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | struct _vcs_dpi_soc_bounding_box_st { | 75 | struct _vcs_dpi_soc_bounding_box_st { |
76 | double sr_exit_time_us; | 76 | double sr_exit_time_us; |
77 | double sr_enter_plus_exit_time_us; | 77 | double sr_enter_plus_exit_time_us; |
78 | double urgent_latency_us; | 78 | double urgent_latency_us; |
79 | double writeback_latency_us; | 79 | double urgent_latency_pixel_data_only_us; |
80 | double ideal_dram_bw_after_urgent_percent; | 80 | double urgent_latency_pixel_mixed_with_vm_data_us; |
81 | unsigned int max_request_size_bytes; | 81 | double urgent_latency_vm_data_only_us; |
82 | double downspread_percent; | 82 | double writeback_latency_us; |
83 | double dram_page_open_time_ns; | 83 | double ideal_dram_bw_after_urgent_percent; |
84 | double dram_rw_turnaround_time_ns; | 84 | double pct_ideal_dram_sdp_bw_after_urgent_pixel_only; // PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelDataOnly |
85 | double dram_return_buffer_per_channel_bytes; | 85 | double pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm; |
86 | double dram_channel_width_bytes; | 86 | double pct_ideal_dram_sdp_bw_after_urgent_vm_only; |
87 | double max_avg_sdp_bw_use_normal_percent; | ||
88 | double max_avg_dram_bw_use_normal_percent; | ||
89 | unsigned int max_request_size_bytes; | ||
90 | double downspread_percent; | ||
91 | double dram_page_open_time_ns; | ||
92 | double dram_rw_turnaround_time_ns; | ||
93 | double dram_return_buffer_per_channel_bytes; | ||
94 | double dram_channel_width_bytes; | ||
87 | double fabric_datapath_to_dcn_data_return_bytes; | 95 | double fabric_datapath_to_dcn_data_return_bytes; |
88 | double dcn_downspread_percent; | 96 | double dcn_downspread_percent; |
89 | double dispclk_dppclk_vco_speed_mhz; | 97 | double dispclk_dppclk_vco_speed_mhz; |
90 | double dfs_vco_period_ps; | 98 | double dfs_vco_period_ps; |
91 | unsigned int round_trip_ping_latency_dcfclk_cycles; | 99 | unsigned int urgent_out_of_order_return_per_channel_pixel_only_bytes; |
92 | unsigned int urgent_out_of_order_return_per_channel_bytes; | 100 | unsigned int urgent_out_of_order_return_per_channel_pixel_and_vm_bytes; |
93 | unsigned int channel_interleave_bytes; | 101 | unsigned int urgent_out_of_order_return_per_channel_vm_only_bytes; |
94 | unsigned int num_banks; | 102 | unsigned int round_trip_ping_latency_dcfclk_cycles; |
95 | unsigned int num_chans; | 103 | unsigned int urgent_out_of_order_return_per_channel_bytes; |
96 | unsigned int vmm_page_size_bytes; | 104 | unsigned int channel_interleave_bytes; |
97 | double dram_clock_change_latency_us; | 105 | unsigned int num_banks; |
98 | double writeback_dram_clock_change_latency_us; | 106 | unsigned int num_chans; |
99 | unsigned int return_bus_width_bytes; | 107 | unsigned int vmm_page_size_bytes; |
100 | unsigned int voltage_override; | 108 | double dram_clock_change_latency_us; |
101 | double xfc_bus_transport_time_us; | 109 | double writeback_dram_clock_change_latency_us; |
102 | double xfc_xbuf_latency_tolerance_us; | 110 | unsigned int return_bus_width_bytes; |
111 | unsigned int voltage_override; | ||
112 | double xfc_bus_transport_time_us; | ||
113 | double xfc_xbuf_latency_tolerance_us; | ||
114 | int use_urgent_burst_bw; | ||
103 | struct _vcs_dpi_voltage_scaling_st clock_limits[7]; | 115 | struct _vcs_dpi_voltage_scaling_st clock_limits[7]; |
104 | }; | 116 | }; |
105 | 117 | ||
106 | struct _vcs_dpi_ip_params_st { | 118 | struct _vcs_dpi_ip_params_st { |
107 | unsigned int max_inter_dcn_tile_repeaters; | 119 | bool gpuvm_enable; |
108 | unsigned int num_dsc; | 120 | bool hostvm_enable; |
109 | unsigned int odm_capable; | 121 | unsigned int gpuvm_max_page_table_levels; |
110 | unsigned int rob_buffer_size_kbytes; | 122 | unsigned int hostvm_max_page_table_levels; |
111 | unsigned int det_buffer_size_kbytes; | 123 | unsigned int hostvm_cached_page_table_levels; |
112 | unsigned int dpte_buffer_size_in_pte_reqs; | 124 | unsigned int pte_group_size_bytes; |
113 | unsigned int pde_proc_buffer_size_64k_reqs; | 125 | unsigned int max_inter_dcn_tile_repeaters; |
114 | unsigned int dpp_output_buffer_pixels; | 126 | unsigned int num_dsc; |
115 | unsigned int opp_output_buffer_lines; | 127 | unsigned int odm_capable; |
116 | unsigned int pixel_chunk_size_kbytes; | 128 | unsigned int rob_buffer_size_kbytes; |
117 | unsigned char pte_enable; | 129 | unsigned int det_buffer_size_kbytes; |
118 | unsigned int pte_chunk_size_kbytes; | 130 | unsigned int dpte_buffer_size_in_pte_reqs; |
119 | unsigned int meta_chunk_size_kbytes; | 131 | unsigned int pde_proc_buffer_size_64k_reqs; |
120 | unsigned int writeback_chunk_size_kbytes; | 132 | unsigned int dpp_output_buffer_pixels; |
121 | unsigned int line_buffer_size_bits; | 133 | unsigned int opp_output_buffer_lines; |
122 | unsigned int max_line_buffer_lines; | 134 | unsigned int pixel_chunk_size_kbytes; |
123 | unsigned int writeback_luma_buffer_size_kbytes; | 135 | unsigned char pte_enable; |
124 | unsigned int writeback_chroma_buffer_size_kbytes; | 136 | unsigned int pte_chunk_size_kbytes; |
125 | unsigned int writeback_chroma_line_buffer_width_pixels; | 137 | unsigned int meta_chunk_size_kbytes; |
126 | unsigned int max_page_table_levels; | 138 | unsigned int writeback_chunk_size_kbytes; |
127 | unsigned int max_num_dpp; | 139 | unsigned int line_buffer_size_bits; |
128 | unsigned int max_num_otg; | 140 | unsigned int max_line_buffer_lines; |
129 | unsigned int cursor_chunk_size; | 141 | unsigned int writeback_luma_buffer_size_kbytes; |
130 | unsigned int cursor_buffer_size; | 142 | unsigned int writeback_chroma_buffer_size_kbytes; |
131 | unsigned int max_num_wb; | 143 | unsigned int writeback_chroma_line_buffer_width_pixels; |
132 | unsigned int max_dchub_pscl_bw_pix_per_clk; | 144 | unsigned int max_page_table_levels; |
133 | unsigned int max_pscl_lb_bw_pix_per_clk; | 145 | unsigned int max_num_dpp; |
134 | unsigned int max_lb_vscl_bw_pix_per_clk; | 146 | unsigned int max_num_otg; |
135 | unsigned int max_vscl_hscl_bw_pix_per_clk; | 147 | unsigned int cursor_chunk_size; |
136 | double max_hscl_ratio; | 148 | unsigned int cursor_buffer_size; |
137 | double max_vscl_ratio; | 149 | unsigned int max_num_wb; |
138 | unsigned int hscl_mults; | 150 | unsigned int max_dchub_pscl_bw_pix_per_clk; |
139 | unsigned int vscl_mults; | 151 | unsigned int max_pscl_lb_bw_pix_per_clk; |
140 | unsigned int max_hscl_taps; | 152 | unsigned int max_lb_vscl_bw_pix_per_clk; |
141 | unsigned int max_vscl_taps; | 153 | unsigned int max_vscl_hscl_bw_pix_per_clk; |
142 | unsigned int xfc_supported; | 154 | double max_hscl_ratio; |
143 | unsigned int xfc_fill_constant_bytes; | 155 | double max_vscl_ratio; |
144 | double dispclk_ramp_margin_percent; | 156 | unsigned int hscl_mults; |
145 | double xfc_fill_bw_overhead_percent; | 157 | unsigned int vscl_mults; |
146 | double underscan_factor; | 158 | unsigned int max_hscl_taps; |
147 | unsigned int min_vblank_lines; | 159 | unsigned int max_vscl_taps; |
148 | unsigned int dppclk_delay_subtotal; | 160 | unsigned int xfc_supported; |
149 | unsigned int dispclk_delay_subtotal; | 161 | unsigned int xfc_fill_constant_bytes; |
150 | unsigned int dcfclk_cstate_latency; | 162 | double dispclk_ramp_margin_percent; |
151 | unsigned int dppclk_delay_scl; | 163 | double xfc_fill_bw_overhead_percent; |
152 | unsigned int dppclk_delay_scl_lb_only; | 164 | double underscan_factor; |
153 | unsigned int dppclk_delay_cnvc_formatter; | 165 | unsigned int min_vblank_lines; |
154 | unsigned int dppclk_delay_cnvc_cursor; | 166 | unsigned int dppclk_delay_subtotal; |
155 | unsigned int is_line_buffer_bpp_fixed; | 167 | unsigned int dispclk_delay_subtotal; |
156 | unsigned int line_buffer_fixed_bpp; | 168 | unsigned int dcfclk_cstate_latency; |
157 | unsigned int dcc_supported; | 169 | unsigned int dppclk_delay_scl; |
170 | unsigned int dppclk_delay_scl_lb_only; | ||
171 | unsigned int dppclk_delay_cnvc_formatter; | ||
172 | unsigned int dppclk_delay_cnvc_cursor; | ||
173 | unsigned int is_line_buffer_bpp_fixed; | ||
174 | unsigned int line_buffer_fixed_bpp; | ||
175 | unsigned int dcc_supported; | ||
158 | 176 | ||
159 | unsigned int IsLineBufferBppFixed; | 177 | unsigned int IsLineBufferBppFixed; |
160 | unsigned int LineBufferFixedBpp; | 178 | unsigned int LineBufferFixedBpp; |
@@ -169,41 +187,45 @@ struct _vcs_dpi_display_xfc_params_st { | |||
169 | int xfc_slv_chunk_size_bytes; | 187 | int xfc_slv_chunk_size_bytes; |
170 | }; | 188 | }; |
171 | 189 | ||
172 | struct _vcs_dpi_display_pipe_source_params_st { | 190 | struct _vcs_dpi_display_pipe_source_params_st { |
173 | int source_format; | 191 | int source_format; |
174 | unsigned char dcc; | 192 | unsigned char dcc; |
175 | unsigned int dcc_override; | 193 | unsigned int dcc_override; |
176 | unsigned int dcc_rate; | 194 | unsigned int dcc_rate; |
177 | unsigned char dcc_use_global; | 195 | unsigned char dcc_use_global; |
178 | unsigned char vm; | 196 | unsigned char vm; |
179 | unsigned char vm_levels_force_en; | 197 | bool gpuvm; // gpuvm enabled |
180 | unsigned int vm_levels_force; | 198 | bool hostvm; // hostvm enabled |
181 | int source_scan; | 199 | bool gpuvm_levels_force_en; |
182 | int sw_mode; | 200 | unsigned int gpuvm_levels_force; |
183 | int macro_tile_size; | 201 | bool hostvm_levels_force_en; |
184 | unsigned char is_display_sw; | 202 | unsigned int hostvm_levels_force; |
185 | unsigned int viewport_width; | 203 | int source_scan; |
186 | unsigned int viewport_height; | 204 | int sw_mode; |
187 | unsigned int viewport_y_y; | 205 | int macro_tile_size; |
188 | unsigned int viewport_y_c; | 206 | unsigned char is_display_sw; |
189 | unsigned int viewport_width_c; | 207 | unsigned int viewport_width; |
190 | unsigned int viewport_height_c; | 208 | unsigned int viewport_height; |
191 | unsigned int data_pitch; | 209 | unsigned int viewport_y_y; |
192 | unsigned int data_pitch_c; | 210 | unsigned int viewport_y_c; |
193 | unsigned int meta_pitch; | 211 | unsigned int viewport_width_c; |
194 | unsigned int meta_pitch_c; | 212 | unsigned int viewport_height_c; |
195 | unsigned int cur0_src_width; | 213 | unsigned int data_pitch; |
196 | int cur0_bpp; | 214 | unsigned int data_pitch_c; |
197 | unsigned int cur1_src_width; | 215 | unsigned int meta_pitch; |
198 | int cur1_bpp; | 216 | unsigned int meta_pitch_c; |
199 | int num_cursors; | 217 | unsigned int cur0_src_width; |
200 | unsigned char is_hsplit; | 218 | int cur0_bpp; |
201 | unsigned char dynamic_metadata_enable; | 219 | unsigned int cur1_src_width; |
202 | unsigned int dynamic_metadata_lines_before_active; | 220 | int cur1_bpp; |
203 | unsigned int dynamic_metadata_xmit_bytes; | 221 | int num_cursors; |
204 | unsigned int hsplit_grp; | 222 | unsigned char is_hsplit; |
205 | unsigned char xfc_enable; | 223 | unsigned char dynamic_metadata_enable; |
206 | unsigned char xfc_slave; | 224 | unsigned int dynamic_metadata_lines_before_active; |
225 | unsigned int dynamic_metadata_xmit_bytes; | ||
226 | unsigned int hsplit_grp; | ||
227 | unsigned char xfc_enable; | ||
228 | unsigned char xfc_slave; | ||
207 | struct _vcs_dpi_display_xfc_params_st xfc_params; | 229 | struct _vcs_dpi_display_xfc_params_st xfc_params; |
208 | }; | 230 | }; |
209 | struct writeback_st { | 231 | struct writeback_st { |
@@ -219,335 +241,335 @@ struct writeback_st { | |||
219 | double wb_vratio; | 241 | double wb_vratio; |
220 | }; | 242 | }; |
221 | 243 | ||
222 | struct _vcs_dpi_display_output_params_st { | 244 | struct _vcs_dpi_display_output_params_st { |
223 | int dp_lanes; | 245 | int dp_lanes; |
224 | int output_bpp; | 246 | int output_bpp; |
225 | int dsc_enable; | 247 | int dsc_enable; |
226 | int wb_enable; | 248 | int wb_enable; |
227 | int num_active_wb; | 249 | int num_active_wb; |
228 | int opp_input_bpc; | 250 | int output_bpc; |
229 | int output_type; | 251 | int output_type; |
230 | int output_format; | 252 | int output_format; |
231 | int output_standard; | 253 | int output_standard; |
232 | int dsc_slices; | 254 | int dsc_slices; |
233 | struct writeback_st wb; | 255 | struct writeback_st wb; |
234 | }; | 256 | }; |
235 | 257 | ||
236 | struct _vcs_dpi_display_bandwidth_st { | 258 | struct _vcs_dpi_display_bandwidth_st { |
237 | double total_bw_consumed_gbps; | 259 | double total_bw_consumed_gbps; |
238 | double guaranteed_urgent_return_bw_gbps; | 260 | double guaranteed_urgent_return_bw_gbps; |
239 | }; | 261 | }; |
240 | 262 | ||
241 | struct _vcs_dpi_scaler_ratio_depth_st { | 263 | struct _vcs_dpi_scaler_ratio_depth_st { |
242 | double hscl_ratio; | 264 | double hscl_ratio; |
243 | double vscl_ratio; | 265 | double vscl_ratio; |
244 | double hscl_ratio_c; | 266 | double hscl_ratio_c; |
245 | double vscl_ratio_c; | 267 | double vscl_ratio_c; |
246 | double vinit; | 268 | double vinit; |
247 | double vinit_c; | 269 | double vinit_c; |
248 | double vinit_bot; | 270 | double vinit_bot; |
249 | double vinit_bot_c; | 271 | double vinit_bot_c; |
250 | int lb_depth; | 272 | int lb_depth; |
251 | int scl_enable; | 273 | int scl_enable; |
252 | }; | 274 | }; |
253 | 275 | ||
254 | struct _vcs_dpi_scaler_taps_st { | 276 | struct _vcs_dpi_scaler_taps_st { |
255 | unsigned int htaps; | 277 | unsigned int htaps; |
256 | unsigned int vtaps; | 278 | unsigned int vtaps; |
257 | unsigned int htaps_c; | 279 | unsigned int htaps_c; |
258 | unsigned int vtaps_c; | 280 | unsigned int vtaps_c; |
259 | }; | 281 | }; |
260 | 282 | ||
261 | struct _vcs_dpi_display_pipe_dest_params_st { | 283 | struct _vcs_dpi_display_pipe_dest_params_st { |
262 | unsigned int recout_width; | 284 | unsigned int recout_width; |
263 | unsigned int recout_height; | 285 | unsigned int recout_height; |
264 | unsigned int full_recout_width; | 286 | unsigned int full_recout_width; |
265 | unsigned int full_recout_height; | 287 | unsigned int full_recout_height; |
266 | unsigned int hblank_start; | 288 | unsigned int hblank_start; |
267 | unsigned int hblank_end; | 289 | unsigned int hblank_end; |
268 | unsigned int vblank_start; | 290 | unsigned int vblank_start; |
269 | unsigned int vblank_end; | 291 | unsigned int vblank_end; |
270 | unsigned int htotal; | 292 | unsigned int htotal; |
271 | unsigned int vtotal; | 293 | unsigned int vtotal; |
272 | unsigned int vactive; | 294 | unsigned int vactive; |
273 | unsigned int hactive; | 295 | unsigned int hactive; |
274 | unsigned int vstartup_start; | 296 | unsigned int vstartup_start; |
275 | unsigned int vupdate_offset; | 297 | unsigned int vupdate_offset; |
276 | unsigned int vupdate_width; | 298 | unsigned int vupdate_width; |
277 | unsigned int vready_offset; | 299 | unsigned int vready_offset; |
278 | unsigned char interlaced; | 300 | unsigned char interlaced; |
279 | unsigned char underscan; | 301 | unsigned char underscan; |
280 | double pixel_rate_mhz; | 302 | double pixel_rate_mhz; |
281 | unsigned char synchronized_vblank_all_planes; | 303 | unsigned char synchronized_vblank_all_planes; |
282 | unsigned char otg_inst; | 304 | unsigned char otg_inst; |
283 | unsigned char odm_split_cnt; | 305 | unsigned char odm_split_cnt; |
284 | unsigned char odm_combine; | 306 | unsigned char odm_combine; |
285 | }; | 307 | }; |
286 | 308 | ||
287 | struct _vcs_dpi_display_pipe_params_st { | 309 | struct _vcs_dpi_display_pipe_params_st { |
288 | display_pipe_source_params_st src; | 310 | display_pipe_source_params_st src; |
289 | display_pipe_dest_params_st dest; | 311 | display_pipe_dest_params_st dest; |
290 | scaler_ratio_depth_st scale_ratio_depth; | 312 | scaler_ratio_depth_st scale_ratio_depth; |
291 | scaler_taps_st scale_taps; | 313 | scaler_taps_st scale_taps; |
292 | }; | 314 | }; |
293 | 315 | ||
294 | struct _vcs_dpi_display_clocks_and_cfg_st { | 316 | struct _vcs_dpi_display_clocks_and_cfg_st { |
295 | int voltage; | 317 | int voltage; |
296 | double dppclk_mhz; | 318 | double dppclk_mhz; |
297 | double refclk_mhz; | 319 | double refclk_mhz; |
298 | double dispclk_mhz; | 320 | double dispclk_mhz; |
299 | double dcfclk_mhz; | 321 | double dcfclk_mhz; |
300 | double socclk_mhz; | 322 | double socclk_mhz; |
301 | }; | 323 | }; |
302 | 324 | ||
303 | struct _vcs_dpi_display_e2e_pipe_params_st { | 325 | struct _vcs_dpi_display_e2e_pipe_params_st { |
304 | display_pipe_params_st pipe; | 326 | display_pipe_params_st pipe; |
305 | display_output_params_st dout; | 327 | display_output_params_st dout; |
306 | display_clocks_and_cfg_st clks_cfg; | 328 | display_clocks_and_cfg_st clks_cfg; |
307 | }; | 329 | }; |
308 | 330 | ||
309 | struct _vcs_dpi_dchub_buffer_sizing_st { | 331 | struct _vcs_dpi_dchub_buffer_sizing_st { |
310 | unsigned int swath_width_y; | 332 | unsigned int swath_width_y; |
311 | unsigned int swath_height_y; | 333 | unsigned int swath_height_y; |
312 | unsigned int swath_height_c; | 334 | unsigned int swath_height_c; |
313 | unsigned int detail_buffer_size_y; | 335 | unsigned int detail_buffer_size_y; |
314 | }; | 336 | }; |
315 | 337 | ||
316 | struct _vcs_dpi_watermarks_perf_st { | 338 | struct _vcs_dpi_watermarks_perf_st { |
317 | double stutter_eff_in_active_region_percent; | 339 | double stutter_eff_in_active_region_percent; |
318 | double urgent_latency_supported_us; | 340 | double urgent_latency_supported_us; |
319 | double non_urgent_latency_supported_us; | 341 | double non_urgent_latency_supported_us; |
320 | double dram_clock_change_margin_us; | 342 | double dram_clock_change_margin_us; |
321 | double dram_access_eff_percent; | 343 | double dram_access_eff_percent; |
322 | }; | 344 | }; |
323 | 345 | ||
324 | struct _vcs_dpi_cstate_pstate_watermarks_st { | 346 | struct _vcs_dpi_cstate_pstate_watermarks_st { |
325 | double cstate_exit_us; | 347 | double cstate_exit_us; |
326 | double cstate_enter_plus_exit_us; | 348 | double cstate_enter_plus_exit_us; |
327 | double pstate_change_us; | 349 | double pstate_change_us; |
328 | }; | 350 | }; |
329 | 351 | ||
330 | struct _vcs_dpi_wm_calc_pipe_params_st { | 352 | struct _vcs_dpi_wm_calc_pipe_params_st { |
331 | unsigned int num_dpp; | 353 | unsigned int num_dpp; |
332 | int voltage; | 354 | int voltage; |
333 | int output_type; | 355 | int output_type; |
334 | double dcfclk_mhz; | 356 | double dcfclk_mhz; |
335 | double socclk_mhz; | 357 | double socclk_mhz; |
336 | double dppclk_mhz; | 358 | double dppclk_mhz; |
337 | double pixclk_mhz; | 359 | double pixclk_mhz; |
338 | unsigned char interlace_en; | 360 | unsigned char interlace_en; |
339 | unsigned char pte_enable; | 361 | unsigned char pte_enable; |
340 | unsigned char dcc_enable; | 362 | unsigned char dcc_enable; |
341 | double dcc_rate; | 363 | double dcc_rate; |
342 | double bytes_per_pixel_c; | 364 | double bytes_per_pixel_c; |
343 | double bytes_per_pixel_y; | 365 | double bytes_per_pixel_y; |
344 | unsigned int swath_width_y; | 366 | unsigned int swath_width_y; |
345 | unsigned int swath_height_y; | 367 | unsigned int swath_height_y; |
346 | unsigned int swath_height_c; | 368 | unsigned int swath_height_c; |
347 | unsigned int det_buffer_size_y; | 369 | unsigned int det_buffer_size_y; |
348 | double h_ratio; | 370 | double h_ratio; |
349 | double v_ratio; | 371 | double v_ratio; |
350 | unsigned int h_taps; | 372 | unsigned int h_taps; |
351 | unsigned int h_total; | 373 | unsigned int h_total; |
352 | unsigned int v_total; | 374 | unsigned int v_total; |
353 | unsigned int v_active; | 375 | unsigned int v_active; |
354 | unsigned int e2e_index; | 376 | unsigned int e2e_index; |
355 | double display_pipe_line_delivery_time; | 377 | double display_pipe_line_delivery_time; |
356 | double read_bw; | 378 | double read_bw; |
357 | unsigned int lines_in_det_y; | 379 | unsigned int lines_in_det_y; |
358 | unsigned int lines_in_det_y_rounded_down_to_swath; | 380 | unsigned int lines_in_det_y_rounded_down_to_swath; |
359 | double full_det_buffering_time; | 381 | double full_det_buffering_time; |
360 | double dcfclk_deepsleep_mhz_per_plane; | 382 | double dcfclk_deepsleep_mhz_per_plane; |
361 | }; | 383 | }; |
362 | 384 | ||
363 | struct _vcs_dpi_vratio_pre_st { | 385 | struct _vcs_dpi_vratio_pre_st { |
364 | double vratio_pre_l; | 386 | double vratio_pre_l; |
365 | double vratio_pre_c; | 387 | double vratio_pre_c; |
366 | }; | 388 | }; |
367 | 389 | ||
368 | struct _vcs_dpi_display_data_rq_misc_params_st { | 390 | struct _vcs_dpi_display_data_rq_misc_params_st { |
369 | unsigned int full_swath_bytes; | 391 | unsigned int full_swath_bytes; |
370 | unsigned int stored_swath_bytes; | 392 | unsigned int stored_swath_bytes; |
371 | unsigned int blk256_height; | 393 | unsigned int blk256_height; |
372 | unsigned int blk256_width; | 394 | unsigned int blk256_width; |
373 | unsigned int req_height; | 395 | unsigned int req_height; |
374 | unsigned int req_width; | 396 | unsigned int req_width; |
375 | }; | 397 | }; |
376 | 398 | ||
377 | struct _vcs_dpi_display_data_rq_sizing_params_st { | 399 | struct _vcs_dpi_display_data_rq_sizing_params_st { |
378 | unsigned int chunk_bytes; | 400 | unsigned int chunk_bytes; |
379 | unsigned int min_chunk_bytes; | 401 | unsigned int min_chunk_bytes; |
380 | unsigned int meta_chunk_bytes; | 402 | unsigned int meta_chunk_bytes; |
381 | unsigned int min_meta_chunk_bytes; | 403 | unsigned int min_meta_chunk_bytes; |
382 | unsigned int mpte_group_bytes; | 404 | unsigned int mpte_group_bytes; |
383 | unsigned int dpte_group_bytes; | 405 | unsigned int dpte_group_bytes; |
384 | }; | 406 | }; |
385 | 407 | ||
386 | struct _vcs_dpi_display_data_rq_dlg_params_st { | 408 | struct _vcs_dpi_display_data_rq_dlg_params_st { |
387 | unsigned int swath_width_ub; | 409 | unsigned int swath_width_ub; |
388 | unsigned int swath_height; | 410 | unsigned int swath_height; |
389 | unsigned int req_per_swath_ub; | 411 | unsigned int req_per_swath_ub; |
390 | unsigned int meta_pte_bytes_per_frame_ub; | 412 | unsigned int meta_pte_bytes_per_frame_ub; |
391 | unsigned int dpte_req_per_row_ub; | 413 | unsigned int dpte_req_per_row_ub; |
392 | unsigned int dpte_groups_per_row_ub; | 414 | unsigned int dpte_groups_per_row_ub; |
393 | unsigned int dpte_row_height; | 415 | unsigned int dpte_row_height; |
394 | unsigned int dpte_bytes_per_row_ub; | 416 | unsigned int dpte_bytes_per_row_ub; |
395 | unsigned int meta_chunks_per_row_ub; | 417 | unsigned int meta_chunks_per_row_ub; |
396 | unsigned int meta_req_per_row_ub; | 418 | unsigned int meta_req_per_row_ub; |
397 | unsigned int meta_row_height; | 419 | unsigned int meta_row_height; |
398 | unsigned int meta_bytes_per_row_ub; | 420 | unsigned int meta_bytes_per_row_ub; |
399 | }; | 421 | }; |
400 | 422 | ||
401 | struct _vcs_dpi_display_cur_rq_dlg_params_st { | 423 | struct _vcs_dpi_display_cur_rq_dlg_params_st { |
402 | unsigned char enable; | 424 | unsigned char enable; |
403 | unsigned int swath_height; | 425 | unsigned int swath_height; |
404 | unsigned int req_per_line; | 426 | unsigned int req_per_line; |
405 | }; | 427 | }; |
406 | 428 | ||
407 | struct _vcs_dpi_display_rq_dlg_params_st { | 429 | struct _vcs_dpi_display_rq_dlg_params_st { |
408 | display_data_rq_dlg_params_st rq_l; | 430 | display_data_rq_dlg_params_st rq_l; |
409 | display_data_rq_dlg_params_st rq_c; | 431 | display_data_rq_dlg_params_st rq_c; |
410 | display_cur_rq_dlg_params_st rq_cur0; | 432 | display_cur_rq_dlg_params_st rq_cur0; |
411 | }; | 433 | }; |
412 | 434 | ||
413 | struct _vcs_dpi_display_rq_sizing_params_st { | 435 | struct _vcs_dpi_display_rq_sizing_params_st { |
414 | display_data_rq_sizing_params_st rq_l; | 436 | display_data_rq_sizing_params_st rq_l; |
415 | display_data_rq_sizing_params_st rq_c; | 437 | display_data_rq_sizing_params_st rq_c; |
416 | }; | 438 | }; |
417 | 439 | ||
418 | struct _vcs_dpi_display_rq_misc_params_st { | 440 | struct _vcs_dpi_display_rq_misc_params_st { |
419 | display_data_rq_misc_params_st rq_l; | 441 | display_data_rq_misc_params_st rq_l; |
420 | display_data_rq_misc_params_st rq_c; | 442 | display_data_rq_misc_params_st rq_c; |
421 | }; | 443 | }; |
422 | 444 | ||
423 | struct _vcs_dpi_display_rq_params_st { | 445 | struct _vcs_dpi_display_rq_params_st { |
424 | unsigned char yuv420; | 446 | unsigned char yuv420; |
425 | unsigned char yuv420_10bpc; | 447 | unsigned char yuv420_10bpc; |
426 | display_rq_misc_params_st misc; | 448 | display_rq_misc_params_st misc; |
427 | display_rq_sizing_params_st sizing; | 449 | display_rq_sizing_params_st sizing; |
428 | display_rq_dlg_params_st dlg; | 450 | display_rq_dlg_params_st dlg; |
429 | }; | 451 | }; |
430 | 452 | ||
431 | struct _vcs_dpi_display_dlg_regs_st { | 453 | struct _vcs_dpi_display_dlg_regs_st { |
432 | unsigned int refcyc_h_blank_end; | 454 | unsigned int refcyc_h_blank_end; |
433 | unsigned int dlg_vblank_end; | 455 | unsigned int dlg_vblank_end; |
434 | unsigned int min_dst_y_next_start; | 456 | unsigned int min_dst_y_next_start; |
435 | unsigned int refcyc_per_htotal; | 457 | unsigned int refcyc_per_htotal; |
436 | unsigned int refcyc_x_after_scaler; | 458 | unsigned int refcyc_x_after_scaler; |
437 | unsigned int dst_y_after_scaler; | 459 | unsigned int dst_y_after_scaler; |
438 | unsigned int dst_y_prefetch; | 460 | unsigned int dst_y_prefetch; |
439 | unsigned int dst_y_per_vm_vblank; | 461 | unsigned int dst_y_per_vm_vblank; |
440 | unsigned int dst_y_per_row_vblank; | 462 | unsigned int dst_y_per_row_vblank; |
441 | unsigned int dst_y_per_vm_flip; | 463 | unsigned int dst_y_per_vm_flip; |
442 | unsigned int dst_y_per_row_flip; | 464 | unsigned int dst_y_per_row_flip; |
443 | unsigned int ref_freq_to_pix_freq; | 465 | unsigned int ref_freq_to_pix_freq; |
444 | unsigned int vratio_prefetch; | 466 | unsigned int vratio_prefetch; |
445 | unsigned int vratio_prefetch_c; | 467 | unsigned int vratio_prefetch_c; |
446 | unsigned int refcyc_per_pte_group_vblank_l; | 468 | unsigned int refcyc_per_pte_group_vblank_l; |
447 | unsigned int refcyc_per_pte_group_vblank_c; | 469 | unsigned int refcyc_per_pte_group_vblank_c; |
448 | unsigned int refcyc_per_meta_chunk_vblank_l; | 470 | unsigned int refcyc_per_meta_chunk_vblank_l; |
449 | unsigned int refcyc_per_meta_chunk_vblank_c; | 471 | unsigned int refcyc_per_meta_chunk_vblank_c; |
450 | unsigned int refcyc_per_pte_group_flip_l; | 472 | unsigned int refcyc_per_pte_group_flip_l; |
451 | unsigned int refcyc_per_pte_group_flip_c; | 473 | unsigned int refcyc_per_pte_group_flip_c; |
452 | unsigned int refcyc_per_meta_chunk_flip_l; | 474 | unsigned int refcyc_per_meta_chunk_flip_l; |
453 | unsigned int refcyc_per_meta_chunk_flip_c; | 475 | unsigned int refcyc_per_meta_chunk_flip_c; |
454 | unsigned int dst_y_per_pte_row_nom_l; | 476 | unsigned int dst_y_per_pte_row_nom_l; |
455 | unsigned int dst_y_per_pte_row_nom_c; | 477 | unsigned int dst_y_per_pte_row_nom_c; |
456 | unsigned int refcyc_per_pte_group_nom_l; | 478 | unsigned int refcyc_per_pte_group_nom_l; |
457 | unsigned int refcyc_per_pte_group_nom_c; | 479 | unsigned int refcyc_per_pte_group_nom_c; |
458 | unsigned int dst_y_per_meta_row_nom_l; | 480 | unsigned int dst_y_per_meta_row_nom_l; |
459 | unsigned int dst_y_per_meta_row_nom_c; | 481 | unsigned int dst_y_per_meta_row_nom_c; |
460 | unsigned int refcyc_per_meta_chunk_nom_l; | 482 | unsigned int refcyc_per_meta_chunk_nom_l; |
461 | unsigned int refcyc_per_meta_chunk_nom_c; | 483 | unsigned int refcyc_per_meta_chunk_nom_c; |
462 | unsigned int refcyc_per_line_delivery_pre_l; | 484 | unsigned int refcyc_per_line_delivery_pre_l; |
463 | unsigned int refcyc_per_line_delivery_pre_c; | 485 | unsigned int refcyc_per_line_delivery_pre_c; |
464 | unsigned int refcyc_per_line_delivery_l; | 486 | unsigned int refcyc_per_line_delivery_l; |
465 | unsigned int refcyc_per_line_delivery_c; | 487 | unsigned int refcyc_per_line_delivery_c; |
466 | unsigned int chunk_hdl_adjust_cur0; | 488 | unsigned int chunk_hdl_adjust_cur0; |
467 | unsigned int chunk_hdl_adjust_cur1; | 489 | unsigned int chunk_hdl_adjust_cur1; |
468 | unsigned int vready_after_vcount0; | 490 | unsigned int vready_after_vcount0; |
469 | unsigned int dst_y_offset_cur0; | 491 | unsigned int dst_y_offset_cur0; |
470 | unsigned int dst_y_offset_cur1; | 492 | unsigned int dst_y_offset_cur1; |
471 | unsigned int xfc_reg_transfer_delay; | 493 | unsigned int xfc_reg_transfer_delay; |
472 | unsigned int xfc_reg_precharge_delay; | 494 | unsigned int xfc_reg_precharge_delay; |
473 | unsigned int xfc_reg_remote_surface_flip_latency; | 495 | unsigned int xfc_reg_remote_surface_flip_latency; |
474 | unsigned int xfc_reg_prefetch_margin; | 496 | unsigned int xfc_reg_prefetch_margin; |
475 | unsigned int dst_y_delta_drq_limit; | 497 | unsigned int dst_y_delta_drq_limit; |
476 | }; | 498 | }; |
477 | 499 | ||
478 | struct _vcs_dpi_display_ttu_regs_st { | 500 | struct _vcs_dpi_display_ttu_regs_st { |
479 | unsigned int qos_level_low_wm; | 501 | unsigned int qos_level_low_wm; |
480 | unsigned int qos_level_high_wm; | 502 | unsigned int qos_level_high_wm; |
481 | unsigned int min_ttu_vblank; | 503 | unsigned int min_ttu_vblank; |
482 | unsigned int qos_level_flip; | 504 | unsigned int qos_level_flip; |
483 | unsigned int refcyc_per_req_delivery_l; | 505 | unsigned int refcyc_per_req_delivery_l; |
484 | unsigned int refcyc_per_req_delivery_c; | 506 | unsigned int refcyc_per_req_delivery_c; |
485 | unsigned int refcyc_per_req_delivery_cur0; | 507 | unsigned int refcyc_per_req_delivery_cur0; |
486 | unsigned int refcyc_per_req_delivery_cur1; | 508 | unsigned int refcyc_per_req_delivery_cur1; |
487 | unsigned int refcyc_per_req_delivery_pre_l; | 509 | unsigned int refcyc_per_req_delivery_pre_l; |
488 | unsigned int refcyc_per_req_delivery_pre_c; | 510 | unsigned int refcyc_per_req_delivery_pre_c; |
489 | unsigned int refcyc_per_req_delivery_pre_cur0; | 511 | unsigned int refcyc_per_req_delivery_pre_cur0; |
490 | unsigned int refcyc_per_req_delivery_pre_cur1; | 512 | unsigned int refcyc_per_req_delivery_pre_cur1; |
491 | unsigned int qos_level_fixed_l; | 513 | unsigned int qos_level_fixed_l; |
492 | unsigned int qos_level_fixed_c; | 514 | unsigned int qos_level_fixed_c; |
493 | unsigned int qos_level_fixed_cur0; | 515 | unsigned int qos_level_fixed_cur0; |
494 | unsigned int qos_level_fixed_cur1; | 516 | unsigned int qos_level_fixed_cur1; |
495 | unsigned int qos_ramp_disable_l; | 517 | unsigned int qos_ramp_disable_l; |
496 | unsigned int qos_ramp_disable_c; | 518 | unsigned int qos_ramp_disable_c; |
497 | unsigned int qos_ramp_disable_cur0; | 519 | unsigned int qos_ramp_disable_cur0; |
498 | unsigned int qos_ramp_disable_cur1; | 520 | unsigned int qos_ramp_disable_cur1; |
499 | }; | 521 | }; |
500 | 522 | ||
501 | struct _vcs_dpi_display_data_rq_regs_st { | 523 | struct _vcs_dpi_display_data_rq_regs_st { |
502 | unsigned int chunk_size; | 524 | unsigned int chunk_size; |
503 | unsigned int min_chunk_size; | 525 | unsigned int min_chunk_size; |
504 | unsigned int meta_chunk_size; | 526 | unsigned int meta_chunk_size; |
505 | unsigned int min_meta_chunk_size; | 527 | unsigned int min_meta_chunk_size; |
506 | unsigned int dpte_group_size; | 528 | unsigned int dpte_group_size; |
507 | unsigned int mpte_group_size; | 529 | unsigned int mpte_group_size; |
508 | unsigned int swath_height; | 530 | unsigned int swath_height; |
509 | unsigned int pte_row_height_linear; | 531 | unsigned int pte_row_height_linear; |
510 | }; | 532 | }; |
511 | 533 | ||
512 | struct _vcs_dpi_display_rq_regs_st { | 534 | struct _vcs_dpi_display_rq_regs_st { |
513 | display_data_rq_regs_st rq_regs_l; | 535 | display_data_rq_regs_st rq_regs_l; |
514 | display_data_rq_regs_st rq_regs_c; | 536 | display_data_rq_regs_st rq_regs_c; |
515 | unsigned int drq_expansion_mode; | 537 | unsigned int drq_expansion_mode; |
516 | unsigned int prq_expansion_mode; | 538 | unsigned int prq_expansion_mode; |
517 | unsigned int mrq_expansion_mode; | 539 | unsigned int mrq_expansion_mode; |
518 | unsigned int crq_expansion_mode; | 540 | unsigned int crq_expansion_mode; |
519 | unsigned int plane1_base_address; | 541 | unsigned int plane1_base_address; |
520 | }; | 542 | }; |
521 | 543 | ||
522 | struct _vcs_dpi_display_dlg_sys_params_st { | 544 | struct _vcs_dpi_display_dlg_sys_params_st { |
523 | double t_mclk_wm_us; | 545 | double t_mclk_wm_us; |
524 | double t_urg_wm_us; | 546 | double t_urg_wm_us; |
525 | double t_sr_wm_us; | 547 | double t_sr_wm_us; |
526 | double t_extra_us; | 548 | double t_extra_us; |
527 | double mem_trip_us; | 549 | double mem_trip_us; |
528 | double t_srx_delay_us; | 550 | double t_srx_delay_us; |
529 | double deepsleep_dcfclk_mhz; | 551 | double deepsleep_dcfclk_mhz; |
530 | double total_flip_bw; | 552 | double total_flip_bw; |
531 | unsigned int total_flip_bytes; | 553 | unsigned int total_flip_bytes; |
532 | }; | 554 | }; |
533 | 555 | ||
534 | struct _vcs_dpi_display_dlg_prefetch_param_st { | 556 | struct _vcs_dpi_display_dlg_prefetch_param_st { |
535 | double prefetch_bw; | 557 | double prefetch_bw; |
536 | unsigned int flip_bytes; | 558 | unsigned int flip_bytes; |
537 | }; | 559 | }; |
538 | 560 | ||
539 | struct _vcs_dpi_display_pipe_clock_st { | 561 | struct _vcs_dpi_display_pipe_clock_st { |
540 | double dcfclk_mhz; | 562 | double dcfclk_mhz; |
541 | double dispclk_mhz; | 563 | double dispclk_mhz; |
542 | double socclk_mhz; | 564 | double socclk_mhz; |
543 | double dscclk_mhz[6]; | 565 | double dscclk_mhz[6]; |
544 | double dppclk_mhz[6]; | 566 | double dppclk_mhz[6]; |
545 | }; | 567 | }; |
546 | 568 | ||
547 | struct _vcs_dpi_display_arb_params_st { | 569 | struct _vcs_dpi_display_arb_params_st { |
548 | int max_req_outstanding; | 570 | int max_req_outstanding; |
549 | int min_req_outstanding; | 571 | int min_req_outstanding; |
550 | int sat_level_us; | 572 | int sat_level_us; |
551 | }; | 573 | }; |
552 | 574 | ||
553 | #endif /*__DISPLAY_MODE_STRUCTS_H__*/ | 575 | #endif /*__DISPLAY_MODE_STRUCTS_H__*/ |
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h index f9cf08357989..e8ce08567cd8 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h +++ b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h | |||
@@ -35,6 +35,16 @@ static inline double dml_min(double a, double b) | |||
35 | return (double) dcn_bw_min2(a, b); | 35 | return (double) dcn_bw_min2(a, b); |
36 | } | 36 | } |
37 | 37 | ||
38 | static inline double dml_min3(double a, double b, double c) | ||
39 | { | ||
40 | return dml_min(dml_min(a, b), c); | ||
41 | } | ||
42 | |||
43 | static inline double dml_min4(double a, double b, double c, double d) | ||
44 | { | ||
45 | return dml_min(dml_min(a, b), dml_min(c, d)); | ||
46 | } | ||
47 | |||
38 | static inline double dml_max(double a, double b) | 48 | static inline double dml_max(double a, double b) |
39 | { | 49 | { |
40 | return (double) dcn_bw_max2(a, b); | 50 | return (double) dcn_bw_max2(a, b); |
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c index 61fe484da1a0..0caee3523017 100644 --- a/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c +++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c | |||
@@ -75,9 +75,7 @@ bool dal_hw_factory_init( | |||
75 | return true; | 75 | return true; |
76 | case DCE_VERSION_11_0: | 76 | case DCE_VERSION_11_0: |
77 | case DCE_VERSION_11_2: | 77 | case DCE_VERSION_11_2: |
78 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
79 | case DCE_VERSION_11_22: | 78 | case DCE_VERSION_11_22: |
80 | #endif | ||
81 | dal_hw_factory_dce110_init(factory); | 79 | dal_hw_factory_dce110_init(factory); |
82 | return true; | 80 | return true; |
83 | case DCE_VERSION_12_0: | 81 | case DCE_VERSION_12_0: |
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c index 910ae2b7bf64..55c707488541 100644 --- a/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c +++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c | |||
@@ -72,9 +72,7 @@ bool dal_hw_translate_init( | |||
72 | case DCE_VERSION_10_0: | 72 | case DCE_VERSION_10_0: |
73 | case DCE_VERSION_11_0: | 73 | case DCE_VERSION_11_0: |
74 | case DCE_VERSION_11_2: | 74 | case DCE_VERSION_11_2: |
75 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
76 | case DCE_VERSION_11_22: | 75 | case DCE_VERSION_11_22: |
77 | #endif | ||
78 | dal_hw_translate_dce110_init(translate); | 76 | dal_hw_translate_dce110_init(translate); |
79 | return true; | 77 | return true; |
80 | case DCE_VERSION_12_0: | 78 | case DCE_VERSION_12_0: |
diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c b/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c index c3d7c320fdba..14dc8c94d862 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c | |||
@@ -83,9 +83,7 @@ struct i2caux *dal_i2caux_create( | |||
83 | case DCE_VERSION_8_3: | 83 | case DCE_VERSION_8_3: |
84 | return dal_i2caux_dce80_create(ctx); | 84 | return dal_i2caux_dce80_create(ctx); |
85 | case DCE_VERSION_11_2: | 85 | case DCE_VERSION_11_2: |
86 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
87 | case DCE_VERSION_11_22: | 86 | case DCE_VERSION_11_22: |
88 | #endif | ||
89 | return dal_i2caux_dce112_create(ctx); | 87 | return dal_i2caux_dce112_create(ctx); |
90 | case DCE_VERSION_11_0: | 88 | case DCE_VERSION_11_0: |
91 | return dal_i2caux_dce110_create(ctx); | 89 | return dal_i2caux_dce110_create(ctx); |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/dce_calcs.h b/drivers/gpu/drm/amd/display/dc/inc/dce_calcs.h index 933ea7a1e18b..eece165206f9 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/dce_calcs.h +++ b/drivers/gpu/drm/amd/display/dc/inc/dce_calcs.h | |||
@@ -43,9 +43,7 @@ enum bw_calcs_version { | |||
43 | BW_CALCS_VERSION_POLARIS10, | 43 | BW_CALCS_VERSION_POLARIS10, |
44 | BW_CALCS_VERSION_POLARIS11, | 44 | BW_CALCS_VERSION_POLARIS11, |
45 | BW_CALCS_VERSION_POLARIS12, | 45 | BW_CALCS_VERSION_POLARIS12, |
46 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
47 | BW_CALCS_VERSION_VEGAM, | 46 | BW_CALCS_VERSION_VEGAM, |
48 | #endif | ||
49 | BW_CALCS_VERSION_STONEY, | 47 | BW_CALCS_VERSION_STONEY, |
50 | BW_CALCS_VERSION_VEGA10 | 48 | BW_CALCS_VERSION_VEGA10 |
51 | }; | 49 | }; |
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 331f8ff57ed7..97df82cddf82 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h | |||
@@ -121,6 +121,8 @@ struct hubp_funcs { | |||
121 | void (*hubp_clk_cntl)(struct hubp *hubp, bool enable); | 121 | void (*hubp_clk_cntl)(struct hubp *hubp, bool enable); |
122 | void (*hubp_vtg_sel)(struct hubp *hubp, uint32_t otg_inst); | 122 | void (*hubp_vtg_sel)(struct hubp *hubp, uint32_t otg_inst); |
123 | void (*hubp_read_state)(struct hubp *hubp); | 123 | void (*hubp_read_state)(struct hubp *hubp); |
124 | void (*hubp_disable_control)(struct hubp *hubp, bool disable_hubp); | ||
125 | unsigned int (*hubp_get_underflow_status)(struct hubp *hubp); | ||
124 | 126 | ||
125 | }; | 127 | }; |
126 | 128 | ||
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 29abf3ecb39c..63fc6c499789 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h | |||
@@ -83,11 +83,6 @@ struct hw_sequencer_funcs { | |||
83 | int num_planes, | 83 | int num_planes, |
84 | struct dc_state *context); | 84 | struct dc_state *context); |
85 | 85 | ||
86 | void (*set_plane_config)( | ||
87 | const struct dc *dc, | ||
88 | struct pipe_ctx *pipe_ctx, | ||
89 | struct resource_context *res_ctx); | ||
90 | |||
91 | void (*program_gamut_remap)( | 86 | void (*program_gamut_remap)( |
92 | struct pipe_ctx *pipe_ctx); | 87 | struct pipe_ctx *pipe_ctx); |
93 | 88 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/irq_types.h b/drivers/gpu/drm/amd/display/dc/irq_types.h index cc3b1bc6cedd..0b5f3a278c22 100644 --- a/drivers/gpu/drm/amd/display/dc/irq_types.h +++ b/drivers/gpu/drm/amd/display/dc/irq_types.h | |||
@@ -26,6 +26,8 @@ | |||
26 | #ifndef __DAL_IRQ_TYPES_H__ | 26 | #ifndef __DAL_IRQ_TYPES_H__ |
27 | #define __DAL_IRQ_TYPES_H__ | 27 | #define __DAL_IRQ_TYPES_H__ |
28 | 28 | ||
29 | #include "os_types.h" | ||
30 | |||
29 | struct dc_context; | 31 | struct dc_context; |
30 | 32 | ||
31 | typedef void (*interrupt_handler)(void *); | 33 | typedef void (*interrupt_handler)(void *); |
diff --git a/drivers/gpu/drm/amd/display/include/dal_asic_id.h b/drivers/gpu/drm/amd/display/include/dal_asic_id.h index 1b987b6a347d..25029ed42d89 100644 --- a/drivers/gpu/drm/amd/display/include/dal_asic_id.h +++ b/drivers/gpu/drm/amd/display/include/dal_asic_id.h | |||
@@ -86,6 +86,7 @@ | |||
86 | #define VI_POLARIS10_P_A0 80 | 86 | #define VI_POLARIS10_P_A0 80 |
87 | #define VI_POLARIS11_M_A0 90 | 87 | #define VI_POLARIS11_M_A0 90 |
88 | #define VI_POLARIS12_V_A0 100 | 88 | #define VI_POLARIS12_V_A0 100 |
89 | #define VI_VEGAM_A0 110 | ||
89 | 90 | ||
90 | #define VI_UNKNOWN 0xFF | 91 | #define VI_UNKNOWN 0xFF |
91 | 92 | ||
@@ -98,14 +99,9 @@ | |||
98 | (eChipRev < VI_POLARIS11_M_A0)) | 99 | (eChipRev < VI_POLARIS11_M_A0)) |
99 | #define ASIC_REV_IS_POLARIS11_M(eChipRev) ((eChipRev >= VI_POLARIS11_M_A0) && \ | 100 | #define ASIC_REV_IS_POLARIS11_M(eChipRev) ((eChipRev >= VI_POLARIS11_M_A0) && \ |
100 | (eChipRev < VI_POLARIS12_V_A0)) | 101 | (eChipRev < VI_POLARIS12_V_A0)) |
101 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
102 | #define VI_VEGAM_A0 110 | ||
103 | #define ASIC_REV_IS_POLARIS12_V(eChipRev) ((eChipRev >= VI_POLARIS12_V_A0) && \ | 102 | #define ASIC_REV_IS_POLARIS12_V(eChipRev) ((eChipRev >= VI_POLARIS12_V_A0) && \ |
104 | (eChipRev < VI_VEGAM_A0)) | 103 | (eChipRev < VI_VEGAM_A0)) |
105 | #define ASIC_REV_IS_VEGAM(eChipRev) (eChipRev >= VI_VEGAM_A0) | 104 | #define ASIC_REV_IS_VEGAM(eChipRev) (eChipRev >= VI_VEGAM_A0) |
106 | #else | ||
107 | #define ASIC_REV_IS_POLARIS12_V(eChipRev) (eChipRev >= VI_POLARIS12_V_A0) | ||
108 | #endif | ||
109 | 105 | ||
110 | /* DCE11 */ | 106 | /* DCE11 */ |
111 | #define CZ_CARRIZO_A0 0x01 | 107 | #define CZ_CARRIZO_A0 0x01 |
@@ -117,17 +113,19 @@ | |||
117 | ((rev >= STONEY_A0) && (rev < CZ_UNKNOWN)) | 113 | ((rev >= STONEY_A0) && (rev < CZ_UNKNOWN)) |
118 | 114 | ||
119 | /* DCE12 */ | 115 | /* DCE12 */ |
116 | #define AI_UNKNOWN 0xFF | ||
120 | 117 | ||
121 | #define AI_GREENLAND_P_A0 1 | 118 | #define AI_GREENLAND_P_A0 1 |
122 | #define AI_GREENLAND_P_A1 2 | 119 | #define AI_GREENLAND_P_A1 2 |
123 | #define AI_UNKNOWN 0xFF | 120 | #define AI_UNKNOWN 0xFF |
124 | 121 | ||
125 | #define AI_VEGA12_P_A0 20 | 122 | #define AI_VEGA12_P_A0 20 |
123 | #define AI_VEGA20_P_A0 40 | ||
126 | #define ASICREV_IS_GREENLAND_M(eChipRev) (eChipRev < AI_VEGA12_P_A0) | 124 | #define ASICREV_IS_GREENLAND_M(eChipRev) (eChipRev < AI_VEGA12_P_A0) |
127 | #define ASICREV_IS_GREENLAND_P(eChipRev) (eChipRev < AI_VEGA12_P_A0) | 125 | #define ASICREV_IS_GREENLAND_P(eChipRev) (eChipRev < AI_VEGA12_P_A0) |
128 | 126 | ||
129 | #define ASICREV_IS_VEGA12_P(eChipRev) ((eChipRev >= AI_VEGA12_P_A0) && (eChipRev < AI_UNKNOWN)) | 127 | #define ASICREV_IS_VEGA12_P(eChipRev) ((eChipRev >= AI_VEGA12_P_A0) && (eChipRev < AI_VEGA20_P_A0)) |
130 | #define ASICREV_IS_VEGA12_p(eChipRev) ((eChipRev >= AI_VEGA12_P_A0) && (eChipRev < AI_UNKNOWN)) | 128 | #define ASICREV_IS_VEGA20_P(eChipRev) ((eChipRev >= AI_VEGA20_P_A0) && (eChipRev < AI_UNKNOWN)) |
131 | 129 | ||
132 | /* DCN1_0 */ | 130 | /* DCN1_0 */ |
133 | #define INTERNAL_REV_RAVEN_A0 0x00 /* First spin of Raven */ | 131 | #define INTERNAL_REV_RAVEN_A0 0x00 /* First spin of Raven */ |
diff --git a/drivers/gpu/drm/amd/display/include/dal_types.h b/drivers/gpu/drm/amd/display/include/dal_types.h index 5b1f8cef0c22..840142b65f8b 100644 --- a/drivers/gpu/drm/amd/display/include/dal_types.h +++ b/drivers/gpu/drm/amd/display/include/dal_types.h | |||
@@ -40,9 +40,7 @@ enum dce_version { | |||
40 | DCE_VERSION_10_0, | 40 | DCE_VERSION_10_0, |
41 | DCE_VERSION_11_0, | 41 | DCE_VERSION_11_0, |
42 | DCE_VERSION_11_2, | 42 | DCE_VERSION_11_2, |
43 | #if defined(CONFIG_DRM_AMD_DC_VEGAM) | ||
44 | DCE_VERSION_11_22, | 43 | DCE_VERSION_11_22, |
45 | #endif | ||
46 | DCE_VERSION_12_0, | 44 | DCE_VERSION_12_0, |
47 | DCE_VERSION_MAX, | 45 | DCE_VERSION_MAX, |
48 | DCN_VERSION_1_0, | 46 | DCN_VERSION_1_0, |
diff --git a/drivers/gpu/drm/amd/display/include/fixed31_32.h b/drivers/gpu/drm/amd/display/include/fixed31_32.h index 16cbdb43d856..bb0d4ebba9f0 100644 --- a/drivers/gpu/drm/amd/display/include/fixed31_32.h +++ b/drivers/gpu/drm/amd/display/include/fixed31_32.h | |||
@@ -27,6 +27,12 @@ | |||
27 | #define __DAL_FIXED31_32_H__ | 27 | #define __DAL_FIXED31_32_H__ |
28 | 28 | ||
29 | #define FIXED31_32_BITS_PER_FRACTIONAL_PART 32 | 29 | #define FIXED31_32_BITS_PER_FRACTIONAL_PART 32 |
30 | #ifndef LLONG_MIN | ||
31 | #define LLONG_MIN (1LL<<63) | ||
32 | #endif | ||
33 | #ifndef LLONG_MAX | ||
34 | #define LLONG_MAX (-1LL>>1) | ||
35 | #endif | ||
30 | 36 | ||
31 | /* | 37 | /* |
32 | * @brief | 38 | * @brief |
@@ -45,21 +51,22 @@ struct fixed31_32 { | |||
45 | long long value; | 51 | long long value; |
46 | }; | 52 | }; |
47 | 53 | ||
54 | |||
48 | /* | 55 | /* |
49 | * @brief | 56 | * @brief |
50 | * Useful constants | 57 | * Useful constants |
51 | */ | 58 | */ |
52 | 59 | ||
53 | static const struct fixed31_32 dal_fixed31_32_zero = { 0 }; | 60 | static const struct fixed31_32 dc_fixpt_zero = { 0 }; |
54 | static const struct fixed31_32 dal_fixed31_32_epsilon = { 1LL }; | 61 | static const struct fixed31_32 dc_fixpt_epsilon = { 1LL }; |
55 | static const struct fixed31_32 dal_fixed31_32_half = { 0x80000000LL }; | 62 | static const struct fixed31_32 dc_fixpt_half = { 0x80000000LL }; |
56 | static const struct fixed31_32 dal_fixed31_32_one = { 0x100000000LL }; | 63 | static const struct fixed31_32 dc_fixpt_one = { 0x100000000LL }; |
57 | 64 | ||
58 | static const struct fixed31_32 dal_fixed31_32_pi = { 13493037705LL }; | 65 | static const struct fixed31_32 dc_fixpt_pi = { 13493037705LL }; |
59 | static const struct fixed31_32 dal_fixed31_32_two_pi = { 26986075409LL }; | 66 | static const struct fixed31_32 dc_fixpt_two_pi = { 26986075409LL }; |
60 | static const struct fixed31_32 dal_fixed31_32_e = { 11674931555LL }; | 67 | static const struct fixed31_32 dc_fixpt_e = { 11674931555LL }; |
61 | static const struct fixed31_32 dal_fixed31_32_ln2 = { 2977044471LL }; | 68 | static const struct fixed31_32 dc_fixpt_ln2 = { 2977044471LL }; |
62 | static const struct fixed31_32 dal_fixed31_32_ln2_div_2 = { 1488522236LL }; | 69 | static const struct fixed31_32 dc_fixpt_ln2_div_2 = { 1488522236LL }; |
63 | 70 | ||
64 | /* | 71 | /* |
65 | * @brief | 72 | * @brief |
@@ -70,24 +77,19 @@ static const struct fixed31_32 dal_fixed31_32_ln2_div_2 = { 1488522236LL }; | |||
70 | * @brief | 77 | * @brief |
71 | * result = numerator / denominator | 78 | * result = numerator / denominator |
72 | */ | 79 | */ |
73 | struct fixed31_32 dal_fixed31_32_from_fraction( | 80 | struct fixed31_32 dc_fixpt_from_fraction(long long numerator, long long denominator); |
74 | long long numerator, | ||
75 | long long denominator); | ||
76 | 81 | ||
77 | /* | 82 | /* |
78 | * @brief | 83 | * @brief |
79 | * result = arg | 84 | * result = arg |
80 | */ | 85 | */ |
81 | struct fixed31_32 dal_fixed31_32_from_int_nonconst(long long arg); | 86 | static inline struct fixed31_32 dc_fixpt_from_int(int arg) |
82 | static inline struct fixed31_32 dal_fixed31_32_from_int(long long arg) | ||
83 | { | 87 | { |
84 | if (__builtin_constant_p(arg)) { | 88 | struct fixed31_32 res; |
85 | struct fixed31_32 res; | 89 | |
86 | BUILD_BUG_ON((LONG_MIN > arg) || (arg > LONG_MAX)); | 90 | res.value = (long long) arg << FIXED31_32_BITS_PER_FRACTIONAL_PART; |
87 | res.value = arg << FIXED31_32_BITS_PER_FRACTIONAL_PART; | 91 | |
88 | return res; | 92 | return res; |
89 | } else | ||
90 | return dal_fixed31_32_from_int_nonconst(arg); | ||
91 | } | 93 | } |
92 | 94 | ||
93 | /* | 95 | /* |
@@ -99,7 +101,7 @@ static inline struct fixed31_32 dal_fixed31_32_from_int(long long arg) | |||
99 | * @brief | 101 | * @brief |
100 | * result = -arg | 102 | * result = -arg |
101 | */ | 103 | */ |
102 | static inline struct fixed31_32 dal_fixed31_32_neg(struct fixed31_32 arg) | 104 | static inline struct fixed31_32 dc_fixpt_neg(struct fixed31_32 arg) |
103 | { | 105 | { |
104 | struct fixed31_32 res; | 106 | struct fixed31_32 res; |
105 | 107 | ||
@@ -112,10 +114,10 @@ static inline struct fixed31_32 dal_fixed31_32_neg(struct fixed31_32 arg) | |||
112 | * @brief | 114 | * @brief |
113 | * result = abs(arg) := (arg >= 0) ? arg : -arg | 115 | * result = abs(arg) := (arg >= 0) ? arg : -arg |
114 | */ | 116 | */ |
115 | static inline struct fixed31_32 dal_fixed31_32_abs(struct fixed31_32 arg) | 117 | static inline struct fixed31_32 dc_fixpt_abs(struct fixed31_32 arg) |
116 | { | 118 | { |
117 | if (arg.value < 0) | 119 | if (arg.value < 0) |
118 | return dal_fixed31_32_neg(arg); | 120 | return dc_fixpt_neg(arg); |
119 | else | 121 | else |
120 | return arg; | 122 | return arg; |
121 | } | 123 | } |
@@ -129,8 +131,7 @@ static inline struct fixed31_32 dal_fixed31_32_abs(struct fixed31_32 arg) | |||
129 | * @brief | 131 | * @brief |
130 | * result = arg1 < arg2 | 132 | * result = arg1 < arg2 |
131 | */ | 133 | */ |
132 | static inline bool dal_fixed31_32_lt(struct fixed31_32 arg1, | 134 | static inline bool dc_fixpt_lt(struct fixed31_32 arg1, struct fixed31_32 arg2) |
133 | struct fixed31_32 arg2) | ||
134 | { | 135 | { |
135 | return arg1.value < arg2.value; | 136 | return arg1.value < arg2.value; |
136 | } | 137 | } |
@@ -139,8 +140,7 @@ static inline bool dal_fixed31_32_lt(struct fixed31_32 arg1, | |||
139 | * @brief | 140 | * @brief |
140 | * result = arg1 <= arg2 | 141 | * result = arg1 <= arg2 |
141 | */ | 142 | */ |
142 | static inline bool dal_fixed31_32_le(struct fixed31_32 arg1, | 143 | static inline bool dc_fixpt_le(struct fixed31_32 arg1, struct fixed31_32 arg2) |
143 | struct fixed31_32 arg2) | ||
144 | { | 144 | { |
145 | return arg1.value <= arg2.value; | 145 | return arg1.value <= arg2.value; |
146 | } | 146 | } |
@@ -149,8 +149,7 @@ static inline bool dal_fixed31_32_le(struct fixed31_32 arg1, | |||
149 | * @brief | 149 | * @brief |
150 | * result = arg1 == arg2 | 150 | * result = arg1 == arg2 |
151 | */ | 151 | */ |
152 | static inline bool dal_fixed31_32_eq(struct fixed31_32 arg1, | 152 | static inline bool dc_fixpt_eq(struct fixed31_32 arg1, struct fixed31_32 arg2) |
153 | struct fixed31_32 arg2) | ||
154 | { | 153 | { |
155 | return arg1.value == arg2.value; | 154 | return arg1.value == arg2.value; |
156 | } | 155 | } |
@@ -159,8 +158,7 @@ static inline bool dal_fixed31_32_eq(struct fixed31_32 arg1, | |||
159 | * @brief | 158 | * @brief |
160 | * result = min(arg1, arg2) := (arg1 <= arg2) ? arg1 : arg2 | 159 | * result = min(arg1, arg2) := (arg1 <= arg2) ? arg1 : arg2 |
161 | */ | 160 | */ |
162 | static inline struct fixed31_32 dal_fixed31_32_min(struct fixed31_32 arg1, | 161 | static inline struct fixed31_32 dc_fixpt_min(struct fixed31_32 arg1, struct fixed31_32 arg2) |
163 | struct fixed31_32 arg2) | ||
164 | { | 162 | { |
165 | if (arg1.value <= arg2.value) | 163 | if (arg1.value <= arg2.value) |
166 | return arg1; | 164 | return arg1; |
@@ -172,8 +170,7 @@ static inline struct fixed31_32 dal_fixed31_32_min(struct fixed31_32 arg1, | |||
172 | * @brief | 170 | * @brief |
173 | * result = max(arg1, arg2) := (arg1 <= arg2) ? arg2 : arg1 | 171 | * result = max(arg1, arg2) := (arg1 <= arg2) ? arg2 : arg1 |
174 | */ | 172 | */ |
175 | static inline struct fixed31_32 dal_fixed31_32_max(struct fixed31_32 arg1, | 173 | static inline struct fixed31_32 dc_fixpt_max(struct fixed31_32 arg1, struct fixed31_32 arg2) |
176 | struct fixed31_32 arg2) | ||
177 | { | 174 | { |
178 | if (arg1.value <= arg2.value) | 175 | if (arg1.value <= arg2.value) |
179 | return arg2; | 176 | return arg2; |
@@ -187,14 +184,14 @@ static inline struct fixed31_32 dal_fixed31_32_max(struct fixed31_32 arg1, | |||
187 | * result = | arg, when min_value < arg < max_value | 184 | * result = | arg, when min_value < arg < max_value |
188 | * | max_value, when arg >= max_value | 185 | * | max_value, when arg >= max_value |
189 | */ | 186 | */ |
190 | static inline struct fixed31_32 dal_fixed31_32_clamp( | 187 | static inline struct fixed31_32 dc_fixpt_clamp( |
191 | struct fixed31_32 arg, | 188 | struct fixed31_32 arg, |
192 | struct fixed31_32 min_value, | 189 | struct fixed31_32 min_value, |
193 | struct fixed31_32 max_value) | 190 | struct fixed31_32 max_value) |
194 | { | 191 | { |
195 | if (dal_fixed31_32_le(arg, min_value)) | 192 | if (dc_fixpt_le(arg, min_value)) |
196 | return min_value; | 193 | return min_value; |
197 | else if (dal_fixed31_32_le(max_value, arg)) | 194 | else if (dc_fixpt_le(max_value, arg)) |
198 | return max_value; | 195 | return max_value; |
199 | else | 196 | else |
200 | return arg; | 197 | return arg; |
@@ -209,21 +206,30 @@ static inline struct fixed31_32 dal_fixed31_32_clamp( | |||
209 | * @brief | 206 | * @brief |
210 | * result = arg << shift | 207 | * result = arg << shift |
211 | */ | 208 | */ |
212 | struct fixed31_32 dal_fixed31_32_shl( | 209 | static inline struct fixed31_32 dc_fixpt_shl(struct fixed31_32 arg, unsigned char shift) |
213 | struct fixed31_32 arg, | 210 | { |
214 | unsigned char shift); | 211 | ASSERT(((arg.value >= 0) && (arg.value <= LLONG_MAX >> shift)) || |
212 | ((arg.value < 0) && (arg.value >= ~(LLONG_MAX >> shift)))); | ||
213 | |||
214 | arg.value = arg.value << shift; | ||
215 | |||
216 | return arg; | ||
217 | } | ||
215 | 218 | ||
216 | /* | 219 | /* |
217 | * @brief | 220 | * @brief |
218 | * result = arg >> shift | 221 | * result = arg >> shift |
219 | */ | 222 | */ |
220 | static inline struct fixed31_32 dal_fixed31_32_shr( | 223 | static inline struct fixed31_32 dc_fixpt_shr(struct fixed31_32 arg, unsigned char shift) |
221 | struct fixed31_32 arg, | ||
222 | unsigned char shift) | ||
223 | { | 224 | { |
224 | struct fixed31_32 res; | 225 | bool negative = arg.value < 0; |
225 | res.value = arg.value >> shift; | 226 | |
226 | return res; | 227 | if (negative) |
228 | arg.value = -arg.value; | ||
229 | arg.value = arg.value >> shift; | ||
230 | if (negative) | ||
231 | arg.value = -arg.value; | ||
232 | return arg; | ||
227 | } | 233 | } |
228 | 234 | ||
229 | /* | 235 | /* |
@@ -235,38 +241,50 @@ static inline struct fixed31_32 dal_fixed31_32_shr( | |||
235 | * @brief | 241 | * @brief |
236 | * result = arg1 + arg2 | 242 | * result = arg1 + arg2 |
237 | */ | 243 | */ |
238 | struct fixed31_32 dal_fixed31_32_add( | 244 | static inline struct fixed31_32 dc_fixpt_add(struct fixed31_32 arg1, struct fixed31_32 arg2) |
239 | struct fixed31_32 arg1, | 245 | { |
240 | struct fixed31_32 arg2); | 246 | struct fixed31_32 res; |
247 | |||
248 | ASSERT(((arg1.value >= 0) && (LLONG_MAX - arg1.value >= arg2.value)) || | ||
249 | ((arg1.value < 0) && (LLONG_MIN - arg1.value <= arg2.value))); | ||
250 | |||
251 | res.value = arg1.value + arg2.value; | ||
252 | |||
253 | return res; | ||
254 | } | ||
241 | 255 | ||
242 | /* | 256 | /* |
243 | * @brief | 257 | * @brief |
244 | * result = arg1 + arg2 | 258 | * result = arg1 + arg2 |
245 | */ | 259 | */ |
246 | static inline struct fixed31_32 dal_fixed31_32_add_int(struct fixed31_32 arg1, | 260 | static inline struct fixed31_32 dc_fixpt_add_int(struct fixed31_32 arg1, int arg2) |
247 | int arg2) | ||
248 | { | 261 | { |
249 | return dal_fixed31_32_add(arg1, | 262 | return dc_fixpt_add(arg1, dc_fixpt_from_int(arg2)); |
250 | dal_fixed31_32_from_int(arg2)); | ||
251 | } | 263 | } |
252 | 264 | ||
253 | /* | 265 | /* |
254 | * @brief | 266 | * @brief |
255 | * result = arg1 - arg2 | 267 | * result = arg1 - arg2 |
256 | */ | 268 | */ |
257 | struct fixed31_32 dal_fixed31_32_sub( | 269 | static inline struct fixed31_32 dc_fixpt_sub(struct fixed31_32 arg1, struct fixed31_32 arg2) |
258 | struct fixed31_32 arg1, | 270 | { |
259 | struct fixed31_32 arg2); | 271 | struct fixed31_32 res; |
272 | |||
273 | ASSERT(((arg2.value >= 0) && (LLONG_MIN + arg2.value <= arg1.value)) || | ||
274 | ((arg2.value < 0) && (LLONG_MAX + arg2.value >= arg1.value))); | ||
275 | |||
276 | res.value = arg1.value - arg2.value; | ||
277 | |||
278 | return res; | ||
279 | } | ||
260 | 280 | ||
261 | /* | 281 | /* |
262 | * @brief | 282 | * @brief |
263 | * result = arg1 - arg2 | 283 | * result = arg1 - arg2 |
264 | */ | 284 | */ |
265 | static inline struct fixed31_32 dal_fixed31_32_sub_int(struct fixed31_32 arg1, | 285 | static inline struct fixed31_32 dc_fixpt_sub_int(struct fixed31_32 arg1, int arg2) |
266 | int arg2) | ||
267 | { | 286 | { |
268 | return dal_fixed31_32_sub(arg1, | 287 | return dc_fixpt_sub(arg1, dc_fixpt_from_int(arg2)); |
269 | dal_fixed31_32_from_int(arg2)); | ||
270 | } | 288 | } |
271 | 289 | ||
272 | 290 | ||
@@ -279,49 +297,40 @@ static inline struct fixed31_32 dal_fixed31_32_sub_int(struct fixed31_32 arg1, | |||
279 | * @brief | 297 | * @brief |
280 | * result = arg1 * arg2 | 298 | * result = arg1 * arg2 |
281 | */ | 299 | */ |
282 | struct fixed31_32 dal_fixed31_32_mul( | 300 | struct fixed31_32 dc_fixpt_mul(struct fixed31_32 arg1, struct fixed31_32 arg2); |
283 | struct fixed31_32 arg1, | ||
284 | struct fixed31_32 arg2); | ||
285 | 301 | ||
286 | 302 | ||
287 | /* | 303 | /* |
288 | * @brief | 304 | * @brief |
289 | * result = arg1 * arg2 | 305 | * result = arg1 * arg2 |
290 | */ | 306 | */ |
291 | static inline struct fixed31_32 dal_fixed31_32_mul_int(struct fixed31_32 arg1, | 307 | static inline struct fixed31_32 dc_fixpt_mul_int(struct fixed31_32 arg1, int arg2) |
292 | int arg2) | ||
293 | { | 308 | { |
294 | return dal_fixed31_32_mul(arg1, | 309 | return dc_fixpt_mul(arg1, dc_fixpt_from_int(arg2)); |
295 | dal_fixed31_32_from_int(arg2)); | ||
296 | } | 310 | } |
297 | 311 | ||
298 | /* | 312 | /* |
299 | * @brief | 313 | * @brief |
300 | * result = square(arg) := arg * arg | 314 | * result = square(arg) := arg * arg |
301 | */ | 315 | */ |
302 | struct fixed31_32 dal_fixed31_32_sqr( | 316 | struct fixed31_32 dc_fixpt_sqr(struct fixed31_32 arg); |
303 | struct fixed31_32 arg); | ||
304 | 317 | ||
305 | /* | 318 | /* |
306 | * @brief | 319 | * @brief |
307 | * result = arg1 / arg2 | 320 | * result = arg1 / arg2 |
308 | */ | 321 | */ |
309 | static inline struct fixed31_32 dal_fixed31_32_div_int(struct fixed31_32 arg1, | 322 | static inline struct fixed31_32 dc_fixpt_div_int(struct fixed31_32 arg1, long long arg2) |
310 | long long arg2) | ||
311 | { | 323 | { |
312 | return dal_fixed31_32_from_fraction(arg1.value, | 324 | return dc_fixpt_from_fraction(arg1.value, dc_fixpt_from_int(arg2).value); |
313 | dal_fixed31_32_from_int(arg2).value); | ||
314 | } | 325 | } |
315 | 326 | ||
316 | /* | 327 | /* |
317 | * @brief | 328 | * @brief |
318 | * result = arg1 / arg2 | 329 | * result = arg1 / arg2 |
319 | */ | 330 | */ |
320 | static inline struct fixed31_32 dal_fixed31_32_div(struct fixed31_32 arg1, | 331 | static inline struct fixed31_32 dc_fixpt_div(struct fixed31_32 arg1, struct fixed31_32 arg2) |
321 | struct fixed31_32 arg2) | ||
322 | { | 332 | { |
323 | return dal_fixed31_32_from_fraction(arg1.value, | 333 | return dc_fixpt_from_fraction(arg1.value, arg2.value); |
324 | arg2.value); | ||
325 | } | 334 | } |
326 | 335 | ||
327 | /* | 336 | /* |
@@ -336,8 +345,7 @@ static inline struct fixed31_32 dal_fixed31_32_div(struct fixed31_32 arg1, | |||
336 | * @note | 345 | * @note |
337 | * No special actions taken in case argument is zero. | 346 | * No special actions taken in case argument is zero. |
338 | */ | 347 | */ |
339 | struct fixed31_32 dal_fixed31_32_recip( | 348 | struct fixed31_32 dc_fixpt_recip(struct fixed31_32 arg); |
340 | struct fixed31_32 arg); | ||
341 | 349 | ||
342 | /* | 350 | /* |
343 | * @brief | 351 | * @brief |
@@ -352,8 +360,7 @@ struct fixed31_32 dal_fixed31_32_recip( | |||
352 | * Argument specified in radians, | 360 | * Argument specified in radians, |
353 | * internally it's normalized to [-2pi...2pi] range. | 361 | * internally it's normalized to [-2pi...2pi] range. |
354 | */ | 362 | */ |
355 | struct fixed31_32 dal_fixed31_32_sinc( | 363 | struct fixed31_32 dc_fixpt_sinc(struct fixed31_32 arg); |
356 | struct fixed31_32 arg); | ||
357 | 364 | ||
358 | /* | 365 | /* |
359 | * @brief | 366 | * @brief |
@@ -363,8 +370,7 @@ struct fixed31_32 dal_fixed31_32_sinc( | |||
363 | * Argument specified in radians, | 370 | * Argument specified in radians, |
364 | * internally it's normalized to [-2pi...2pi] range. | 371 | * internally it's normalized to [-2pi...2pi] range. |
365 | */ | 372 | */ |
366 | struct fixed31_32 dal_fixed31_32_sin( | 373 | struct fixed31_32 dc_fixpt_sin(struct fixed31_32 arg); |
367 | struct fixed31_32 arg); | ||
368 | 374 | ||
369 | /* | 375 | /* |
370 | * @brief | 376 | * @brief |
@@ -376,8 +382,7 @@ struct fixed31_32 dal_fixed31_32_sin( | |||
376 | * passing arguments outside that range | 382 | * passing arguments outside that range |
377 | * will cause incorrect result! | 383 | * will cause incorrect result! |
378 | */ | 384 | */ |
379 | struct fixed31_32 dal_fixed31_32_cos( | 385 | struct fixed31_32 dc_fixpt_cos(struct fixed31_32 arg); |
380 | struct fixed31_32 arg); | ||
381 | 386 | ||
382 | /* | 387 | /* |
383 | * @brief | 388 | * @brief |
@@ -391,8 +396,7 @@ struct fixed31_32 dal_fixed31_32_cos( | |||
391 | * @note | 396 | * @note |
392 | * Currently, function is verified for abs(arg) <= 1. | 397 | * Currently, function is verified for abs(arg) <= 1. |
393 | */ | 398 | */ |
394 | struct fixed31_32 dal_fixed31_32_exp( | 399 | struct fixed31_32 dc_fixpt_exp(struct fixed31_32 arg); |
395 | struct fixed31_32 arg); | ||
396 | 400 | ||
397 | /* | 401 | /* |
398 | * @brief | 402 | * @brief |
@@ -404,8 +408,7 @@ struct fixed31_32 dal_fixed31_32_exp( | |||
404 | * Currently, no special actions taken | 408 | * Currently, no special actions taken |
405 | * in case of invalid argument(s). Take care! | 409 | * in case of invalid argument(s). Take care! |
406 | */ | 410 | */ |
407 | struct fixed31_32 dal_fixed31_32_log( | 411 | struct fixed31_32 dc_fixpt_log(struct fixed31_32 arg); |
408 | struct fixed31_32 arg); | ||
409 | 412 | ||
410 | /* | 413 | /* |
411 | * @brief | 414 | * @brief |
@@ -419,9 +422,13 @@ struct fixed31_32 dal_fixed31_32_log( | |||
419 | * @note | 422 | * @note |
420 | * Currently, abs(arg1) should be less than 1. Take care! | 423 | * Currently, abs(arg1) should be less than 1. Take care! |
421 | */ | 424 | */ |
422 | struct fixed31_32 dal_fixed31_32_pow( | 425 | static inline struct fixed31_32 dc_fixpt_pow(struct fixed31_32 arg1, struct fixed31_32 arg2) |
423 | struct fixed31_32 arg1, | 426 | { |
424 | struct fixed31_32 arg2); | 427 | return dc_fixpt_exp( |
428 | dc_fixpt_mul( | ||
429 | dc_fixpt_log(arg1), | ||
430 | arg2)); | ||
431 | } | ||
425 | 432 | ||
426 | /* | 433 | /* |
427 | * @brief | 434 | * @brief |
@@ -432,22 +439,56 @@ struct fixed31_32 dal_fixed31_32_pow( | |||
432 | * @brief | 439 | * @brief |
433 | * result = floor(arg) := greatest integer lower than or equal to arg | 440 | * result = floor(arg) := greatest integer lower than or equal to arg |
434 | */ | 441 | */ |
435 | int dal_fixed31_32_floor( | 442 | static inline int dc_fixpt_floor(struct fixed31_32 arg) |
436 | struct fixed31_32 arg); | 443 | { |
444 | unsigned long long arg_value = arg.value > 0 ? arg.value : -arg.value; | ||
445 | |||
446 | if (arg.value >= 0) | ||
447 | return (int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); | ||
448 | else | ||
449 | return -(int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); | ||
450 | } | ||
437 | 451 | ||
438 | /* | 452 | /* |
439 | * @brief | 453 | * @brief |
440 | * result = round(arg) := integer nearest to arg | 454 | * result = round(arg) := integer nearest to arg |
441 | */ | 455 | */ |
442 | int dal_fixed31_32_round( | 456 | static inline int dc_fixpt_round(struct fixed31_32 arg) |
443 | struct fixed31_32 arg); | 457 | { |
458 | unsigned long long arg_value = arg.value > 0 ? arg.value : -arg.value; | ||
459 | |||
460 | const long long summand = dc_fixpt_half.value; | ||
461 | |||
462 | ASSERT(LLONG_MAX - (long long)arg_value >= summand); | ||
463 | |||
464 | arg_value += summand; | ||
465 | |||
466 | if (arg.value >= 0) | ||
467 | return (int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); | ||
468 | else | ||
469 | return -(int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); | ||
470 | } | ||
444 | 471 | ||
445 | /* | 472 | /* |
446 | * @brief | 473 | * @brief |
447 | * result = ceil(arg) := lowest integer greater than or equal to arg | 474 | * result = ceil(arg) := lowest integer greater than or equal to arg |
448 | */ | 475 | */ |
449 | int dal_fixed31_32_ceil( | 476 | static inline int dc_fixpt_ceil(struct fixed31_32 arg) |
450 | struct fixed31_32 arg); | 477 | { |
478 | unsigned long long arg_value = arg.value > 0 ? arg.value : -arg.value; | ||
479 | |||
480 | const long long summand = dc_fixpt_one.value - | ||
481 | dc_fixpt_epsilon.value; | ||
482 | |||
483 | ASSERT(LLONG_MAX - (long long)arg_value >= summand); | ||
484 | |||
485 | arg_value += summand; | ||
486 | |||
487 | if (arg.value >= 0) | ||
488 | return (int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); | ||
489 | else | ||
490 | return -(int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); | ||
491 | } | ||
451 | 492 | ||
452 | /* the following two function are used in scaler hw programming to convert fixed | 493 | /* the following two function are used in scaler hw programming to convert fixed |
453 | * point value to format 2 bits from integer part and 19 bits from fractional | 494 | * point value to format 2 bits from integer part and 19 bits from fractional |
@@ -455,20 +496,31 @@ int dal_fixed31_32_ceil( | |||
455 | * fractional | 496 | * fractional |
456 | */ | 497 | */ |
457 | 498 | ||
458 | unsigned int dal_fixed31_32_u2d19( | 499 | unsigned int dc_fixpt_u2d19(struct fixed31_32 arg); |
459 | struct fixed31_32 arg); | 500 | |
501 | unsigned int dc_fixpt_u0d19(struct fixed31_32 arg); | ||
460 | 502 | ||
461 | unsigned int dal_fixed31_32_u0d19( | 503 | unsigned int dc_fixpt_clamp_u0d14(struct fixed31_32 arg); |
462 | struct fixed31_32 arg); | ||
463 | 504 | ||
505 | unsigned int dc_fixpt_clamp_u0d10(struct fixed31_32 arg); | ||
464 | 506 | ||
465 | unsigned int dal_fixed31_32_clamp_u0d14( | 507 | int dc_fixpt_s4d19(struct fixed31_32 arg); |
466 | struct fixed31_32 arg); | ||
467 | 508 | ||
468 | unsigned int dal_fixed31_32_clamp_u0d10( | 509 | static inline struct fixed31_32 dc_fixpt_truncate(struct fixed31_32 arg, unsigned int frac_bits) |
469 | struct fixed31_32 arg); | 510 | { |
511 | bool negative = arg.value < 0; | ||
470 | 512 | ||
471 | int dal_fixed31_32_s4d19( | 513 | if (frac_bits >= FIXED31_32_BITS_PER_FRACTIONAL_PART) { |
472 | struct fixed31_32 arg); | 514 | ASSERT(frac_bits == FIXED31_32_BITS_PER_FRACTIONAL_PART); |
515 | return arg; | ||
516 | } | ||
517 | |||
518 | if (negative) | ||
519 | arg.value = -arg.value; | ||
520 | arg.value &= (~0LL) << (FIXED31_32_BITS_PER_FRACTIONAL_PART - frac_bits); | ||
521 | if (negative) | ||
522 | arg.value = -arg.value; | ||
523 | return arg; | ||
524 | } | ||
473 | 525 | ||
474 | #endif | 526 | #endif |
diff --git a/drivers/gpu/drm/amd/display/include/fixed32_32.h b/drivers/gpu/drm/amd/display/include/fixed32_32.h deleted file mode 100644 index 9c70341fe026..000000000000 --- a/drivers/gpu/drm/amd/display/include/fixed32_32.h +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2012-15 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 | * Authors: AMD | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | |||
27 | #ifndef __DAL_FIXED32_32_H__ | ||
28 | #define __DAL_FIXED32_32_H__ | ||
29 | |||
30 | #include "os_types.h" | ||
31 | |||
32 | struct fixed32_32 { | ||
33 | uint64_t value; | ||
34 | }; | ||
35 | |||
36 | static const struct fixed32_32 dal_fixed32_32_zero = { 0 }; | ||
37 | static const struct fixed32_32 dal_fixed32_32_one = { 0x100000000LL }; | ||
38 | static const struct fixed32_32 dal_fixed32_32_half = { 0x80000000LL }; | ||
39 | |||
40 | struct fixed32_32 dal_fixed32_32_from_fraction(uint32_t n, uint32_t d); | ||
41 | static inline struct fixed32_32 dal_fixed32_32_from_int(uint32_t value) | ||
42 | { | ||
43 | struct fixed32_32 fx; | ||
44 | |||
45 | fx.value = (uint64_t)value<<32; | ||
46 | return fx; | ||
47 | } | ||
48 | |||
49 | struct fixed32_32 dal_fixed32_32_add( | ||
50 | struct fixed32_32 lhs, | ||
51 | struct fixed32_32 rhs); | ||
52 | struct fixed32_32 dal_fixed32_32_add_int( | ||
53 | struct fixed32_32 lhs, | ||
54 | uint32_t rhs); | ||
55 | struct fixed32_32 dal_fixed32_32_sub( | ||
56 | struct fixed32_32 lhs, | ||
57 | struct fixed32_32 rhs); | ||
58 | struct fixed32_32 dal_fixed32_32_sub_int( | ||
59 | struct fixed32_32 lhs, | ||
60 | uint32_t rhs); | ||
61 | struct fixed32_32 dal_fixed32_32_mul( | ||
62 | struct fixed32_32 lhs, | ||
63 | struct fixed32_32 rhs); | ||
64 | struct fixed32_32 dal_fixed32_32_mul_int( | ||
65 | struct fixed32_32 lhs, | ||
66 | uint32_t rhs); | ||
67 | struct fixed32_32 dal_fixed32_32_div( | ||
68 | struct fixed32_32 lhs, | ||
69 | struct fixed32_32 rhs); | ||
70 | struct fixed32_32 dal_fixed32_32_div_int( | ||
71 | struct fixed32_32 lhs, | ||
72 | uint32_t rhs); | ||
73 | |||
74 | static inline struct fixed32_32 dal_fixed32_32_min(struct fixed32_32 lhs, | ||
75 | struct fixed32_32 rhs) | ||
76 | { | ||
77 | return (lhs.value < rhs.value) ? lhs : rhs; | ||
78 | } | ||
79 | |||
80 | static inline struct fixed32_32 dal_fixed32_32_max(struct fixed32_32 lhs, | ||
81 | struct fixed32_32 rhs) | ||
82 | { | ||
83 | return (lhs.value > rhs.value) ? lhs : rhs; | ||
84 | } | ||
85 | |||
86 | static inline bool dal_fixed32_32_gt(struct fixed32_32 lhs, struct fixed32_32 rhs) | ||
87 | { | ||
88 | return lhs.value > rhs.value; | ||
89 | } | ||
90 | |||
91 | static inline bool dal_fixed32_32_gt_int(struct fixed32_32 lhs, uint32_t rhs) | ||
92 | { | ||
93 | return lhs.value > ((uint64_t)rhs<<32); | ||
94 | } | ||
95 | |||
96 | static inline bool dal_fixed32_32_lt(struct fixed32_32 lhs, struct fixed32_32 rhs) | ||
97 | { | ||
98 | return lhs.value < rhs.value; | ||
99 | } | ||
100 | |||
101 | static inline bool dal_fixed32_32_lt_int(struct fixed32_32 lhs, uint32_t rhs) | ||
102 | { | ||
103 | return lhs.value < ((uint64_t)rhs<<32); | ||
104 | } | ||
105 | |||
106 | static inline bool dal_fixed32_32_le(struct fixed32_32 lhs, struct fixed32_32 rhs) | ||
107 | { | ||
108 | return lhs.value <= rhs.value; | ||
109 | } | ||
110 | |||
111 | static inline bool dal_fixed32_32_le_int(struct fixed32_32 lhs, uint32_t rhs) | ||
112 | { | ||
113 | return lhs.value <= ((uint64_t)rhs<<32); | ||
114 | } | ||
115 | |||
116 | static inline bool dal_fixed32_32_eq(struct fixed32_32 lhs, struct fixed32_32 rhs) | ||
117 | { | ||
118 | return lhs.value == rhs.value; | ||
119 | } | ||
120 | |||
121 | uint32_t dal_fixed32_32_ceil(struct fixed32_32 value); | ||
122 | static inline uint32_t dal_fixed32_32_floor(struct fixed32_32 value) | ||
123 | { | ||
124 | return value.value>>32; | ||
125 | } | ||
126 | |||
127 | uint32_t dal_fixed32_32_round(struct fixed32_32 value); | ||
128 | |||
129 | #endif | ||
diff --git a/drivers/gpu/drm/amd/display/include/logger_interface.h b/drivers/gpu/drm/amd/display/include/logger_interface.h index 28dee960d509..dc98d6d4b2bd 100644 --- a/drivers/gpu/drm/amd/display/include/logger_interface.h +++ b/drivers/gpu/drm/amd/display/include/logger_interface.h | |||
@@ -190,4 +190,13 @@ void context_clock_trace( | |||
190 | } \ | 190 | } \ |
191 | } while (0) | 191 | } while (0) |
192 | 192 | ||
193 | #define DISPLAY_STATS_BEGIN(entry) \ | ||
194 | dm_logger_open(dc->ctx->logger, &entry, LOG_DISPLAYSTATS) | ||
195 | |||
196 | #define DISPLAY_STATS(msg, ...) \ | ||
197 | dm_logger_append(&log_entry, msg, ##__VA_ARGS__) | ||
198 | |||
199 | #define DISPLAY_STATS_END(entry) \ | ||
200 | dm_logger_close(&entry) | ||
201 | |||
193 | #endif /* __DAL_LOGGER_INTERFACE_H__ */ | 202 | #endif /* __DAL_LOGGER_INTERFACE_H__ */ |
diff --git a/drivers/gpu/drm/amd/display/include/logger_types.h b/drivers/gpu/drm/amd/display/include/logger_types.h index b608a0830801..0a540b9897a6 100644 --- a/drivers/gpu/drm/amd/display/include/logger_types.h +++ b/drivers/gpu/drm/amd/display/include/logger_types.h | |||
@@ -98,7 +98,7 @@ enum dc_log_type { | |||
98 | LOG_EVENT_UNDERFLOW, | 98 | LOG_EVENT_UNDERFLOW, |
99 | LOG_IF_TRACE, | 99 | LOG_IF_TRACE, |
100 | LOG_PERF_TRACE, | 100 | LOG_PERF_TRACE, |
101 | LOG_PROFILING, | 101 | LOG_DISPLAYSTATS, |
102 | 102 | ||
103 | LOG_SECTION_TOTAL_COUNT | 103 | LOG_SECTION_TOTAL_COUNT |
104 | }; | 104 | }; |
diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c index 8446e0876ac8..0cd111d59018 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c | |||
@@ -43,7 +43,7 @@ static bool de_pq_initialized; /* = false; */ | |||
43 | /* one-time setup of X points */ | 43 | /* one-time setup of X points */ |
44 | void setup_x_points_distribution(void) | 44 | void setup_x_points_distribution(void) |
45 | { | 45 | { |
46 | struct fixed31_32 region_size = dal_fixed31_32_from_int(128); | 46 | struct fixed31_32 region_size = dc_fixpt_from_int(128); |
47 | int32_t segment; | 47 | int32_t segment; |
48 | uint32_t seg_offset; | 48 | uint32_t seg_offset; |
49 | uint32_t index; | 49 | uint32_t index; |
@@ -53,8 +53,8 @@ void setup_x_points_distribution(void) | |||
53 | coordinates_x[MAX_HW_POINTS + 1].x = region_size; | 53 | coordinates_x[MAX_HW_POINTS + 1].x = region_size; |
54 | 54 | ||
55 | for (segment = 6; segment > (6 - NUM_REGIONS); segment--) { | 55 | for (segment = 6; segment > (6 - NUM_REGIONS); segment--) { |
56 | region_size = dal_fixed31_32_div_int(region_size, 2); | 56 | region_size = dc_fixpt_div_int(region_size, 2); |
57 | increment = dal_fixed31_32_div_int(region_size, | 57 | increment = dc_fixpt_div_int(region_size, |
58 | NUM_PTS_IN_REGION); | 58 | NUM_PTS_IN_REGION); |
59 | seg_offset = (segment + (NUM_REGIONS - 7)) * NUM_PTS_IN_REGION; | 59 | seg_offset = (segment + (NUM_REGIONS - 7)) * NUM_PTS_IN_REGION; |
60 | coordinates_x[seg_offset].x = region_size; | 60 | coordinates_x[seg_offset].x = region_size; |
@@ -62,7 +62,7 @@ void setup_x_points_distribution(void) | |||
62 | for (index = seg_offset + 1; | 62 | for (index = seg_offset + 1; |
63 | index < seg_offset + NUM_PTS_IN_REGION; | 63 | index < seg_offset + NUM_PTS_IN_REGION; |
64 | index++) { | 64 | index++) { |
65 | coordinates_x[index].x = dal_fixed31_32_add | 65 | coordinates_x[index].x = dc_fixpt_add |
66 | (coordinates_x[index-1].x, increment); | 66 | (coordinates_x[index-1].x, increment); |
67 | } | 67 | } |
68 | } | 68 | } |
@@ -72,63 +72,63 @@ static void compute_pq(struct fixed31_32 in_x, struct fixed31_32 *out_y) | |||
72 | { | 72 | { |
73 | /* consts for PQ gamma formula. */ | 73 | /* consts for PQ gamma formula. */ |
74 | const struct fixed31_32 m1 = | 74 | const struct fixed31_32 m1 = |
75 | dal_fixed31_32_from_fraction(159301758, 1000000000); | 75 | dc_fixpt_from_fraction(159301758, 1000000000); |
76 | const struct fixed31_32 m2 = | 76 | const struct fixed31_32 m2 = |
77 | dal_fixed31_32_from_fraction(7884375, 100000); | 77 | dc_fixpt_from_fraction(7884375, 100000); |
78 | const struct fixed31_32 c1 = | 78 | const struct fixed31_32 c1 = |
79 | dal_fixed31_32_from_fraction(8359375, 10000000); | 79 | dc_fixpt_from_fraction(8359375, 10000000); |
80 | const struct fixed31_32 c2 = | 80 | const struct fixed31_32 c2 = |
81 | dal_fixed31_32_from_fraction(188515625, 10000000); | 81 | dc_fixpt_from_fraction(188515625, 10000000); |
82 | const struct fixed31_32 c3 = | 82 | const struct fixed31_32 c3 = |
83 | dal_fixed31_32_from_fraction(186875, 10000); | 83 | dc_fixpt_from_fraction(186875, 10000); |
84 | 84 | ||
85 | struct fixed31_32 l_pow_m1; | 85 | struct fixed31_32 l_pow_m1; |
86 | struct fixed31_32 base; | 86 | struct fixed31_32 base; |
87 | 87 | ||
88 | if (dal_fixed31_32_lt(in_x, dal_fixed31_32_zero)) | 88 | if (dc_fixpt_lt(in_x, dc_fixpt_zero)) |
89 | in_x = dal_fixed31_32_zero; | 89 | in_x = dc_fixpt_zero; |
90 | 90 | ||
91 | l_pow_m1 = dal_fixed31_32_pow(in_x, m1); | 91 | l_pow_m1 = dc_fixpt_pow(in_x, m1); |
92 | base = dal_fixed31_32_div( | 92 | base = dc_fixpt_div( |
93 | dal_fixed31_32_add(c1, | 93 | dc_fixpt_add(c1, |
94 | (dal_fixed31_32_mul(c2, l_pow_m1))), | 94 | (dc_fixpt_mul(c2, l_pow_m1))), |
95 | dal_fixed31_32_add(dal_fixed31_32_one, | 95 | dc_fixpt_add(dc_fixpt_one, |
96 | (dal_fixed31_32_mul(c3, l_pow_m1)))); | 96 | (dc_fixpt_mul(c3, l_pow_m1)))); |
97 | *out_y = dal_fixed31_32_pow(base, m2); | 97 | *out_y = dc_fixpt_pow(base, m2); |
98 | } | 98 | } |
99 | 99 | ||
100 | static void compute_de_pq(struct fixed31_32 in_x, struct fixed31_32 *out_y) | 100 | static void compute_de_pq(struct fixed31_32 in_x, struct fixed31_32 *out_y) |
101 | { | 101 | { |
102 | /* consts for dePQ gamma formula. */ | 102 | /* consts for dePQ gamma formula. */ |
103 | const struct fixed31_32 m1 = | 103 | const struct fixed31_32 m1 = |
104 | dal_fixed31_32_from_fraction(159301758, 1000000000); | 104 | dc_fixpt_from_fraction(159301758, 1000000000); |
105 | const struct fixed31_32 m2 = | 105 | const struct fixed31_32 m2 = |
106 | dal_fixed31_32_from_fraction(7884375, 100000); | 106 | dc_fixpt_from_fraction(7884375, 100000); |
107 | const struct fixed31_32 c1 = | 107 | const struct fixed31_32 c1 = |
108 | dal_fixed31_32_from_fraction(8359375, 10000000); | 108 | dc_fixpt_from_fraction(8359375, 10000000); |
109 | const struct fixed31_32 c2 = | 109 | const struct fixed31_32 c2 = |
110 | dal_fixed31_32_from_fraction(188515625, 10000000); | 110 | dc_fixpt_from_fraction(188515625, 10000000); |
111 | const struct fixed31_32 c3 = | 111 | const struct fixed31_32 c3 = |
112 | dal_fixed31_32_from_fraction(186875, 10000); | 112 | dc_fixpt_from_fraction(186875, 10000); |
113 | 113 | ||
114 | struct fixed31_32 l_pow_m1; | 114 | struct fixed31_32 l_pow_m1; |
115 | struct fixed31_32 base, div; | 115 | struct fixed31_32 base, div; |
116 | 116 | ||
117 | 117 | ||
118 | if (dal_fixed31_32_lt(in_x, dal_fixed31_32_zero)) | 118 | if (dc_fixpt_lt(in_x, dc_fixpt_zero)) |
119 | in_x = dal_fixed31_32_zero; | 119 | in_x = dc_fixpt_zero; |
120 | 120 | ||
121 | l_pow_m1 = dal_fixed31_32_pow(in_x, | 121 | l_pow_m1 = dc_fixpt_pow(in_x, |
122 | dal_fixed31_32_div(dal_fixed31_32_one, m2)); | 122 | dc_fixpt_div(dc_fixpt_one, m2)); |
123 | base = dal_fixed31_32_sub(l_pow_m1, c1); | 123 | base = dc_fixpt_sub(l_pow_m1, c1); |
124 | 124 | ||
125 | if (dal_fixed31_32_lt(base, dal_fixed31_32_zero)) | 125 | if (dc_fixpt_lt(base, dc_fixpt_zero)) |
126 | base = dal_fixed31_32_zero; | 126 | base = dc_fixpt_zero; |
127 | 127 | ||
128 | div = dal_fixed31_32_sub(c2, dal_fixed31_32_mul(c3, l_pow_m1)); | 128 | div = dc_fixpt_sub(c2, dc_fixpt_mul(c3, l_pow_m1)); |
129 | 129 | ||
130 | *out_y = dal_fixed31_32_pow(dal_fixed31_32_div(base, div), | 130 | *out_y = dc_fixpt_pow(dc_fixpt_div(base, div), |
131 | dal_fixed31_32_div(dal_fixed31_32_one, m1)); | 131 | dc_fixpt_div(dc_fixpt_one, m1)); |
132 | 132 | ||
133 | } | 133 | } |
134 | /* one-time pre-compute PQ values - only for sdr_white_level 80 */ | 134 | /* one-time pre-compute PQ values - only for sdr_white_level 80 */ |
@@ -138,14 +138,14 @@ void precompute_pq(void) | |||
138 | struct fixed31_32 x; | 138 | struct fixed31_32 x; |
139 | const struct hw_x_point *coord_x = coordinates_x + 32; | 139 | const struct hw_x_point *coord_x = coordinates_x + 32; |
140 | struct fixed31_32 scaling_factor = | 140 | struct fixed31_32 scaling_factor = |
141 | dal_fixed31_32_from_fraction(80, 10000); | 141 | dc_fixpt_from_fraction(80, 10000); |
142 | 142 | ||
143 | /* pow function has problems with arguments too small */ | 143 | /* pow function has problems with arguments too small */ |
144 | for (i = 0; i < 32; i++) | 144 | for (i = 0; i < 32; i++) |
145 | pq_table[i] = dal_fixed31_32_zero; | 145 | pq_table[i] = dc_fixpt_zero; |
146 | 146 | ||
147 | for (i = 32; i <= MAX_HW_POINTS; i++) { | 147 | for (i = 32; i <= MAX_HW_POINTS; i++) { |
148 | x = dal_fixed31_32_mul(coord_x->x, scaling_factor); | 148 | x = dc_fixpt_mul(coord_x->x, scaling_factor); |
149 | compute_pq(x, &pq_table[i]); | 149 | compute_pq(x, &pq_table[i]); |
150 | ++coord_x; | 150 | ++coord_x; |
151 | } | 151 | } |
@@ -158,7 +158,7 @@ void precompute_de_pq(void) | |||
158 | struct fixed31_32 y; | 158 | struct fixed31_32 y; |
159 | uint32_t begin_index, end_index; | 159 | uint32_t begin_index, end_index; |
160 | 160 | ||
161 | struct fixed31_32 scaling_factor = dal_fixed31_32_from_int(125); | 161 | struct fixed31_32 scaling_factor = dc_fixpt_from_int(125); |
162 | 162 | ||
163 | /* X points is 2^-25 to 2^7 | 163 | /* X points is 2^-25 to 2^7 |
164 | * De-gamma X is 2^-12 to 2^0 – we are skipping first -12-(-25) = 13 regions | 164 | * De-gamma X is 2^-12 to 2^0 – we are skipping first -12-(-25) = 13 regions |
@@ -167,11 +167,11 @@ void precompute_de_pq(void) | |||
167 | end_index = begin_index + 12 * NUM_PTS_IN_REGION; | 167 | end_index = begin_index + 12 * NUM_PTS_IN_REGION; |
168 | 168 | ||
169 | for (i = 0; i <= begin_index; i++) | 169 | for (i = 0; i <= begin_index; i++) |
170 | de_pq_table[i] = dal_fixed31_32_zero; | 170 | de_pq_table[i] = dc_fixpt_zero; |
171 | 171 | ||
172 | for (; i <= end_index; i++) { | 172 | for (; i <= end_index; i++) { |
173 | compute_de_pq(coordinates_x[i].x, &y); | 173 | compute_de_pq(coordinates_x[i].x, &y); |
174 | de_pq_table[i] = dal_fixed31_32_mul(y, scaling_factor); | 174 | de_pq_table[i] = dc_fixpt_mul(y, scaling_factor); |
175 | } | 175 | } |
176 | 176 | ||
177 | for (; i <= MAX_HW_POINTS; i++) | 177 | for (; i <= MAX_HW_POINTS; i++) |
@@ -195,15 +195,15 @@ static void build_coefficients(struct gamma_coefficients *coefficients, bool is_ | |||
195 | uint32_t index = is_2_4 == true ? 0:1; | 195 | uint32_t index = is_2_4 == true ? 0:1; |
196 | 196 | ||
197 | do { | 197 | do { |
198 | coefficients->a0[i] = dal_fixed31_32_from_fraction( | 198 | coefficients->a0[i] = dc_fixpt_from_fraction( |
199 | numerator01[index], 10000000); | 199 | numerator01[index], 10000000); |
200 | coefficients->a1[i] = dal_fixed31_32_from_fraction( | 200 | coefficients->a1[i] = dc_fixpt_from_fraction( |
201 | numerator02[index], 1000); | 201 | numerator02[index], 1000); |
202 | coefficients->a2[i] = dal_fixed31_32_from_fraction( | 202 | coefficients->a2[i] = dc_fixpt_from_fraction( |
203 | numerator03[index], 1000); | 203 | numerator03[index], 1000); |
204 | coefficients->a3[i] = dal_fixed31_32_from_fraction( | 204 | coefficients->a3[i] = dc_fixpt_from_fraction( |
205 | numerator04[index], 1000); | 205 | numerator04[index], 1000); |
206 | coefficients->user_gamma[i] = dal_fixed31_32_from_fraction( | 206 | coefficients->user_gamma[i] = dc_fixpt_from_fraction( |
207 | numerator05[index], 1000); | 207 | numerator05[index], 1000); |
208 | 208 | ||
209 | ++i; | 209 | ++i; |
@@ -218,33 +218,33 @@ static struct fixed31_32 translate_from_linear_space( | |||
218 | struct fixed31_32 a3, | 218 | struct fixed31_32 a3, |
219 | struct fixed31_32 gamma) | 219 | struct fixed31_32 gamma) |
220 | { | 220 | { |
221 | const struct fixed31_32 one = dal_fixed31_32_from_int(1); | 221 | const struct fixed31_32 one = dc_fixpt_from_int(1); |
222 | 222 | ||
223 | if (dal_fixed31_32_lt(one, arg)) | 223 | if (dc_fixpt_lt(one, arg)) |
224 | return one; | 224 | return one; |
225 | 225 | ||
226 | if (dal_fixed31_32_le(arg, dal_fixed31_32_neg(a0))) | 226 | if (dc_fixpt_le(arg, dc_fixpt_neg(a0))) |
227 | return dal_fixed31_32_sub( | 227 | return dc_fixpt_sub( |
228 | a2, | 228 | a2, |
229 | dal_fixed31_32_mul( | 229 | dc_fixpt_mul( |
230 | dal_fixed31_32_add( | 230 | dc_fixpt_add( |
231 | one, | 231 | one, |
232 | a3), | 232 | a3), |
233 | dal_fixed31_32_pow( | 233 | dc_fixpt_pow( |
234 | dal_fixed31_32_neg(arg), | 234 | dc_fixpt_neg(arg), |
235 | dal_fixed31_32_recip(gamma)))); | 235 | dc_fixpt_recip(gamma)))); |
236 | else if (dal_fixed31_32_le(a0, arg)) | 236 | else if (dc_fixpt_le(a0, arg)) |
237 | return dal_fixed31_32_sub( | 237 | return dc_fixpt_sub( |
238 | dal_fixed31_32_mul( | 238 | dc_fixpt_mul( |
239 | dal_fixed31_32_add( | 239 | dc_fixpt_add( |
240 | one, | 240 | one, |
241 | a3), | 241 | a3), |
242 | dal_fixed31_32_pow( | 242 | dc_fixpt_pow( |
243 | arg, | 243 | arg, |
244 | dal_fixed31_32_recip(gamma))), | 244 | dc_fixpt_recip(gamma))), |
245 | a2); | 245 | a2); |
246 | else | 246 | else |
247 | return dal_fixed31_32_mul( | 247 | return dc_fixpt_mul( |
248 | arg, | 248 | arg, |
249 | a1); | 249 | a1); |
250 | } | 250 | } |
@@ -259,25 +259,25 @@ static struct fixed31_32 translate_to_linear_space( | |||
259 | { | 259 | { |
260 | struct fixed31_32 linear; | 260 | struct fixed31_32 linear; |
261 | 261 | ||
262 | a0 = dal_fixed31_32_mul(a0, a1); | 262 | a0 = dc_fixpt_mul(a0, a1); |
263 | if (dal_fixed31_32_le(arg, dal_fixed31_32_neg(a0))) | 263 | if (dc_fixpt_le(arg, dc_fixpt_neg(a0))) |
264 | 264 | ||
265 | linear = dal_fixed31_32_neg( | 265 | linear = dc_fixpt_neg( |
266 | dal_fixed31_32_pow( | 266 | dc_fixpt_pow( |
267 | dal_fixed31_32_div( | 267 | dc_fixpt_div( |
268 | dal_fixed31_32_sub(a2, arg), | 268 | dc_fixpt_sub(a2, arg), |
269 | dal_fixed31_32_add( | 269 | dc_fixpt_add( |
270 | dal_fixed31_32_one, a3)), gamma)); | 270 | dc_fixpt_one, a3)), gamma)); |
271 | 271 | ||
272 | else if (dal_fixed31_32_le(dal_fixed31_32_neg(a0), arg) && | 272 | else if (dc_fixpt_le(dc_fixpt_neg(a0), arg) && |
273 | dal_fixed31_32_le(arg, a0)) | 273 | dc_fixpt_le(arg, a0)) |
274 | linear = dal_fixed31_32_div(arg, a1); | 274 | linear = dc_fixpt_div(arg, a1); |
275 | else | 275 | else |
276 | linear = dal_fixed31_32_pow( | 276 | linear = dc_fixpt_pow( |
277 | dal_fixed31_32_div( | 277 | dc_fixpt_div( |
278 | dal_fixed31_32_add(a2, arg), | 278 | dc_fixpt_add(a2, arg), |
279 | dal_fixed31_32_add( | 279 | dc_fixpt_add( |
280 | dal_fixed31_32_one, a3)), gamma); | 280 | dc_fixpt_one, a3)), gamma); |
281 | 281 | ||
282 | return linear; | 282 | return linear; |
283 | } | 283 | } |
@@ -352,8 +352,8 @@ static bool find_software_points( | |||
352 | right = axis_x[max_number - 1].b; | 352 | right = axis_x[max_number - 1].b; |
353 | } | 353 | } |
354 | 354 | ||
355 | if (dal_fixed31_32_le(left, hw_point) && | 355 | if (dc_fixpt_le(left, hw_point) && |
356 | dal_fixed31_32_le(hw_point, right)) { | 356 | dc_fixpt_le(hw_point, right)) { |
357 | *index_to_start = i; | 357 | *index_to_start = i; |
358 | *index_left = i; | 358 | *index_left = i; |
359 | 359 | ||
@@ -366,7 +366,7 @@ static bool find_software_points( | |||
366 | 366 | ||
367 | return true; | 367 | return true; |
368 | } else if ((i == *index_to_start) && | 368 | } else if ((i == *index_to_start) && |
369 | dal_fixed31_32_le(hw_point, left)) { | 369 | dc_fixpt_le(hw_point, left)) { |
370 | *index_to_start = i; | 370 | *index_to_start = i; |
371 | *index_left = i; | 371 | *index_left = i; |
372 | *index_right = i; | 372 | *index_right = i; |
@@ -375,7 +375,7 @@ static bool find_software_points( | |||
375 | 375 | ||
376 | return true; | 376 | return true; |
377 | } else if ((i == max_number - 1) && | 377 | } else if ((i == max_number - 1) && |
378 | dal_fixed31_32_le(right, hw_point)) { | 378 | dc_fixpt_le(right, hw_point)) { |
379 | *index_to_start = i; | 379 | *index_to_start = i; |
380 | *index_left = i; | 380 | *index_left = i; |
381 | *index_right = i; | 381 | *index_right = i; |
@@ -457,17 +457,17 @@ static bool build_custom_gamma_mapping_coefficients_worker( | |||
457 | } | 457 | } |
458 | 458 | ||
459 | if (hw_pos == HW_POINT_POSITION_MIDDLE) | 459 | if (hw_pos == HW_POINT_POSITION_MIDDLE) |
460 | point->coeff = dal_fixed31_32_div( | 460 | point->coeff = dc_fixpt_div( |
461 | dal_fixed31_32_sub( | 461 | dc_fixpt_sub( |
462 | coord_x, | 462 | coord_x, |
463 | left_pos), | 463 | left_pos), |
464 | dal_fixed31_32_sub( | 464 | dc_fixpt_sub( |
465 | right_pos, | 465 | right_pos, |
466 | left_pos)); | 466 | left_pos)); |
467 | else if (hw_pos == HW_POINT_POSITION_LEFT) | 467 | else if (hw_pos == HW_POINT_POSITION_LEFT) |
468 | point->coeff = dal_fixed31_32_zero; | 468 | point->coeff = dc_fixpt_zero; |
469 | else if (hw_pos == HW_POINT_POSITION_RIGHT) | 469 | else if (hw_pos == HW_POINT_POSITION_RIGHT) |
470 | point->coeff = dal_fixed31_32_from_int(2); | 470 | point->coeff = dc_fixpt_from_int(2); |
471 | else { | 471 | else { |
472 | BREAK_TO_DEBUGGER(); | 472 | BREAK_TO_DEBUGGER(); |
473 | return false; | 473 | return false; |
@@ -502,45 +502,45 @@ static struct fixed31_32 calculate_mapped_value( | |||
502 | 502 | ||
503 | if ((point->left_index < 0) || (point->left_index > max_index)) { | 503 | if ((point->left_index < 0) || (point->left_index > max_index)) { |
504 | BREAK_TO_DEBUGGER(); | 504 | BREAK_TO_DEBUGGER(); |
505 | return dal_fixed31_32_zero; | 505 | return dc_fixpt_zero; |
506 | } | 506 | } |
507 | 507 | ||
508 | if ((point->right_index < 0) || (point->right_index > max_index)) { | 508 | if ((point->right_index < 0) || (point->right_index > max_index)) { |
509 | BREAK_TO_DEBUGGER(); | 509 | BREAK_TO_DEBUGGER(); |
510 | return dal_fixed31_32_zero; | 510 | return dc_fixpt_zero; |
511 | } | 511 | } |
512 | 512 | ||
513 | if (point->pos == HW_POINT_POSITION_MIDDLE) | 513 | if (point->pos == HW_POINT_POSITION_MIDDLE) |
514 | if (channel == CHANNEL_NAME_RED) | 514 | if (channel == CHANNEL_NAME_RED) |
515 | result = dal_fixed31_32_add( | 515 | result = dc_fixpt_add( |
516 | dal_fixed31_32_mul( | 516 | dc_fixpt_mul( |
517 | point->coeff, | 517 | point->coeff, |
518 | dal_fixed31_32_sub( | 518 | dc_fixpt_sub( |
519 | rgb[point->right_index].r, | 519 | rgb[point->right_index].r, |
520 | rgb[point->left_index].r)), | 520 | rgb[point->left_index].r)), |
521 | rgb[point->left_index].r); | 521 | rgb[point->left_index].r); |
522 | else if (channel == CHANNEL_NAME_GREEN) | 522 | else if (channel == CHANNEL_NAME_GREEN) |
523 | result = dal_fixed31_32_add( | 523 | result = dc_fixpt_add( |
524 | dal_fixed31_32_mul( | 524 | dc_fixpt_mul( |
525 | point->coeff, | 525 | point->coeff, |
526 | dal_fixed31_32_sub( | 526 | dc_fixpt_sub( |
527 | rgb[point->right_index].g, | 527 | rgb[point->right_index].g, |
528 | rgb[point->left_index].g)), | 528 | rgb[point->left_index].g)), |
529 | rgb[point->left_index].g); | 529 | rgb[point->left_index].g); |
530 | else | 530 | else |
531 | result = dal_fixed31_32_add( | 531 | result = dc_fixpt_add( |
532 | dal_fixed31_32_mul( | 532 | dc_fixpt_mul( |
533 | point->coeff, | 533 | point->coeff, |
534 | dal_fixed31_32_sub( | 534 | dc_fixpt_sub( |
535 | rgb[point->right_index].b, | 535 | rgb[point->right_index].b, |
536 | rgb[point->left_index].b)), | 536 | rgb[point->left_index].b)), |
537 | rgb[point->left_index].b); | 537 | rgb[point->left_index].b); |
538 | else if (point->pos == HW_POINT_POSITION_LEFT) { | 538 | else if (point->pos == HW_POINT_POSITION_LEFT) { |
539 | BREAK_TO_DEBUGGER(); | 539 | BREAK_TO_DEBUGGER(); |
540 | result = dal_fixed31_32_zero; | 540 | result = dc_fixpt_zero; |
541 | } else { | 541 | } else { |
542 | BREAK_TO_DEBUGGER(); | 542 | BREAK_TO_DEBUGGER(); |
543 | result = dal_fixed31_32_one; | 543 | result = dc_fixpt_one; |
544 | } | 544 | } |
545 | 545 | ||
546 | return result; | 546 | return result; |
@@ -558,7 +558,7 @@ static void build_pq(struct pwl_float_data_ex *rgb_regamma, | |||
558 | struct fixed31_32 x; | 558 | struct fixed31_32 x; |
559 | struct fixed31_32 output; | 559 | struct fixed31_32 output; |
560 | struct fixed31_32 scaling_factor = | 560 | struct fixed31_32 scaling_factor = |
561 | dal_fixed31_32_from_fraction(sdr_white_level, 10000); | 561 | dc_fixpt_from_fraction(sdr_white_level, 10000); |
562 | 562 | ||
563 | if (!pq_initialized && sdr_white_level == 80) { | 563 | if (!pq_initialized && sdr_white_level == 80) { |
564 | precompute_pq(); | 564 | precompute_pq(); |
@@ -579,15 +579,15 @@ static void build_pq(struct pwl_float_data_ex *rgb_regamma, | |||
579 | if (sdr_white_level == 80) { | 579 | if (sdr_white_level == 80) { |
580 | output = pq_table[i]; | 580 | output = pq_table[i]; |
581 | } else { | 581 | } else { |
582 | x = dal_fixed31_32_mul(coord_x->x, scaling_factor); | 582 | x = dc_fixpt_mul(coord_x->x, scaling_factor); |
583 | compute_pq(x, &output); | 583 | compute_pq(x, &output); |
584 | } | 584 | } |
585 | 585 | ||
586 | /* should really not happen? */ | 586 | /* should really not happen? */ |
587 | if (dal_fixed31_32_lt(output, dal_fixed31_32_zero)) | 587 | if (dc_fixpt_lt(output, dc_fixpt_zero)) |
588 | output = dal_fixed31_32_zero; | 588 | output = dc_fixpt_zero; |
589 | else if (dal_fixed31_32_lt(dal_fixed31_32_one, output)) | 589 | else if (dc_fixpt_lt(dc_fixpt_one, output)) |
590 | output = dal_fixed31_32_one; | 590 | output = dc_fixpt_one; |
591 | 591 | ||
592 | rgb->r = output; | 592 | rgb->r = output; |
593 | rgb->g = output; | 593 | rgb->g = output; |
@@ -605,7 +605,7 @@ static void build_de_pq(struct pwl_float_data_ex *de_pq, | |||
605 | uint32_t i; | 605 | uint32_t i; |
606 | struct fixed31_32 output; | 606 | struct fixed31_32 output; |
607 | 607 | ||
608 | struct fixed31_32 scaling_factor = dal_fixed31_32_from_int(125); | 608 | struct fixed31_32 scaling_factor = dc_fixpt_from_int(125); |
609 | 609 | ||
610 | if (!de_pq_initialized) { | 610 | if (!de_pq_initialized) { |
611 | precompute_de_pq(); | 611 | precompute_de_pq(); |
@@ -616,9 +616,9 @@ static void build_de_pq(struct pwl_float_data_ex *de_pq, | |||
616 | for (i = 0; i <= hw_points_num; i++) { | 616 | for (i = 0; i <= hw_points_num; i++) { |
617 | output = de_pq_table[i]; | 617 | output = de_pq_table[i]; |
618 | /* should really not happen? */ | 618 | /* should really not happen? */ |
619 | if (dal_fixed31_32_lt(output, dal_fixed31_32_zero)) | 619 | if (dc_fixpt_lt(output, dc_fixpt_zero)) |
620 | output = dal_fixed31_32_zero; | 620 | output = dc_fixpt_zero; |
621 | else if (dal_fixed31_32_lt(scaling_factor, output)) | 621 | else if (dc_fixpt_lt(scaling_factor, output)) |
622 | output = scaling_factor; | 622 | output = scaling_factor; |
623 | de_pq[i].r = output; | 623 | de_pq[i].r = output; |
624 | de_pq[i].g = output; | 624 | de_pq[i].g = output; |
@@ -670,9 +670,9 @@ static void build_degamma(struct pwl_float_data_ex *curve, | |||
670 | end_index = begin_index + 12 * NUM_PTS_IN_REGION; | 670 | end_index = begin_index + 12 * NUM_PTS_IN_REGION; |
671 | 671 | ||
672 | while (i != begin_index) { | 672 | while (i != begin_index) { |
673 | curve[i].r = dal_fixed31_32_zero; | 673 | curve[i].r = dc_fixpt_zero; |
674 | curve[i].g = dal_fixed31_32_zero; | 674 | curve[i].g = dc_fixpt_zero; |
675 | curve[i].b = dal_fixed31_32_zero; | 675 | curve[i].b = dc_fixpt_zero; |
676 | i++; | 676 | i++; |
677 | } | 677 | } |
678 | 678 | ||
@@ -684,9 +684,9 @@ static void build_degamma(struct pwl_float_data_ex *curve, | |||
684 | i++; | 684 | i++; |
685 | } | 685 | } |
686 | while (i != hw_points_num + 1) { | 686 | while (i != hw_points_num + 1) { |
687 | curve[i].r = dal_fixed31_32_one; | 687 | curve[i].r = dc_fixpt_one; |
688 | curve[i].g = dal_fixed31_32_one; | 688 | curve[i].g = dc_fixpt_one; |
689 | curve[i].b = dal_fixed31_32_one; | 689 | curve[i].b = dc_fixpt_one; |
690 | i++; | 690 | i++; |
691 | } | 691 | } |
692 | } | 692 | } |
@@ -695,8 +695,8 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb, | |||
695 | const struct dc_gamma *ramp, | 695 | const struct dc_gamma *ramp, |
696 | struct dividers dividers) | 696 | struct dividers dividers) |
697 | { | 697 | { |
698 | const struct fixed31_32 max_driver = dal_fixed31_32_from_int(0xFFFF); | 698 | const struct fixed31_32 max_driver = dc_fixpt_from_int(0xFFFF); |
699 | const struct fixed31_32 max_os = dal_fixed31_32_from_int(0xFF00); | 699 | const struct fixed31_32 max_os = dc_fixpt_from_int(0xFF00); |
700 | struct fixed31_32 scaler = max_os; | 700 | struct fixed31_32 scaler = max_os; |
701 | uint32_t i; | 701 | uint32_t i; |
702 | struct pwl_float_data *rgb = pwl_rgb; | 702 | struct pwl_float_data *rgb = pwl_rgb; |
@@ -705,9 +705,9 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb, | |||
705 | i = 0; | 705 | i = 0; |
706 | 706 | ||
707 | do { | 707 | do { |
708 | if (dal_fixed31_32_lt(max_os, ramp->entries.red[i]) || | 708 | if (dc_fixpt_lt(max_os, ramp->entries.red[i]) || |
709 | dal_fixed31_32_lt(max_os, ramp->entries.green[i]) || | 709 | dc_fixpt_lt(max_os, ramp->entries.green[i]) || |
710 | dal_fixed31_32_lt(max_os, ramp->entries.blue[i])) { | 710 | dc_fixpt_lt(max_os, ramp->entries.blue[i])) { |
711 | scaler = max_driver; | 711 | scaler = max_driver; |
712 | break; | 712 | break; |
713 | } | 713 | } |
@@ -717,40 +717,40 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb, | |||
717 | i = 0; | 717 | i = 0; |
718 | 718 | ||
719 | do { | 719 | do { |
720 | rgb->r = dal_fixed31_32_div( | 720 | rgb->r = dc_fixpt_div( |
721 | ramp->entries.red[i], scaler); | 721 | ramp->entries.red[i], scaler); |
722 | rgb->g = dal_fixed31_32_div( | 722 | rgb->g = dc_fixpt_div( |
723 | ramp->entries.green[i], scaler); | 723 | ramp->entries.green[i], scaler); |
724 | rgb->b = dal_fixed31_32_div( | 724 | rgb->b = dc_fixpt_div( |
725 | ramp->entries.blue[i], scaler); | 725 | ramp->entries.blue[i], scaler); |
726 | 726 | ||
727 | ++rgb; | 727 | ++rgb; |
728 | ++i; | 728 | ++i; |
729 | } while (i != ramp->num_entries); | 729 | } while (i != ramp->num_entries); |
730 | 730 | ||
731 | rgb->r = dal_fixed31_32_mul(rgb_last->r, | 731 | rgb->r = dc_fixpt_mul(rgb_last->r, |
732 | dividers.divider1); | 732 | dividers.divider1); |
733 | rgb->g = dal_fixed31_32_mul(rgb_last->g, | 733 | rgb->g = dc_fixpt_mul(rgb_last->g, |
734 | dividers.divider1); | 734 | dividers.divider1); |
735 | rgb->b = dal_fixed31_32_mul(rgb_last->b, | 735 | rgb->b = dc_fixpt_mul(rgb_last->b, |
736 | dividers.divider1); | 736 | dividers.divider1); |
737 | 737 | ||
738 | ++rgb; | 738 | ++rgb; |
739 | 739 | ||
740 | rgb->r = dal_fixed31_32_mul(rgb_last->r, | 740 | rgb->r = dc_fixpt_mul(rgb_last->r, |
741 | dividers.divider2); | 741 | dividers.divider2); |
742 | rgb->g = dal_fixed31_32_mul(rgb_last->g, | 742 | rgb->g = dc_fixpt_mul(rgb_last->g, |
743 | dividers.divider2); | 743 | dividers.divider2); |
744 | rgb->b = dal_fixed31_32_mul(rgb_last->b, | 744 | rgb->b = dc_fixpt_mul(rgb_last->b, |
745 | dividers.divider2); | 745 | dividers.divider2); |
746 | 746 | ||
747 | ++rgb; | 747 | ++rgb; |
748 | 748 | ||
749 | rgb->r = dal_fixed31_32_mul(rgb_last->r, | 749 | rgb->r = dc_fixpt_mul(rgb_last->r, |
750 | dividers.divider3); | 750 | dividers.divider3); |
751 | rgb->g = dal_fixed31_32_mul(rgb_last->g, | 751 | rgb->g = dc_fixpt_mul(rgb_last->g, |
752 | dividers.divider3); | 752 | dividers.divider3); |
753 | rgb->b = dal_fixed31_32_mul(rgb_last->b, | 753 | rgb->b = dc_fixpt_mul(rgb_last->b, |
754 | dividers.divider3); | 754 | dividers.divider3); |
755 | } | 755 | } |
756 | 756 | ||
@@ -759,62 +759,62 @@ static void scale_gamma_dx(struct pwl_float_data *pwl_rgb, | |||
759 | struct dividers dividers) | 759 | struct dividers dividers) |
760 | { | 760 | { |
761 | uint32_t i; | 761 | uint32_t i; |
762 | struct fixed31_32 min = dal_fixed31_32_zero; | 762 | struct fixed31_32 min = dc_fixpt_zero; |
763 | struct fixed31_32 max = dal_fixed31_32_one; | 763 | struct fixed31_32 max = dc_fixpt_one; |
764 | 764 | ||
765 | struct fixed31_32 delta = dal_fixed31_32_zero; | 765 | struct fixed31_32 delta = dc_fixpt_zero; |
766 | struct fixed31_32 offset = dal_fixed31_32_zero; | 766 | struct fixed31_32 offset = dc_fixpt_zero; |
767 | 767 | ||
768 | for (i = 0 ; i < ramp->num_entries; i++) { | 768 | for (i = 0 ; i < ramp->num_entries; i++) { |
769 | if (dal_fixed31_32_lt(ramp->entries.red[i], min)) | 769 | if (dc_fixpt_lt(ramp->entries.red[i], min)) |
770 | min = ramp->entries.red[i]; | 770 | min = ramp->entries.red[i]; |
771 | 771 | ||
772 | if (dal_fixed31_32_lt(ramp->entries.green[i], min)) | 772 | if (dc_fixpt_lt(ramp->entries.green[i], min)) |
773 | min = ramp->entries.green[i]; | 773 | min = ramp->entries.green[i]; |
774 | 774 | ||
775 | if (dal_fixed31_32_lt(ramp->entries.blue[i], min)) | 775 | if (dc_fixpt_lt(ramp->entries.blue[i], min)) |
776 | min = ramp->entries.blue[i]; | 776 | min = ramp->entries.blue[i]; |
777 | 777 | ||
778 | if (dal_fixed31_32_lt(max, ramp->entries.red[i])) | 778 | if (dc_fixpt_lt(max, ramp->entries.red[i])) |
779 | max = ramp->entries.red[i]; | 779 | max = ramp->entries.red[i]; |
780 | 780 | ||
781 | if (dal_fixed31_32_lt(max, ramp->entries.green[i])) | 781 | if (dc_fixpt_lt(max, ramp->entries.green[i])) |
782 | max = ramp->entries.green[i]; | 782 | max = ramp->entries.green[i]; |
783 | 783 | ||
784 | if (dal_fixed31_32_lt(max, ramp->entries.blue[i])) | 784 | if (dc_fixpt_lt(max, ramp->entries.blue[i])) |
785 | max = ramp->entries.blue[i]; | 785 | max = ramp->entries.blue[i]; |
786 | } | 786 | } |
787 | 787 | ||
788 | if (dal_fixed31_32_lt(min, dal_fixed31_32_zero)) | 788 | if (dc_fixpt_lt(min, dc_fixpt_zero)) |
789 | delta = dal_fixed31_32_neg(min); | 789 | delta = dc_fixpt_neg(min); |
790 | 790 | ||
791 | offset = dal_fixed31_32_add(min, max); | 791 | offset = dc_fixpt_add(min, max); |
792 | 792 | ||
793 | for (i = 0 ; i < ramp->num_entries; i++) { | 793 | for (i = 0 ; i < ramp->num_entries; i++) { |
794 | pwl_rgb[i].r = dal_fixed31_32_div( | 794 | pwl_rgb[i].r = dc_fixpt_div( |
795 | dal_fixed31_32_add( | 795 | dc_fixpt_add( |
796 | ramp->entries.red[i], delta), offset); | 796 | ramp->entries.red[i], delta), offset); |
797 | pwl_rgb[i].g = dal_fixed31_32_div( | 797 | pwl_rgb[i].g = dc_fixpt_div( |
798 | dal_fixed31_32_add( | 798 | dc_fixpt_add( |
799 | ramp->entries.green[i], delta), offset); | 799 | ramp->entries.green[i], delta), offset); |
800 | pwl_rgb[i].b = dal_fixed31_32_div( | 800 | pwl_rgb[i].b = dc_fixpt_div( |
801 | dal_fixed31_32_add( | 801 | dc_fixpt_add( |
802 | ramp->entries.blue[i], delta), offset); | 802 | ramp->entries.blue[i], delta), offset); |
803 | 803 | ||
804 | } | 804 | } |
805 | 805 | ||
806 | pwl_rgb[i].r = dal_fixed31_32_sub(dal_fixed31_32_mul_int( | 806 | pwl_rgb[i].r = dc_fixpt_sub(dc_fixpt_mul_int( |
807 | pwl_rgb[i-1].r, 2), pwl_rgb[i-2].r); | 807 | pwl_rgb[i-1].r, 2), pwl_rgb[i-2].r); |
808 | pwl_rgb[i].g = dal_fixed31_32_sub(dal_fixed31_32_mul_int( | 808 | pwl_rgb[i].g = dc_fixpt_sub(dc_fixpt_mul_int( |
809 | pwl_rgb[i-1].g, 2), pwl_rgb[i-2].g); | 809 | pwl_rgb[i-1].g, 2), pwl_rgb[i-2].g); |
810 | pwl_rgb[i].b = dal_fixed31_32_sub(dal_fixed31_32_mul_int( | 810 | pwl_rgb[i].b = dc_fixpt_sub(dc_fixpt_mul_int( |
811 | pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b); | 811 | pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b); |
812 | ++i; | 812 | ++i; |
813 | pwl_rgb[i].r = dal_fixed31_32_sub(dal_fixed31_32_mul_int( | 813 | pwl_rgb[i].r = dc_fixpt_sub(dc_fixpt_mul_int( |
814 | pwl_rgb[i-1].r, 2), pwl_rgb[i-2].r); | 814 | pwl_rgb[i-1].r, 2), pwl_rgb[i-2].r); |
815 | pwl_rgb[i].g = dal_fixed31_32_sub(dal_fixed31_32_mul_int( | 815 | pwl_rgb[i].g = dc_fixpt_sub(dc_fixpt_mul_int( |
816 | pwl_rgb[i-1].g, 2), pwl_rgb[i-2].g); | 816 | pwl_rgb[i-1].g, 2), pwl_rgb[i-2].g); |
817 | pwl_rgb[i].b = dal_fixed31_32_sub(dal_fixed31_32_mul_int( | 817 | pwl_rgb[i].b = dc_fixpt_sub(dc_fixpt_mul_int( |
818 | pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b); | 818 | pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b); |
819 | } | 819 | } |
820 | 820 | ||
@@ -846,40 +846,40 @@ static void scale_user_regamma_ramp(struct pwl_float_data *pwl_rgb, | |||
846 | 846 | ||
847 | i = 0; | 847 | i = 0; |
848 | do { | 848 | do { |
849 | rgb->r = dal_fixed31_32_from_fraction( | 849 | rgb->r = dc_fixpt_from_fraction( |
850 | ramp->gamma[i], scaler); | 850 | ramp->gamma[i], scaler); |
851 | rgb->g = dal_fixed31_32_from_fraction( | 851 | rgb->g = dc_fixpt_from_fraction( |
852 | ramp->gamma[i + 256], scaler); | 852 | ramp->gamma[i + 256], scaler); |
853 | rgb->b = dal_fixed31_32_from_fraction( | 853 | rgb->b = dc_fixpt_from_fraction( |
854 | ramp->gamma[i + 512], scaler); | 854 | ramp->gamma[i + 512], scaler); |
855 | 855 | ||
856 | ++rgb; | 856 | ++rgb; |
857 | ++i; | 857 | ++i; |
858 | } while (i != GAMMA_RGB_256_ENTRIES); | 858 | } while (i != GAMMA_RGB_256_ENTRIES); |
859 | 859 | ||
860 | rgb->r = dal_fixed31_32_mul(rgb_last->r, | 860 | rgb->r = dc_fixpt_mul(rgb_last->r, |
861 | dividers.divider1); | 861 | dividers.divider1); |
862 | rgb->g = dal_fixed31_32_mul(rgb_last->g, | 862 | rgb->g = dc_fixpt_mul(rgb_last->g, |
863 | dividers.divider1); | 863 | dividers.divider1); |
864 | rgb->b = dal_fixed31_32_mul(rgb_last->b, | 864 | rgb->b = dc_fixpt_mul(rgb_last->b, |
865 | dividers.divider1); | 865 | dividers.divider1); |
866 | 866 | ||
867 | ++rgb; | 867 | ++rgb; |
868 | 868 | ||
869 | rgb->r = dal_fixed31_32_mul(rgb_last->r, | 869 | rgb->r = dc_fixpt_mul(rgb_last->r, |
870 | dividers.divider2); | 870 | dividers.divider2); |
871 | rgb->g = dal_fixed31_32_mul(rgb_last->g, | 871 | rgb->g = dc_fixpt_mul(rgb_last->g, |
872 | dividers.divider2); | 872 | dividers.divider2); |
873 | rgb->b = dal_fixed31_32_mul(rgb_last->b, | 873 | rgb->b = dc_fixpt_mul(rgb_last->b, |
874 | dividers.divider2); | 874 | dividers.divider2); |
875 | 875 | ||
876 | ++rgb; | 876 | ++rgb; |
877 | 877 | ||
878 | rgb->r = dal_fixed31_32_mul(rgb_last->r, | 878 | rgb->r = dc_fixpt_mul(rgb_last->r, |
879 | dividers.divider3); | 879 | dividers.divider3); |
880 | rgb->g = dal_fixed31_32_mul(rgb_last->g, | 880 | rgb->g = dc_fixpt_mul(rgb_last->g, |
881 | dividers.divider3); | 881 | dividers.divider3); |
882 | rgb->b = dal_fixed31_32_mul(rgb_last->b, | 882 | rgb->b = dc_fixpt_mul(rgb_last->b, |
883 | dividers.divider3); | 883 | dividers.divider3); |
884 | } | 884 | } |
885 | 885 | ||
@@ -913,7 +913,7 @@ static void apply_lut_1d( | |||
913 | struct fixed31_32 lut2; | 913 | struct fixed31_32 lut2; |
914 | const int max_lut_index = 4095; | 914 | const int max_lut_index = 4095; |
915 | const struct fixed31_32 max_lut_index_f = | 915 | const struct fixed31_32 max_lut_index_f = |
916 | dal_fixed31_32_from_int_nonconst(max_lut_index); | 916 | dc_fixpt_from_int(max_lut_index); |
917 | int32_t index = 0, index_next = 0; | 917 | int32_t index = 0, index_next = 0; |
918 | struct fixed31_32 index_f; | 918 | struct fixed31_32 index_f; |
919 | struct fixed31_32 delta_lut; | 919 | struct fixed31_32 delta_lut; |
@@ -931,10 +931,10 @@ static void apply_lut_1d( | |||
931 | else | 931 | else |
932 | regamma_y = &tf_pts->blue[i]; | 932 | regamma_y = &tf_pts->blue[i]; |
933 | 933 | ||
934 | norm_y = dal_fixed31_32_mul(max_lut_index_f, | 934 | norm_y = dc_fixpt_mul(max_lut_index_f, |
935 | *regamma_y); | 935 | *regamma_y); |
936 | index = dal_fixed31_32_floor(norm_y); | 936 | index = dc_fixpt_floor(norm_y); |
937 | index_f = dal_fixed31_32_from_int_nonconst(index); | 937 | index_f = dc_fixpt_from_int(index); |
938 | 938 | ||
939 | if (index < 0 || index > max_lut_index) | 939 | if (index < 0 || index > max_lut_index) |
940 | continue; | 940 | continue; |
@@ -953,11 +953,11 @@ static void apply_lut_1d( | |||
953 | } | 953 | } |
954 | 954 | ||
955 | // we have everything now, so interpolate | 955 | // we have everything now, so interpolate |
956 | delta_lut = dal_fixed31_32_sub(lut2, lut1); | 956 | delta_lut = dc_fixpt_sub(lut2, lut1); |
957 | delta_index = dal_fixed31_32_sub(norm_y, index_f); | 957 | delta_index = dc_fixpt_sub(norm_y, index_f); |
958 | 958 | ||
959 | *regamma_y = dal_fixed31_32_add(lut1, | 959 | *regamma_y = dc_fixpt_add(lut1, |
960 | dal_fixed31_32_mul(delta_index, delta_lut)); | 960 | dc_fixpt_mul(delta_index, delta_lut)); |
961 | } | 961 | } |
962 | } | 962 | } |
963 | } | 963 | } |
@@ -973,7 +973,7 @@ static void build_evenly_distributed_points( | |||
973 | uint32_t i = 0; | 973 | uint32_t i = 0; |
974 | 974 | ||
975 | do { | 975 | do { |
976 | struct fixed31_32 value = dal_fixed31_32_from_fraction(i, | 976 | struct fixed31_32 value = dc_fixpt_from_fraction(i, |
977 | numberof_points - 1); | 977 | numberof_points - 1); |
978 | 978 | ||
979 | p->r = value; | 979 | p->r = value; |
@@ -984,21 +984,21 @@ static void build_evenly_distributed_points( | |||
984 | ++i; | 984 | ++i; |
985 | } while (i != numberof_points); | 985 | } while (i != numberof_points); |
986 | 986 | ||
987 | p->r = dal_fixed31_32_div(p_last->r, dividers.divider1); | 987 | p->r = dc_fixpt_div(p_last->r, dividers.divider1); |
988 | p->g = dal_fixed31_32_div(p_last->g, dividers.divider1); | 988 | p->g = dc_fixpt_div(p_last->g, dividers.divider1); |
989 | p->b = dal_fixed31_32_div(p_last->b, dividers.divider1); | 989 | p->b = dc_fixpt_div(p_last->b, dividers.divider1); |
990 | 990 | ||
991 | ++p; | 991 | ++p; |
992 | 992 | ||
993 | p->r = dal_fixed31_32_div(p_last->r, dividers.divider2); | 993 | p->r = dc_fixpt_div(p_last->r, dividers.divider2); |
994 | p->g = dal_fixed31_32_div(p_last->g, dividers.divider2); | 994 | p->g = dc_fixpt_div(p_last->g, dividers.divider2); |
995 | p->b = dal_fixed31_32_div(p_last->b, dividers.divider2); | 995 | p->b = dc_fixpt_div(p_last->b, dividers.divider2); |
996 | 996 | ||
997 | ++p; | 997 | ++p; |
998 | 998 | ||
999 | p->r = dal_fixed31_32_div(p_last->r, dividers.divider3); | 999 | p->r = dc_fixpt_div(p_last->r, dividers.divider3); |
1000 | p->g = dal_fixed31_32_div(p_last->g, dividers.divider3); | 1000 | p->g = dc_fixpt_div(p_last->g, dividers.divider3); |
1001 | p->b = dal_fixed31_32_div(p_last->b, dividers.divider3); | 1001 | p->b = dc_fixpt_div(p_last->b, dividers.divider3); |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | static inline void copy_rgb_regamma_to_coordinates_x( | 1004 | static inline void copy_rgb_regamma_to_coordinates_x( |
@@ -1094,7 +1094,7 @@ static void interpolate_user_regamma(uint32_t hw_points_num, | |||
1094 | struct fixed31_32 *tf_point; | 1094 | struct fixed31_32 *tf_point; |
1095 | struct fixed31_32 hw_x; | 1095 | struct fixed31_32 hw_x; |
1096 | struct fixed31_32 norm_factor = | 1096 | struct fixed31_32 norm_factor = |
1097 | dal_fixed31_32_from_int_nonconst(255); | 1097 | dc_fixpt_from_int(255); |
1098 | struct fixed31_32 norm_x; | 1098 | struct fixed31_32 norm_x; |
1099 | struct fixed31_32 index_f; | 1099 | struct fixed31_32 index_f; |
1100 | struct fixed31_32 lut1; | 1100 | struct fixed31_32 lut1; |
@@ -1105,9 +1105,9 @@ static void interpolate_user_regamma(uint32_t hw_points_num, | |||
1105 | i = 0; | 1105 | i = 0; |
1106 | /* fixed_pt library has problems handling too small values */ | 1106 | /* fixed_pt library has problems handling too small values */ |
1107 | while (i != 32) { | 1107 | while (i != 32) { |
1108 | tf_pts->red[i] = dal_fixed31_32_zero; | 1108 | tf_pts->red[i] = dc_fixpt_zero; |
1109 | tf_pts->green[i] = dal_fixed31_32_zero; | 1109 | tf_pts->green[i] = dc_fixpt_zero; |
1110 | tf_pts->blue[i] = dal_fixed31_32_zero; | 1110 | tf_pts->blue[i] = dc_fixpt_zero; |
1111 | ++i; | 1111 | ++i; |
1112 | } | 1112 | } |
1113 | while (i <= hw_points_num + 1) { | 1113 | while (i <= hw_points_num + 1) { |
@@ -1129,12 +1129,12 @@ static void interpolate_user_regamma(uint32_t hw_points_num, | |||
1129 | } else | 1129 | } else |
1130 | hw_x = coordinates_x[i].x; | 1130 | hw_x = coordinates_x[i].x; |
1131 | 1131 | ||
1132 | norm_x = dal_fixed31_32_mul(norm_factor, hw_x); | 1132 | norm_x = dc_fixpt_mul(norm_factor, hw_x); |
1133 | index = dal_fixed31_32_floor(norm_x); | 1133 | index = dc_fixpt_floor(norm_x); |
1134 | if (index < 0 || index > 255) | 1134 | if (index < 0 || index > 255) |
1135 | continue; | 1135 | continue; |
1136 | 1136 | ||
1137 | index_f = dal_fixed31_32_from_int_nonconst(index); | 1137 | index_f = dc_fixpt_from_int(index); |
1138 | index_next = (index == 255) ? index : index + 1; | 1138 | index_next = (index == 255) ? index : index + 1; |
1139 | 1139 | ||
1140 | if (color == 0) { | 1140 | if (color == 0) { |
@@ -1149,11 +1149,11 @@ static void interpolate_user_regamma(uint32_t hw_points_num, | |||
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | // we have everything now, so interpolate | 1151 | // we have everything now, so interpolate |
1152 | delta_lut = dal_fixed31_32_sub(lut2, lut1); | 1152 | delta_lut = dc_fixpt_sub(lut2, lut1); |
1153 | delta_index = dal_fixed31_32_sub(norm_x, index_f); | 1153 | delta_index = dc_fixpt_sub(norm_x, index_f); |
1154 | 1154 | ||
1155 | *tf_point = dal_fixed31_32_add(lut1, | 1155 | *tf_point = dc_fixpt_add(lut1, |
1156 | dal_fixed31_32_mul(delta_index, delta_lut)); | 1156 | dc_fixpt_mul(delta_index, delta_lut)); |
1157 | } | 1157 | } |
1158 | ++i; | 1158 | ++i; |
1159 | } | 1159 | } |
@@ -1168,15 +1168,15 @@ static void build_new_custom_resulted_curve( | |||
1168 | i = 0; | 1168 | i = 0; |
1169 | 1169 | ||
1170 | while (i != hw_points_num + 1) { | 1170 | while (i != hw_points_num + 1) { |
1171 | tf_pts->red[i] = dal_fixed31_32_clamp( | 1171 | tf_pts->red[i] = dc_fixpt_clamp( |
1172 | tf_pts->red[i], dal_fixed31_32_zero, | 1172 | tf_pts->red[i], dc_fixpt_zero, |
1173 | dal_fixed31_32_one); | 1173 | dc_fixpt_one); |
1174 | tf_pts->green[i] = dal_fixed31_32_clamp( | 1174 | tf_pts->green[i] = dc_fixpt_clamp( |
1175 | tf_pts->green[i], dal_fixed31_32_zero, | 1175 | tf_pts->green[i], dc_fixpt_zero, |
1176 | dal_fixed31_32_one); | 1176 | dc_fixpt_one); |
1177 | tf_pts->blue[i] = dal_fixed31_32_clamp( | 1177 | tf_pts->blue[i] = dc_fixpt_clamp( |
1178 | tf_pts->blue[i], dal_fixed31_32_zero, | 1178 | tf_pts->blue[i], dc_fixpt_zero, |
1179 | dal_fixed31_32_one); | 1179 | dc_fixpt_one); |
1180 | 1180 | ||
1181 | ++i; | 1181 | ++i; |
1182 | } | 1182 | } |
@@ -1290,9 +1290,9 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, | |||
1290 | if (!coeff) | 1290 | if (!coeff) |
1291 | goto coeff_alloc_fail; | 1291 | goto coeff_alloc_fail; |
1292 | 1292 | ||
1293 | dividers.divider1 = dal_fixed31_32_from_fraction(3, 2); | 1293 | dividers.divider1 = dc_fixpt_from_fraction(3, 2); |
1294 | dividers.divider2 = dal_fixed31_32_from_int(2); | 1294 | dividers.divider2 = dc_fixpt_from_int(2); |
1295 | dividers.divider3 = dal_fixed31_32_from_fraction(5, 2); | 1295 | dividers.divider3 = dc_fixpt_from_fraction(5, 2); |
1296 | 1296 | ||
1297 | tf = output_tf->tf; | 1297 | tf = output_tf->tf; |
1298 | 1298 | ||
@@ -1357,15 +1357,15 @@ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf, | |||
1357 | uint32_t i = 0; | 1357 | uint32_t i = 0; |
1358 | 1358 | ||
1359 | do { | 1359 | do { |
1360 | coeff.a0[i] = dal_fixed31_32_from_fraction( | 1360 | coeff.a0[i] = dc_fixpt_from_fraction( |
1361 | regamma->coeff.A0[i], 10000000); | 1361 | regamma->coeff.A0[i], 10000000); |
1362 | coeff.a1[i] = dal_fixed31_32_from_fraction( | 1362 | coeff.a1[i] = dc_fixpt_from_fraction( |
1363 | regamma->coeff.A1[i], 1000); | 1363 | regamma->coeff.A1[i], 1000); |
1364 | coeff.a2[i] = dal_fixed31_32_from_fraction( | 1364 | coeff.a2[i] = dc_fixpt_from_fraction( |
1365 | regamma->coeff.A2[i], 1000); | 1365 | regamma->coeff.A2[i], 1000); |
1366 | coeff.a3[i] = dal_fixed31_32_from_fraction( | 1366 | coeff.a3[i] = dc_fixpt_from_fraction( |
1367 | regamma->coeff.A3[i], 1000); | 1367 | regamma->coeff.A3[i], 1000); |
1368 | coeff.user_gamma[i] = dal_fixed31_32_from_fraction( | 1368 | coeff.user_gamma[i] = dc_fixpt_from_fraction( |
1369 | regamma->coeff.gamma[i], 1000); | 1369 | regamma->coeff.gamma[i], 1000); |
1370 | 1370 | ||
1371 | ++i; | 1371 | ++i; |
@@ -1374,9 +1374,9 @@ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf, | |||
1374 | i = 0; | 1374 | i = 0; |
1375 | /* fixed_pt library has problems handling too small values */ | 1375 | /* fixed_pt library has problems handling too small values */ |
1376 | while (i != 32) { | 1376 | while (i != 32) { |
1377 | output_tf->tf_pts.red[i] = dal_fixed31_32_zero; | 1377 | output_tf->tf_pts.red[i] = dc_fixpt_zero; |
1378 | output_tf->tf_pts.green[i] = dal_fixed31_32_zero; | 1378 | output_tf->tf_pts.green[i] = dc_fixpt_zero; |
1379 | output_tf->tf_pts.blue[i] = dal_fixed31_32_zero; | 1379 | output_tf->tf_pts.blue[i] = dc_fixpt_zero; |
1380 | ++coord_x; | 1380 | ++coord_x; |
1381 | ++i; | 1381 | ++i; |
1382 | } | 1382 | } |
@@ -1423,9 +1423,9 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf, | |||
1423 | if (!rgb_regamma) | 1423 | if (!rgb_regamma) |
1424 | goto rgb_regamma_alloc_fail; | 1424 | goto rgb_regamma_alloc_fail; |
1425 | 1425 | ||
1426 | dividers.divider1 = dal_fixed31_32_from_fraction(3, 2); | 1426 | dividers.divider1 = dc_fixpt_from_fraction(3, 2); |
1427 | dividers.divider2 = dal_fixed31_32_from_int(2); | 1427 | dividers.divider2 = dc_fixpt_from_int(2); |
1428 | dividers.divider3 = dal_fixed31_32_from_fraction(5, 2); | 1428 | dividers.divider3 = dc_fixpt_from_fraction(5, 2); |
1429 | 1429 | ||
1430 | scale_user_regamma_ramp(rgb_user, ®amma->ramp, dividers); | 1430 | scale_user_regamma_ramp(rgb_user, ®amma->ramp, dividers); |
1431 | 1431 | ||
@@ -1496,9 +1496,9 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf, | |||
1496 | if (!coeff) | 1496 | if (!coeff) |
1497 | goto coeff_alloc_fail; | 1497 | goto coeff_alloc_fail; |
1498 | 1498 | ||
1499 | dividers.divider1 = dal_fixed31_32_from_fraction(3, 2); | 1499 | dividers.divider1 = dc_fixpt_from_fraction(3, 2); |
1500 | dividers.divider2 = dal_fixed31_32_from_int(2); | 1500 | dividers.divider2 = dc_fixpt_from_int(2); |
1501 | dividers.divider3 = dal_fixed31_32_from_fraction(5, 2); | 1501 | dividers.divider3 = dc_fixpt_from_fraction(5, 2); |
1502 | 1502 | ||
1503 | tf = input_tf->tf; | 1503 | tf = input_tf->tf; |
1504 | 1504 | ||
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_stats.h b/drivers/gpu/drm/amd/display/modules/inc/mod_stats.h index 3230e2adb870..3812094b52e8 100644 --- a/drivers/gpu/drm/amd/display/modules/inc/mod_stats.h +++ b/drivers/gpu/drm/amd/display/modules/inc/mod_stats.h | |||
@@ -46,6 +46,10 @@ void mod_stats_dump(struct mod_stats *mod_stats); | |||
46 | 46 | ||
47 | void mod_stats_reset_data(struct mod_stats *mod_stats); | 47 | void mod_stats_reset_data(struct mod_stats *mod_stats); |
48 | 48 | ||
49 | void mod_stats_update_event(struct mod_stats *mod_stats, | ||
50 | char *event_string, | ||
51 | unsigned int length); | ||
52 | |||
49 | void mod_stats_update_flip(struct mod_stats *mod_stats, | 53 | void mod_stats_update_flip(struct mod_stats *mod_stats, |
50 | unsigned long timestamp_in_ns); | 54 | unsigned long timestamp_in_ns); |
51 | 55 | ||
diff --git a/drivers/gpu/drm/amd/display/modules/stats/stats.c b/drivers/gpu/drm/amd/display/modules/stats/stats.c index 48e02197919f..3f7d47fdc367 100644 --- a/drivers/gpu/drm/amd/display/modules/stats/stats.c +++ b/drivers/gpu/drm/amd/display/modules/stats/stats.c | |||
@@ -36,9 +36,14 @@ | |||
36 | #define DAL_STATS_ENTRIES_REGKEY_DEFAULT 0x00350000 | 36 | #define DAL_STATS_ENTRIES_REGKEY_DEFAULT 0x00350000 |
37 | #define DAL_STATS_ENTRIES_REGKEY_MAX 0x01000000 | 37 | #define DAL_STATS_ENTRIES_REGKEY_MAX 0x01000000 |
38 | 38 | ||
39 | #define DAL_STATS_EVENT_ENTRIES_DEFAULT 0x00000100 | ||
40 | |||
39 | #define MOD_STATS_NUM_VSYNCS 5 | 41 | #define MOD_STATS_NUM_VSYNCS 5 |
42 | #define MOD_STATS_EVENT_STRING_MAX 512 | ||
40 | 43 | ||
41 | struct stats_time_cache { | 44 | struct stats_time_cache { |
45 | unsigned int entry_id; | ||
46 | |||
42 | unsigned long flip_timestamp_in_ns; | 47 | unsigned long flip_timestamp_in_ns; |
43 | unsigned long vupdate_timestamp_in_ns; | 48 | unsigned long vupdate_timestamp_in_ns; |
44 | 49 | ||
@@ -63,15 +68,26 @@ struct stats_time_cache { | |||
63 | unsigned int flags; | 68 | unsigned int flags; |
64 | }; | 69 | }; |
65 | 70 | ||
71 | struct stats_event_cache { | ||
72 | unsigned int entry_id; | ||
73 | char event_string[MOD_STATS_EVENT_STRING_MAX]; | ||
74 | }; | ||
75 | |||
66 | struct core_stats { | 76 | struct core_stats { |
67 | struct mod_stats public; | 77 | struct mod_stats public; |
68 | struct dc *dc; | 78 | struct dc *dc; |
69 | 79 | ||
80 | bool enabled; | ||
81 | unsigned int entries; | ||
82 | unsigned int event_entries; | ||
83 | unsigned int entry_id; | ||
84 | |||
70 | struct stats_time_cache *time; | 85 | struct stats_time_cache *time; |
71 | unsigned int index; | 86 | unsigned int index; |
72 | 87 | ||
73 | bool enabled; | 88 | struct stats_event_cache *events; |
74 | unsigned int entries; | 89 | unsigned int event_index; |
90 | |||
75 | }; | 91 | }; |
76 | 92 | ||
77 | #define MOD_STATS_TO_CORE(mod_stats)\ | 93 | #define MOD_STATS_TO_CORE(mod_stats)\ |
@@ -99,12 +115,12 @@ struct mod_stats *mod_stats_create(struct dc *dc) | |||
99 | unsigned int reg_data; | 115 | unsigned int reg_data; |
100 | int i = 0; | 116 | int i = 0; |
101 | 117 | ||
118 | if (dc == NULL) | ||
119 | goto fail_construct; | ||
120 | |||
102 | core_stats = kzalloc(sizeof(struct core_stats), GFP_KERNEL); | 121 | core_stats = kzalloc(sizeof(struct core_stats), GFP_KERNEL); |
103 | 122 | ||
104 | if (core_stats == NULL) | 123 | if (core_stats == NULL) |
105 | goto fail_alloc_context; | ||
106 | |||
107 | if (dc == NULL) | ||
108 | goto fail_construct; | 124 | goto fail_construct; |
109 | 125 | ||
110 | core_stats->dc = dc; | 126 | core_stats->dc = dc; |
@@ -125,27 +141,45 @@ struct mod_stats *mod_stats_create(struct dc *dc) | |||
125 | else | 141 | else |
126 | core_stats->entries = reg_data; | 142 | core_stats->entries = reg_data; |
127 | } | 143 | } |
144 | core_stats->time = kzalloc( | ||
145 | sizeof(struct stats_time_cache) * | ||
146 | core_stats->entries, | ||
147 | GFP_KERNEL); | ||
148 | |||
149 | if (core_stats->time == NULL) | ||
150 | goto fail_construct_time; | ||
128 | 151 | ||
129 | core_stats->time = kzalloc(sizeof(struct stats_time_cache) * core_stats->entries, | 152 | core_stats->event_entries = DAL_STATS_EVENT_ENTRIES_DEFAULT; |
153 | core_stats->events = kzalloc( | ||
154 | sizeof(struct stats_event_cache) * | ||
155 | core_stats->event_entries, | ||
130 | GFP_KERNEL); | 156 | GFP_KERNEL); |
157 | |||
158 | if (core_stats->events == NULL) | ||
159 | goto fail_construct_events; | ||
160 | |||
131 | } else { | 161 | } else { |
132 | core_stats->entries = 0; | 162 | core_stats->entries = 0; |
133 | } | 163 | } |
134 | 164 | ||
135 | if (core_stats->time == NULL) | ||
136 | goto fail_construct; | ||
137 | |||
138 | /* Purposely leave index 0 unused so we don't need special logic to | 165 | /* Purposely leave index 0 unused so we don't need special logic to |
139 | * handle calculation cases that depend on previous flip data. | 166 | * handle calculation cases that depend on previous flip data. |
140 | */ | 167 | */ |
141 | core_stats->index = 1; | 168 | core_stats->index = 1; |
169 | core_stats->event_index = 0; | ||
170 | |||
171 | // Keeps track of ordering within the different stats structures | ||
172 | core_stats->entry_id = 0; | ||
142 | 173 | ||
143 | return &core_stats->public; | 174 | return &core_stats->public; |
144 | 175 | ||
145 | fail_construct: | 176 | fail_construct_events: |
177 | kfree(core_stats->time); | ||
178 | |||
179 | fail_construct_time: | ||
146 | kfree(core_stats); | 180 | kfree(core_stats); |
147 | 181 | ||
148 | fail_alloc_context: | 182 | fail_construct: |
149 | return NULL; | 183 | return NULL; |
150 | } | 184 | } |
151 | 185 | ||
@@ -157,6 +191,9 @@ void mod_stats_destroy(struct mod_stats *mod_stats) | |||
157 | if (core_stats->time != NULL) | 191 | if (core_stats->time != NULL) |
158 | kfree(core_stats->time); | 192 | kfree(core_stats->time); |
159 | 193 | ||
194 | if (core_stats->events != NULL) | ||
195 | kfree(core_stats->events); | ||
196 | |||
160 | kfree(core_stats); | 197 | kfree(core_stats); |
161 | } | 198 | } |
162 | } | 199 | } |
@@ -167,7 +204,11 @@ void mod_stats_dump(struct mod_stats *mod_stats) | |||
167 | struct dal_logger *logger = NULL; | 204 | struct dal_logger *logger = NULL; |
168 | struct core_stats *core_stats = NULL; | 205 | struct core_stats *core_stats = NULL; |
169 | struct stats_time_cache *time = NULL; | 206 | struct stats_time_cache *time = NULL; |
207 | struct stats_event_cache *events = NULL; | ||
208 | unsigned int time_index = 1; | ||
209 | unsigned int event_index = 0; | ||
170 | unsigned int index = 0; | 210 | unsigned int index = 0; |
211 | struct log_entry log_entry; | ||
171 | 212 | ||
172 | if (mod_stats == NULL) | 213 | if (mod_stats == NULL) |
173 | return; | 214 | return; |
@@ -176,45 +217,62 @@ void mod_stats_dump(struct mod_stats *mod_stats) | |||
176 | dc = core_stats->dc; | 217 | dc = core_stats->dc; |
177 | logger = dc->ctx->logger; | 218 | logger = dc->ctx->logger; |
178 | time = core_stats->time; | 219 | time = core_stats->time; |
179 | 220 | events = core_stats->events; | |
180 | //LogEntry* pLog = GetLog()->Open(LogMajor_ISR, LogMinor_ISR_FreeSyncSW); | 221 | |
181 | 222 | DISPLAY_STATS_BEGIN(log_entry); | |
182 | //if (!pLog->IsDummyEntry()) | 223 | |
183 | { | 224 | DISPLAY_STATS("==Display Caps==\n"); |
184 | dm_logger_write(logger, LOG_PROFILING, "==Display Caps==\n"); | 225 | |
185 | dm_logger_write(logger, LOG_PROFILING, "\n"); | 226 | DISPLAY_STATS("==Display Stats==\n"); |
186 | dm_logger_write(logger, LOG_PROFILING, "\n"); | 227 | |
187 | 228 | DISPLAY_STATS("%10s %10s %10s %10s %10s" | |
188 | dm_logger_write(logger, LOG_PROFILING, "==Stats==\n"); | 229 | " %11s %11s %17s %10s %14s" |
189 | dm_logger_write(logger, LOG_PROFILING, | 230 | " %10s %10s %10s %10s %10s" |
190 | "render avgRender minWindow midPoint maxWindow vsyncToFlip flipToVsync #vsyncBetweenFlip #frame insertDuration vTotalMin vTotalMax eventTrigs vSyncTime1 vSyncTime2 vSyncTime3 vSyncTime4 vSyncTime5 flags\n"); | 231 | " %10s %10s %10s %10s\n", |
191 | 232 | "render", "avgRender", | |
192 | for (int i = 0; i < core_stats->index && i < core_stats->entries; i++) { | 233 | "minWindow", "midPoint", "maxWindow", |
193 | dm_logger_write(logger, LOG_PROFILING, | 234 | "vsyncToFlip", "flipToVsync", "vsyncsBetweenFlip", |
194 | "%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u", | 235 | "numFrame", "insertDuration", |
195 | time[i].render_time_in_us, | 236 | "vTotalMin", "vTotalMax", "eventTrigs", |
196 | time[i].avg_render_time_in_us_last_ten, | 237 | "vSyncTime1", "vSyncTime2", "vSyncTime3", |
197 | time[i].min_window, | 238 | "vSyncTime4", "vSyncTime5", "flags"); |
198 | time[i].lfc_mid_point_in_us, | 239 | |
199 | time[i].max_window, | 240 | for (int i = 0; i < core_stats->entry_id; i++) { |
200 | time[i].vsync_to_flip_time_in_us, | 241 | if (event_index < core_stats->event_index && |
201 | time[i].flip_to_vsync_time_in_us, | 242 | i == events[event_index].entry_id) { |
202 | time[i].num_vsync_between_flips, | 243 | DISPLAY_STATS("%s\n", events[event_index].event_string); |
203 | time[i].num_frames_inserted, | 244 | event_index++; |
204 | time[i].inserted_duration_in_us, | 245 | } else if (time_index < core_stats->index && |
205 | time[i].v_total_min, | 246 | i == time[time_index].entry_id) { |
206 | time[i].v_total_max, | 247 | DISPLAY_STATS("%10u %10u %10u %10u %10u" |
207 | time[i].event_triggers, | 248 | " %11u %11u %17u %10u %14u" |
208 | time[i].v_sync_time_in_us[0], | 249 | " %10u %10u %10u %10u %10u" |
209 | time[i].v_sync_time_in_us[1], | 250 | " %10u %10u %10u %10u\n", |
210 | time[i].v_sync_time_in_us[2], | 251 | time[time_index].render_time_in_us, |
211 | time[i].v_sync_time_in_us[3], | 252 | time[time_index].avg_render_time_in_us_last_ten, |
212 | time[i].v_sync_time_in_us[4], | 253 | time[time_index].min_window, |
213 | time[i].flags); | 254 | time[time_index].lfc_mid_point_in_us, |
255 | time[time_index].max_window, | ||
256 | time[time_index].vsync_to_flip_time_in_us, | ||
257 | time[time_index].flip_to_vsync_time_in_us, | ||
258 | time[time_index].num_vsync_between_flips, | ||
259 | time[time_index].num_frames_inserted, | ||
260 | time[time_index].inserted_duration_in_us, | ||
261 | time[time_index].v_total_min, | ||
262 | time[time_index].v_total_max, | ||
263 | time[time_index].event_triggers, | ||
264 | time[time_index].v_sync_time_in_us[0], | ||
265 | time[time_index].v_sync_time_in_us[1], | ||
266 | time[time_index].v_sync_time_in_us[2], | ||
267 | time[time_index].v_sync_time_in_us[3], | ||
268 | time[time_index].v_sync_time_in_us[4], | ||
269 | time[time_index].flags); | ||
270 | |||
271 | time_index++; | ||
214 | } | 272 | } |
215 | } | 273 | } |
216 | //GetLog()->Close(pLog); | 274 | |
217 | //GetLog()->UnSetLogMask(LogMajor_ISR, LogMinor_ISR_FreeSyncSW); | 275 | DISPLAY_STATS_END(log_entry); |
218 | } | 276 | } |
219 | 277 | ||
220 | void mod_stats_reset_data(struct mod_stats *mod_stats) | 278 | void mod_stats_reset_data(struct mod_stats *mod_stats) |
@@ -231,7 +289,46 @@ void mod_stats_reset_data(struct mod_stats *mod_stats) | |||
231 | memset(core_stats->time, 0, | 289 | memset(core_stats->time, 0, |
232 | sizeof(struct stats_time_cache) * core_stats->entries); | 290 | sizeof(struct stats_time_cache) * core_stats->entries); |
233 | 291 | ||
292 | memset(core_stats->events, 0, | ||
293 | sizeof(struct stats_event_cache) * core_stats->event_entries); | ||
294 | |||
234 | core_stats->index = 1; | 295 | core_stats->index = 1; |
296 | core_stats->event_index = 0; | ||
297 | |||
298 | // Keeps track of ordering within the different stats structures | ||
299 | core_stats->entry_id = 0; | ||
300 | } | ||
301 | |||
302 | void mod_stats_update_event(struct mod_stats *mod_stats, | ||
303 | char *event_string, | ||
304 | unsigned int length) | ||
305 | { | ||
306 | struct core_stats *core_stats = NULL; | ||
307 | struct stats_event_cache *events = NULL; | ||
308 | unsigned int index = 0; | ||
309 | unsigned int copy_length = 0; | ||
310 | |||
311 | if (mod_stats == NULL) | ||
312 | return; | ||
313 | |||
314 | core_stats = MOD_STATS_TO_CORE(mod_stats); | ||
315 | |||
316 | if (core_stats->event_index >= core_stats->event_entries) | ||
317 | return; | ||
318 | |||
319 | events = core_stats->events; | ||
320 | index = core_stats->event_index; | ||
321 | |||
322 | copy_length = length; | ||
323 | if (length > MOD_STATS_EVENT_STRING_MAX) | ||
324 | copy_length = MOD_STATS_EVENT_STRING_MAX; | ||
325 | |||
326 | memcpy(&events[index].event_string, event_string, copy_length); | ||
327 | events[index].event_string[copy_length - 1] = '\0'; | ||
328 | |||
329 | events[index].entry_id = core_stats->entry_id; | ||
330 | core_stats->event_index++; | ||
331 | core_stats->entry_id++; | ||
235 | } | 332 | } |
236 | 333 | ||
237 | void mod_stats_update_flip(struct mod_stats *mod_stats, | 334 | void mod_stats_update_flip(struct mod_stats *mod_stats, |
@@ -272,7 +369,9 @@ void mod_stats_update_flip(struct mod_stats *mod_stats, | |||
272 | (timestamp_in_ns - | 369 | (timestamp_in_ns - |
273 | time[index - 1].vupdate_timestamp_in_ns) / 1000; | 370 | time[index - 1].vupdate_timestamp_in_ns) / 1000; |
274 | 371 | ||
372 | time[index].entry_id = core_stats->entry_id; | ||
275 | core_stats->index++; | 373 | core_stats->index++; |
374 | core_stats->entry_id++; | ||
276 | } | 375 | } |
277 | 376 | ||
278 | void mod_stats_update_vupdate(struct mod_stats *mod_stats, | 377 | void mod_stats_update_vupdate(struct mod_stats *mod_stats, |
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h index 33de33016bda..b178176b72ac 100644 --- a/drivers/gpu/drm/amd/include/amd_shared.h +++ b/drivers/gpu/drm/amd/include/amd_shared.h | |||
@@ -92,7 +92,7 @@ enum amd_powergating_state { | |||
92 | #define AMD_CG_SUPPORT_GFX_3D_CGLS (1 << 21) | 92 | #define AMD_CG_SUPPORT_GFX_3D_CGLS (1 << 21) |
93 | #define AMD_CG_SUPPORT_DRM_MGCG (1 << 22) | 93 | #define AMD_CG_SUPPORT_DRM_MGCG (1 << 22) |
94 | #define AMD_CG_SUPPORT_DF_MGCG (1 << 23) | 94 | #define AMD_CG_SUPPORT_DF_MGCG (1 << 23) |
95 | 95 | #define AMD_CG_SUPPORT_VCN_MGCG (1 << 24) | |
96 | /* PG flags */ | 96 | /* PG flags */ |
97 | #define AMD_PG_SUPPORT_GFX_PG (1 << 0) | 97 | #define AMD_PG_SUPPORT_GFX_PG (1 << 0) |
98 | #define AMD_PG_SUPPORT_GFX_SMG (1 << 1) | 98 | #define AMD_PG_SUPPORT_GFX_SMG (1 << 1) |
@@ -108,6 +108,7 @@ enum amd_powergating_state { | |||
108 | #define AMD_PG_SUPPORT_GFX_QUICK_MG (1 << 11) | 108 | #define AMD_PG_SUPPORT_GFX_QUICK_MG (1 << 11) |
109 | #define AMD_PG_SUPPORT_GFX_PIPELINE (1 << 12) | 109 | #define AMD_PG_SUPPORT_GFX_PIPELINE (1 << 12) |
110 | #define AMD_PG_SUPPORT_MMHUB (1 << 13) | 110 | #define AMD_PG_SUPPORT_MMHUB (1 << 13) |
111 | #define AMD_PG_SUPPORT_VCN (1 << 14) | ||
111 | 112 | ||
112 | enum PP_FEATURE_MASK { | 113 | enum PP_FEATURE_MASK { |
113 | PP_SCLK_DPM_MASK = 0x1, | 114 | PP_SCLK_DPM_MASK = 0x1, |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_offset.h b/drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_offset.h index f730d0629020..b6f74bf4af02 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_offset.h +++ b/drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_offset.h | |||
@@ -2095,6 +2095,18 @@ | |||
2095 | #define mmDC_GPIO_AUX_CTRL_2_BASE_IDX 2 | 2095 | #define mmDC_GPIO_AUX_CTRL_2_BASE_IDX 2 |
2096 | #define mmDC_GPIO_RXEN 0x212f | 2096 | #define mmDC_GPIO_RXEN 0x212f |
2097 | #define mmDC_GPIO_RXEN_BASE_IDX 2 | 2097 | #define mmDC_GPIO_RXEN_BASE_IDX 2 |
2098 | #define mmDC_GPIO_AUX_CTRL_3 0x2130 | ||
2099 | #define mmDC_GPIO_AUX_CTRL_3_BASE_IDX 2 | ||
2100 | #define mmDC_GPIO_AUX_CTRL_4 0x2131 | ||
2101 | #define mmDC_GPIO_AUX_CTRL_4_BASE_IDX 2 | ||
2102 | #define mmDC_GPIO_AUX_CTRL_5 0x2132 | ||
2103 | #define mmDC_GPIO_AUX_CTRL_5_BASE_IDX 2 | ||
2104 | #define mmAUXI2C_PAD_ALL_PWR_OK 0x2133 | ||
2105 | #define mmAUXI2C_PAD_ALL_PWR_OK_BASE_IDX 2 | ||
2106 | #define mmDC_GPIO_PULLUPEN 0x2134 | ||
2107 | #define mmDC_GPIO_PULLUPEN_BASE_IDX 2 | ||
2108 | #define mmDC_GPIO_AUX_CTRL_6 0x2135 | ||
2109 | #define mmDC_GPIO_AUX_CTRL_6_BASE_IDX 2 | ||
2098 | #define mmBPHYC_DAC_MACRO_CNTL 0x2136 | 2110 | #define mmBPHYC_DAC_MACRO_CNTL 0x2136 |
2099 | #define mmBPHYC_DAC_MACRO_CNTL_BASE_IDX 2 | 2111 | #define mmBPHYC_DAC_MACRO_CNTL_BASE_IDX 2 |
2100 | #define mmDAC_MACRO_CNTL_RESERVED0 0x2136 | 2112 | #define mmDAC_MACRO_CNTL_RESERVED0 0x2136 |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_sh_mask.h index 6d3162c42957..bcd190a3fcdd 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_sh_mask.h +++ b/drivers/gpu/drm/amd/include/asic_reg/dce/dce_12_0_sh_mask.h | |||
@@ -10971,6 +10971,158 @@ | |||
10971 | #define DC_GPIO_RXEN__DC_GPIO_BLON_RXEN_MASK 0x00100000L | 10971 | #define DC_GPIO_RXEN__DC_GPIO_BLON_RXEN_MASK 0x00100000L |
10972 | #define DC_GPIO_RXEN__DC_GPIO_DIGON_RXEN_MASK 0x00200000L | 10972 | #define DC_GPIO_RXEN__DC_GPIO_DIGON_RXEN_MASK 0x00200000L |
10973 | #define DC_GPIO_RXEN__DC_GPIO_ENA_BL_RXEN_MASK 0x00400000L | 10973 | #define DC_GPIO_RXEN__DC_GPIO_ENA_BL_RXEN_MASK 0x00400000L |
10974 | //DC_GPIO_AUX_CTRL_3 | ||
10975 | #define DC_GPIO_AUX_CTRL_3__AUX1_NEN_RTERM__SHIFT 0x0 | ||
10976 | #define DC_GPIO_AUX_CTRL_3__AUX2_NEN_RTERM__SHIFT 0x1 | ||
10977 | #define DC_GPIO_AUX_CTRL_3__AUX3_NEN_RTERM__SHIFT 0x2 | ||
10978 | #define DC_GPIO_AUX_CTRL_3__AUX4_NEN_RTERM__SHIFT 0x3 | ||
10979 | #define DC_GPIO_AUX_CTRL_3__AUX5_NEN_RTERM__SHIFT 0x4 | ||
10980 | #define DC_GPIO_AUX_CTRL_3__AUX6_NEN_RTERM__SHIFT 0x5 | ||
10981 | #define DC_GPIO_AUX_CTRL_3__AUX1_DP_DN_SWAP__SHIFT 0x8 | ||
10982 | #define DC_GPIO_AUX_CTRL_3__AUX2_DP_DN_SWAP__SHIFT 0x9 | ||
10983 | #define DC_GPIO_AUX_CTRL_3__AUX3_DP_DN_SWAP__SHIFT 0xa | ||
10984 | #define DC_GPIO_AUX_CTRL_3__AUX4_DP_DN_SWAP__SHIFT 0xb | ||
10985 | #define DC_GPIO_AUX_CTRL_3__AUX5_DP_DN_SWAP__SHIFT 0xc | ||
10986 | #define DC_GPIO_AUX_CTRL_3__AUX6_DP_DN_SWAP__SHIFT 0xd | ||
10987 | #define DC_GPIO_AUX_CTRL_3__AUX1_HYS_TUNE__SHIFT 0x10 | ||
10988 | #define DC_GPIO_AUX_CTRL_3__AUX2_HYS_TUNE__SHIFT 0x12 | ||
10989 | #define DC_GPIO_AUX_CTRL_3__AUX3_HYS_TUNE__SHIFT 0x14 | ||
10990 | #define DC_GPIO_AUX_CTRL_3__AUX4_HYS_TUNE__SHIFT 0x16 | ||
10991 | #define DC_GPIO_AUX_CTRL_3__AUX5_HYS_TUNE__SHIFT 0x18 | ||
10992 | #define DC_GPIO_AUX_CTRL_3__AUX6_HYS_TUNE__SHIFT 0x1a | ||
10993 | #define DC_GPIO_AUX_CTRL_3__AUX1_NEN_RTERM_MASK 0x00000001L | ||
10994 | #define DC_GPIO_AUX_CTRL_3__AUX2_NEN_RTERM_MASK 0x00000002L | ||
10995 | #define DC_GPIO_AUX_CTRL_3__AUX3_NEN_RTERM_MASK 0x00000004L | ||
10996 | #define DC_GPIO_AUX_CTRL_3__AUX4_NEN_RTERM_MASK 0x00000008L | ||
10997 | #define DC_GPIO_AUX_CTRL_3__AUX5_NEN_RTERM_MASK 0x00000010L | ||
10998 | #define DC_GPIO_AUX_CTRL_3__AUX6_NEN_RTERM_MASK 0x00000020L | ||
10999 | #define DC_GPIO_AUX_CTRL_3__AUX1_DP_DN_SWAP_MASK 0x00000100L | ||
11000 | #define DC_GPIO_AUX_CTRL_3__AUX2_DP_DN_SWAP_MASK 0x00000200L | ||
11001 | #define DC_GPIO_AUX_CTRL_3__AUX3_DP_DN_SWAP_MASK 0x00000400L | ||
11002 | #define DC_GPIO_AUX_CTRL_3__AUX4_DP_DN_SWAP_MASK 0x00000800L | ||
11003 | #define DC_GPIO_AUX_CTRL_3__AUX5_DP_DN_SWAP_MASK 0x00001000L | ||
11004 | #define DC_GPIO_AUX_CTRL_3__AUX6_DP_DN_SWAP_MASK 0x00002000L | ||
11005 | #define DC_GPIO_AUX_CTRL_3__AUX1_HYS_TUNE_MASK 0x00030000L | ||
11006 | #define DC_GPIO_AUX_CTRL_3__AUX2_HYS_TUNE_MASK 0x000C0000L | ||
11007 | #define DC_GPIO_AUX_CTRL_3__AUX3_HYS_TUNE_MASK 0x00300000L | ||
11008 | #define DC_GPIO_AUX_CTRL_3__AUX4_HYS_TUNE_MASK 0x00C00000L | ||
11009 | #define DC_GPIO_AUX_CTRL_3__AUX5_HYS_TUNE_MASK 0x03000000L | ||
11010 | #define DC_GPIO_AUX_CTRL_3__AUX6_HYS_TUNE_MASK 0x0C000000L | ||
11011 | //DC_GPIO_AUX_CTRL_4 | ||
11012 | #define DC_GPIO_AUX_CTRL_4__AUX1_AUX_CTRL__SHIFT 0x0 | ||
11013 | #define DC_GPIO_AUX_CTRL_4__AUX2_AUX_CTRL__SHIFT 0x4 | ||
11014 | #define DC_GPIO_AUX_CTRL_4__AUX3_AUX_CTRL__SHIFT 0x8 | ||
11015 | #define DC_GPIO_AUX_CTRL_4__AUX4_AUX_CTRL__SHIFT 0xc | ||
11016 | #define DC_GPIO_AUX_CTRL_4__AUX5_AUX_CTRL__SHIFT 0x10 | ||
11017 | #define DC_GPIO_AUX_CTRL_4__AUX6_AUX_CTRL__SHIFT 0x14 | ||
11018 | #define DC_GPIO_AUX_CTRL_4__AUX1_AUX_CTRL_MASK 0x0000000FL | ||
11019 | #define DC_GPIO_AUX_CTRL_4__AUX2_AUX_CTRL_MASK 0x000000F0L | ||
11020 | #define DC_GPIO_AUX_CTRL_4__AUX3_AUX_CTRL_MASK 0x00000F00L | ||
11021 | #define DC_GPIO_AUX_CTRL_4__AUX4_AUX_CTRL_MASK 0x0000F000L | ||
11022 | #define DC_GPIO_AUX_CTRL_4__AUX5_AUX_CTRL_MASK 0x000F0000L | ||
11023 | #define DC_GPIO_AUX_CTRL_4__AUX6_AUX_CTRL_MASK 0x00F00000L | ||
11024 | //DC_GPIO_AUX_CTRL_5 | ||
11025 | #define DC_GPIO_AUX_CTRL_5__AUX1_VOD_TUNE__SHIFT 0x0 | ||
11026 | #define DC_GPIO_AUX_CTRL_5__AUX2_VOD_TUNE__SHIFT 0x2 | ||
11027 | #define DC_GPIO_AUX_CTRL_5__AUX3_VOD_TUNE__SHIFT 0x4 | ||
11028 | #define DC_GPIO_AUX_CTRL_5__AUX4_VOD_TUNE__SHIFT 0x6 | ||
11029 | #define DC_GPIO_AUX_CTRL_5__AUX5_VOD_TUNE__SHIFT 0x8 | ||
11030 | #define DC_GPIO_AUX_CTRL_5__AUX6_VOD_TUNE__SHIFT 0xa | ||
11031 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD1_I2CMODE__SHIFT 0xc | ||
11032 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD2_I2CMODE__SHIFT 0xd | ||
11033 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD3_I2CMODE__SHIFT 0xe | ||
11034 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD4_I2CMODE__SHIFT 0xf | ||
11035 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD5_I2CMODE__SHIFT 0x10 | ||
11036 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD6_I2CMODE__SHIFT 0x11 | ||
11037 | #define DC_GPIO_AUX_CTRL_5__DDC1_I2C_VPH_1V2_EN__SHIFT 0x12 | ||
11038 | #define DC_GPIO_AUX_CTRL_5__DDC2_I2C_VPH_1V2_EN__SHIFT 0x13 | ||
11039 | #define DC_GPIO_AUX_CTRL_5__DDC3_I2C_VPH_1V2_EN__SHIFT 0x14 | ||
11040 | #define DC_GPIO_AUX_CTRL_5__DDC4_I2C_VPH_1V2_EN__SHIFT 0x15 | ||
11041 | #define DC_GPIO_AUX_CTRL_5__DDC5_I2C_VPH_1V2_EN__SHIFT 0x16 | ||
11042 | #define DC_GPIO_AUX_CTRL_5__DDC6_I2C_VPH_1V2_EN__SHIFT 0x17 | ||
11043 | #define DC_GPIO_AUX_CTRL_5__DDC1_PAD_I2C_CTRL__SHIFT 0x18 | ||
11044 | #define DC_GPIO_AUX_CTRL_5__DDC2_PAD_I2C_CTRL__SHIFT 0x19 | ||
11045 | #define DC_GPIO_AUX_CTRL_5__DDC3_PAD_I2C_CTRL__SHIFT 0x1a | ||
11046 | #define DC_GPIO_AUX_CTRL_5__DDC4_PAD_I2C_CTRL__SHIFT 0x1b | ||
11047 | #define DC_GPIO_AUX_CTRL_5__DDC5_PAD_I2C_CTRL__SHIFT 0x1c | ||
11048 | #define DC_GPIO_AUX_CTRL_5__DDC6_PAD_I2C_CTRL__SHIFT 0x1d | ||
11049 | #define DC_GPIO_AUX_CTRL_5__AUX1_VOD_TUNE_MASK 0x00000003L | ||
11050 | #define DC_GPIO_AUX_CTRL_5__AUX2_VOD_TUNE_MASK 0x0000000CL | ||
11051 | #define DC_GPIO_AUX_CTRL_5__AUX3_VOD_TUNE_MASK 0x00000030L | ||
11052 | #define DC_GPIO_AUX_CTRL_5__AUX4_VOD_TUNE_MASK 0x000000C0L | ||
11053 | #define DC_GPIO_AUX_CTRL_5__AUX5_VOD_TUNE_MASK 0x00000300L | ||
11054 | #define DC_GPIO_AUX_CTRL_5__AUX6_VOD_TUNE_MASK 0x00000C00L | ||
11055 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD1_I2CMODE_MASK 0x00001000L | ||
11056 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD2_I2CMODE_MASK 0x00002000L | ||
11057 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD3_I2CMODE_MASK 0x00004000L | ||
11058 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD4_I2CMODE_MASK 0x00008000L | ||
11059 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD5_I2CMODE_MASK 0x00010000L | ||
11060 | #define DC_GPIO_AUX_CTRL_5__DDC_PAD6_I2CMODE_MASK 0x00020000L | ||
11061 | #define DC_GPIO_AUX_CTRL_5__DDC1_I2C_VPH_1V2_EN_MASK 0x00040000L | ||
11062 | #define DC_GPIO_AUX_CTRL_5__DDC2_I2C_VPH_1V2_EN_MASK 0x00080000L | ||
11063 | #define DC_GPIO_AUX_CTRL_5__DDC3_I2C_VPH_1V2_EN_MASK 0x00100000L | ||
11064 | #define DC_GPIO_AUX_CTRL_5__DDC4_I2C_VPH_1V2_EN_MASK 0x00200000L | ||
11065 | #define DC_GPIO_AUX_CTRL_5__DDC5_I2C_VPH_1V2_EN_MASK 0x00400000L | ||
11066 | #define DC_GPIO_AUX_CTRL_5__DDC6_I2C_VPH_1V2_EN_MASK 0x00800000L | ||
11067 | #define DC_GPIO_AUX_CTRL_5__DDC1_PAD_I2C_CTRL_MASK 0x01000000L | ||
11068 | #define DC_GPIO_AUX_CTRL_5__DDC2_PAD_I2C_CTRL_MASK 0x02000000L | ||
11069 | #define DC_GPIO_AUX_CTRL_5__DDC3_PAD_I2C_CTRL_MASK 0x04000000L | ||
11070 | #define DC_GPIO_AUX_CTRL_5__DDC4_PAD_I2C_CTRL_MASK 0x08000000L | ||
11071 | #define DC_GPIO_AUX_CTRL_5__DDC5_PAD_I2C_CTRL_MASK 0x10000000L | ||
11072 | #define DC_GPIO_AUX_CTRL_5__DDC6_PAD_I2C_CTRL_MASK 0x20000000L | ||
11073 | //AUXI2C_PAD_ALL_PWR_OK | ||
11074 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY1_ALL_PWR_OK__SHIFT 0x0 | ||
11075 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY2_ALL_PWR_OK__SHIFT 0x1 | ||
11076 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY3_ALL_PWR_OK__SHIFT 0x2 | ||
11077 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY4_ALL_PWR_OK__SHIFT 0x3 | ||
11078 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY5_ALL_PWR_OK__SHIFT 0x4 | ||
11079 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY6_ALL_PWR_OK__SHIFT 0x5 | ||
11080 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY1_ALL_PWR_OK_MASK 0x00000001L | ||
11081 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY2_ALL_PWR_OK_MASK 0x00000002L | ||
11082 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY3_ALL_PWR_OK_MASK 0x00000004L | ||
11083 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY4_ALL_PWR_OK_MASK 0x00000008L | ||
11084 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY5_ALL_PWR_OK_MASK 0x00000010L | ||
11085 | #define AUXI2C_PAD_ALL_PWR_OK__AUXI2C_PHY6_ALL_PWR_OK_MASK 0x00000020L | ||
11086 | //DC_GPIO_PULLUPEN | ||
11087 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICA_PU_EN__SHIFT 0x0 | ||
11088 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICB_PU_EN__SHIFT 0x1 | ||
11089 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICC_PU_EN__SHIFT 0x2 | ||
11090 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICD_PU_EN__SHIFT 0x3 | ||
11091 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICE_PU_EN__SHIFT 0x4 | ||
11092 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICF_PU_EN__SHIFT 0x5 | ||
11093 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICG_PU_EN__SHIFT 0x6 | ||
11094 | #define DC_GPIO_PULLUPEN__DC_GPIO_HSYNCA_PU_EN__SHIFT 0x8 | ||
11095 | #define DC_GPIO_PULLUPEN__DC_GPIO_VSYNCA_PU_EN__SHIFT 0x9 | ||
11096 | #define DC_GPIO_PULLUPEN__DC_GPIO_HPD1_PU_EN__SHIFT 0xe | ||
11097 | #define DC_GPIO_PULLUPEN__DC_GPIO_BLON_PU_EN__SHIFT 0x14 | ||
11098 | #define DC_GPIO_PULLUPEN__DC_GPIO_DIGON_PU_EN__SHIFT 0x15 | ||
11099 | #define DC_GPIO_PULLUPEN__DC_GPIO_ENA_BL_PU_EN__SHIFT 0x16 | ||
11100 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICA_PU_EN_MASK 0x00000001L | ||
11101 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICB_PU_EN_MASK 0x00000002L | ||
11102 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICC_PU_EN_MASK 0x00000004L | ||
11103 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICD_PU_EN_MASK 0x00000008L | ||
11104 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICE_PU_EN_MASK 0x00000010L | ||
11105 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICF_PU_EN_MASK 0x00000020L | ||
11106 | #define DC_GPIO_PULLUPEN__DC_GPIO_GENERICG_PU_EN_MASK 0x00000040L | ||
11107 | #define DC_GPIO_PULLUPEN__DC_GPIO_HSYNCA_PU_EN_MASK 0x00000100L | ||
11108 | #define DC_GPIO_PULLUPEN__DC_GPIO_VSYNCA_PU_EN_MASK 0x00000200L | ||
11109 | #define DC_GPIO_PULLUPEN__DC_GPIO_HPD1_PU_EN_MASK 0x00004000L | ||
11110 | #define DC_GPIO_PULLUPEN__DC_GPIO_BLON_PU_EN_MASK 0x00100000L | ||
11111 | #define DC_GPIO_PULLUPEN__DC_GPIO_DIGON_PU_EN_MASK 0x00200000L | ||
11112 | #define DC_GPIO_PULLUPEN__DC_GPIO_ENA_BL_PU_EN_MASK 0x00400000L | ||
11113 | //DC_GPIO_AUX_CTRL_6 | ||
11114 | #define DC_GPIO_AUX_CTRL_6__AUX1_PAD_RXSEL__SHIFT 0x0 | ||
11115 | #define DC_GPIO_AUX_CTRL_6__AUX2_PAD_RXSEL__SHIFT 0x2 | ||
11116 | #define DC_GPIO_AUX_CTRL_6__AUX3_PAD_RXSEL__SHIFT 0x4 | ||
11117 | #define DC_GPIO_AUX_CTRL_6__AUX4_PAD_RXSEL__SHIFT 0x6 | ||
11118 | #define DC_GPIO_AUX_CTRL_6__AUX5_PAD_RXSEL__SHIFT 0x8 | ||
11119 | #define DC_GPIO_AUX_CTRL_6__AUX6_PAD_RXSEL__SHIFT 0xa | ||
11120 | #define DC_GPIO_AUX_CTRL_6__AUX1_PAD_RXSEL_MASK 0x00000003L | ||
11121 | #define DC_GPIO_AUX_CTRL_6__AUX2_PAD_RXSEL_MASK 0x0000000CL | ||
11122 | #define DC_GPIO_AUX_CTRL_6__AUX3_PAD_RXSEL_MASK 0x00000030L | ||
11123 | #define DC_GPIO_AUX_CTRL_6__AUX4_PAD_RXSEL_MASK 0x000000C0L | ||
11124 | #define DC_GPIO_AUX_CTRL_6__AUX5_PAD_RXSEL_MASK 0x00000300L | ||
11125 | #define DC_GPIO_AUX_CTRL_6__AUX6_PAD_RXSEL_MASK 0x00000C00L | ||
10974 | //BPHYC_DAC_MACRO_CNTL | 11126 | //BPHYC_DAC_MACRO_CNTL |
10975 | #define BPHYC_DAC_MACRO_CNTL__BPHYC_DAC_WHITE_LEVEL__SHIFT 0x0 | 11127 | #define BPHYC_DAC_MACRO_CNTL__BPHYC_DAC_WHITE_LEVEL__SHIFT 0x0 |
10976 | #define BPHYC_DAC_MACRO_CNTL__BPHYC_DAC_WHITE_FINE_CONTROL__SHIFT 0x8 | 11128 | #define BPHYC_DAC_MACRO_CNTL__BPHYC_DAC_WHITE_FINE_CONTROL__SHIFT 0x8 |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/df/df_1_7_offset.h b/drivers/gpu/drm/amd/include/asic_reg/df/df_1_7_offset.h index 2b305dd021e8..e6044e27a913 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/df/df_1_7_offset.h +++ b/drivers/gpu/drm/amd/include/asic_reg/df/df_1_7_offset.h | |||
@@ -30,4 +30,8 @@ | |||
30 | #define mmDF_CS_AON0_DramBaseAddress0 0x0044 | 30 | #define mmDF_CS_AON0_DramBaseAddress0 0x0044 |
31 | #define mmDF_CS_AON0_DramBaseAddress0_BASE_IDX 0 | 31 | #define mmDF_CS_AON0_DramBaseAddress0_BASE_IDX 0 |
32 | 32 | ||
33 | #define mmDF_CS_AON0_CoherentSlaveModeCtrlA0 0x0214 | ||
34 | #define mmDF_CS_AON0_CoherentSlaveModeCtrlA0_BASE_IDX 0 | ||
35 | |||
36 | |||
33 | #endif | 37 | #endif |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/df/df_1_7_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/df/df_1_7_sh_mask.h index 2ba849798924..a78c99480e2d 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/df/df_1_7_sh_mask.h +++ b/drivers/gpu/drm/amd/include/asic_reg/df/df_1_7_sh_mask.h | |||
@@ -45,4 +45,8 @@ | |||
45 | #define DF_CS_AON0_DramBaseAddress0__IntLvAddrSel_MASK 0x00000700L | 45 | #define DF_CS_AON0_DramBaseAddress0__IntLvAddrSel_MASK 0x00000700L |
46 | #define DF_CS_AON0_DramBaseAddress0__DramBaseAddr_MASK 0xFFFFF000L | 46 | #define DF_CS_AON0_DramBaseAddress0__DramBaseAddr_MASK 0xFFFFF000L |
47 | 47 | ||
48 | //DF_CS_AON0_CoherentSlaveModeCtrlA0 | ||
49 | #define DF_CS_AON0_CoherentSlaveModeCtrlA0__ForceParWrRMW__SHIFT 0x3 | ||
50 | #define DF_CS_AON0_CoherentSlaveModeCtrlA0__ForceParWrRMW_MASK 0x00000008L | ||
51 | |||
48 | #endif | 52 | #endif |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_default.h b/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_default.h new file mode 100644 index 000000000000..e58c207ac980 --- /dev/null +++ b/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_default.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 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 | ||
12 | * in all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
15 | * OR 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) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
18 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
20 | */ | ||
21 | #ifndef _df_3_6_DEFAULT_HEADER | ||
22 | #define _df_3_6_DEFAULT_HEADER | ||
23 | |||
24 | #define mmFabricConfigAccessControl_DEFAULT 0x00000000 | ||
25 | |||
26 | #endif | ||
diff --git a/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_offset.h b/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_offset.h new file mode 100644 index 000000000000..a9575db8d7aa --- /dev/null +++ b/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_offset.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 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 | ||
12 | * in all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
15 | * OR 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) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
18 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
20 | */ | ||
21 | #ifndef _df_3_6_OFFSET_HEADER | ||
22 | #define _df_3_6_OFFSET_HEADER | ||
23 | |||
24 | #define mmFabricConfigAccessControl 0x0410 | ||
25 | #define mmFabricConfigAccessControl_BASE_IDX 0 | ||
26 | |||
27 | #define mmDF_PIE_AON0_DfGlobalClkGater 0x00fc | ||
28 | #define mmDF_PIE_AON0_DfGlobalClkGater_BASE_IDX 0 | ||
29 | |||
30 | #define mmDF_CS_UMC_AON0_DramBaseAddress0 0x0044 | ||
31 | #define mmDF_CS_UMC_AON0_DramBaseAddress0_BASE_IDX 0 | ||
32 | |||
33 | #endif | ||
diff --git a/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_sh_mask.h new file mode 100644 index 000000000000..88f7c69df6b9 --- /dev/null +++ b/drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_sh_mask.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 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 | ||
12 | * in all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
15 | * OR 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) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
18 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
20 | */ | ||
21 | #ifndef _df_3_6_SH_MASK_HEADER | ||
22 | #define _df_3_6_SH_MASK_HEADER | ||
23 | |||
24 | /* FabricConfigAccessControl */ | ||
25 | #define FabricConfigAccessControl__CfgRegInstAccEn__SHIFT 0x0 | ||
26 | #define FabricConfigAccessControl__CfgRegInstAccRegLock__SHIFT 0x1 | ||
27 | #define FabricConfigAccessControl__CfgRegInstID__SHIFT 0x10 | ||
28 | #define FabricConfigAccessControl__CfgRegInstAccEn_MASK 0x00000001L | ||
29 | #define FabricConfigAccessControl__CfgRegInstAccRegLock_MASK 0x00000002L | ||
30 | #define FabricConfigAccessControl__CfgRegInstID_MASK 0x00FF0000L | ||
31 | |||
32 | /* DF_PIE_AON0_DfGlobalClkGater */ | ||
33 | #define DF_PIE_AON0_DfGlobalClkGater__MGCGMode__SHIFT 0x0 | ||
34 | #define DF_PIE_AON0_DfGlobalClkGater__MGCGMode_MASK 0x0000000FL | ||
35 | |||
36 | /* DF_CS_AON0_DramBaseAddress0 */ | ||
37 | #define DF_CS_UMC_AON0_DramBaseAddress0__AddrRngVal__SHIFT 0x0 | ||
38 | #define DF_CS_UMC_AON0_DramBaseAddress0__LgcyMmioHoleEn__SHIFT 0x1 | ||
39 | #define DF_CS_UMC_AON0_DramBaseAddress0__IntLvNumChan__SHIFT 0x4 | ||
40 | #define DF_CS_UMC_AON0_DramBaseAddress0__IntLvAddrSel__SHIFT 0x8 | ||
41 | #define DF_CS_UMC_AON0_DramBaseAddress0__DramBaseAddr__SHIFT 0xc | ||
42 | #define DF_CS_UMC_AON0_DramBaseAddress0__AddrRngVal_MASK 0x00000001L | ||
43 | #define DF_CS_UMC_AON0_DramBaseAddress0__LgcyMmioHoleEn_MASK 0x00000002L | ||
44 | #define DF_CS_UMC_AON0_DramBaseAddress0__IntLvNumChan_MASK 0x000000F0L | ||
45 | #define DF_CS_UMC_AON0_DramBaseAddress0__IntLvAddrSel_MASK 0x00000700L | ||
46 | #define DF_CS_UMC_AON0_DramBaseAddress0__DramBaseAddr_MASK 0xFFFFF000L | ||
47 | |||
48 | #endif | ||
diff --git a/drivers/gpu/drm/amd/include/atomfirmware.h b/drivers/gpu/drm/amd/include/atomfirmware.h index de177ce8ca80..c6c1666ac120 100644 --- a/drivers/gpu/drm/amd/include/atomfirmware.h +++ b/drivers/gpu/drm/amd/include/atomfirmware.h | |||
@@ -1219,6 +1219,41 @@ struct atom_gfx_info_v2_3 { | |||
1219 | uint32_t rm21_sram_vmin_value; | 1219 | uint32_t rm21_sram_vmin_value; |
1220 | }; | 1220 | }; |
1221 | 1221 | ||
1222 | struct atom_gfx_info_v2_4 { | ||
1223 | struct atom_common_table_header table_header; | ||
1224 | uint8_t gfxip_min_ver; | ||
1225 | uint8_t gfxip_max_ver; | ||
1226 | uint8_t gc_num_se; | ||
1227 | uint8_t max_tile_pipes; | ||
1228 | uint8_t gc_num_cu_per_sh; | ||
1229 | uint8_t gc_num_sh_per_se; | ||
1230 | uint8_t gc_num_rb_per_se; | ||
1231 | uint8_t gc_num_tccs; | ||
1232 | uint32_t regaddr_cp_dma_src_addr; | ||
1233 | uint32_t regaddr_cp_dma_src_addr_hi; | ||
1234 | uint32_t regaddr_cp_dma_dst_addr; | ||
1235 | uint32_t regaddr_cp_dma_dst_addr_hi; | ||
1236 | uint32_t regaddr_cp_dma_command; | ||
1237 | uint32_t regaddr_cp_status; | ||
1238 | uint32_t regaddr_rlc_gpu_clock_32; | ||
1239 | uint32_t rlc_gpu_timer_refclk; | ||
1240 | uint8_t active_cu_per_sh; | ||
1241 | uint8_t active_rb_per_se; | ||
1242 | uint16_t gcgoldenoffset; | ||
1243 | uint16_t gc_num_gprs; | ||
1244 | uint16_t gc_gsprim_buff_depth; | ||
1245 | uint16_t gc_parameter_cache_depth; | ||
1246 | uint16_t gc_wave_size; | ||
1247 | uint16_t gc_max_waves_per_simd; | ||
1248 | uint16_t gc_lds_size; | ||
1249 | uint8_t gc_num_max_gs_thds; | ||
1250 | uint8_t gc_gs_table_depth; | ||
1251 | uint8_t gc_double_offchip_lds_buffer; | ||
1252 | uint8_t gc_max_scratch_slots_per_cu; | ||
1253 | uint32_t sram_rm_fuses_val; | ||
1254 | uint32_t sram_custom_rm_fuses_val; | ||
1255 | }; | ||
1256 | |||
1222 | /* | 1257 | /* |
1223 | *************************************************************************** | 1258 | *************************************************************************** |
1224 | Data Table smu_info structure | 1259 | Data Table smu_info structure |
diff --git a/drivers/gpu/drm/amd/include/soc15_ih_clientid.h b/drivers/gpu/drm/amd/include/soc15_ih_clientid.h index a12d4f27cfa4..12e196c15bbe 100644 --- a/drivers/gpu/drm/amd/include/soc15_ih_clientid.h +++ b/drivers/gpu/drm/amd/include/soc15_ih_clientid.h | |||
@@ -43,6 +43,7 @@ enum soc15_ih_clientid { | |||
43 | SOC15_IH_CLIENTID_SE2SH = 0x0c, | 43 | SOC15_IH_CLIENTID_SE2SH = 0x0c, |
44 | SOC15_IH_CLIENTID_SE3SH = 0x0d, | 44 | SOC15_IH_CLIENTID_SE3SH = 0x0d, |
45 | SOC15_IH_CLIENTID_SYSHUB = 0x0e, | 45 | SOC15_IH_CLIENTID_SYSHUB = 0x0e, |
46 | SOC15_IH_CLIENTID_UVD1 = 0x0e, | ||
46 | SOC15_IH_CLIENTID_THM = 0x0f, | 47 | SOC15_IH_CLIENTID_THM = 0x0f, |
47 | SOC15_IH_CLIENTID_UVD = 0x10, | 48 | SOC15_IH_CLIENTID_UVD = 0x10, |
48 | SOC15_IH_CLIENTID_VCE0 = 0x11, | 49 | SOC15_IH_CLIENTID_VCE0 = 0x11, |
diff --git a/drivers/gpu/drm/amd/include/vega20_ip_offset.h b/drivers/gpu/drm/amd/include/vega20_ip_offset.h new file mode 100644 index 000000000000..2a2a9cc8bedb --- /dev/null +++ b/drivers/gpu/drm/amd/include/vega20_ip_offset.h | |||
@@ -0,0 +1,1051 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 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 | ||
12 | * in all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
15 | * OR 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) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
18 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
20 | */ | ||
21 | #ifndef _vega20_ip_offset_HEADER | ||
22 | #define _vega20_ip_offset_HEADER | ||
23 | |||
24 | #define MAX_INSTANCE 6 | ||
25 | #define MAX_SEGMENT 6 | ||
26 | |||
27 | |||
28 | struct IP_BASE_INSTANCE | ||
29 | { | ||
30 | unsigned int segment[MAX_SEGMENT]; | ||
31 | }; | ||
32 | |||
33 | struct IP_BASE | ||
34 | { | ||
35 | struct IP_BASE_INSTANCE instance[MAX_INSTANCE]; | ||
36 | }; | ||
37 | |||
38 | |||
39 | static const struct IP_BASE ATHUB_BASE ={ { { { 0x00000C20, 0, 0, 0, 0, 0 } }, | ||
40 | { { 0, 0, 0, 0, 0, 0 } }, | ||
41 | { { 0, 0, 0, 0, 0, 0 } }, | ||
42 | { { 0, 0, 0, 0, 0, 0 } }, | ||
43 | { { 0, 0, 0, 0, 0, 0 } }, | ||
44 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
45 | static const struct IP_BASE CLK_BASE ={ { { { 0x00016C00, 0x00016E00, 0x00017000, 0x00017200, 0x0001B000, 0x0001B200 } }, | ||
46 | { { 0, 0, 0, 0, 0, 0 } }, | ||
47 | { { 0, 0, 0, 0, 0, 0 } }, | ||
48 | { { 0, 0, 0, 0, 0, 0 } }, | ||
49 | { { 0, 0, 0, 0, 0, 0 } }, | ||
50 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
51 | static const struct IP_BASE DCE_BASE ={ { { { 0x00000012, 0x000000C0, 0x000034C0, 0, 0, 0 } }, | ||
52 | { { 0, 0, 0, 0, 0, 0 } }, | ||
53 | { { 0, 0, 0, 0, 0, 0 } }, | ||
54 | { { 0, 0, 0, 0, 0, 0 } }, | ||
55 | { { 0, 0, 0, 0, 0, 0 } }, | ||
56 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
57 | static const struct IP_BASE DF_BASE ={ { { { 0x00007000, 0, 0, 0, 0, 0 } }, | ||
58 | { { 0, 0, 0, 0, 0, 0 } }, | ||
59 | { { 0, 0, 0, 0, 0, 0 } }, | ||
60 | { { 0, 0, 0, 0, 0, 0 } }, | ||
61 | { { 0, 0, 0, 0, 0, 0 } }, | ||
62 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
63 | static const struct IP_BASE FUSE_BASE ={ { { { 0x00017400, 0, 0, 0, 0, 0 } }, | ||
64 | { { 0, 0, 0, 0, 0, 0 } }, | ||
65 | { { 0, 0, 0, 0, 0, 0 } }, | ||
66 | { { 0, 0, 0, 0, 0, 0 } }, | ||
67 | { { 0, 0, 0, 0, 0, 0 } }, | ||
68 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
69 | static const struct IP_BASE GC_BASE ={ { { { 0x00002000, 0x0000A000, 0, 0, 0, 0 } }, | ||
70 | { { 0, 0, 0, 0, 0, 0 } }, | ||
71 | { { 0, 0, 0, 0, 0, 0 } }, | ||
72 | { { 0, 0, 0, 0, 0, 0 } }, | ||
73 | { { 0, 0, 0, 0, 0, 0 } }, | ||
74 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
75 | static const struct IP_BASE HDP_BASE ={ { { { 0x00000F20, 0, 0, 0, 0, 0 } }, | ||
76 | { { 0, 0, 0, 0, 0, 0 } }, | ||
77 | { { 0, 0, 0, 0, 0, 0 } }, | ||
78 | { { 0, 0, 0, 0, 0, 0 } }, | ||
79 | { { 0, 0, 0, 0, 0, 0 } }, | ||
80 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
81 | static const struct IP_BASE MMHUB_BASE ={ { { { 0x0001A000, 0, 0, 0, 0, 0 } }, | ||
82 | { { 0, 0, 0, 0, 0, 0 } }, | ||
83 | { { 0, 0, 0, 0, 0, 0 } }, | ||
84 | { { 0, 0, 0, 0, 0, 0 } }, | ||
85 | { { 0, 0, 0, 0, 0, 0 } }, | ||
86 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
87 | static const struct IP_BASE MP0_BASE ={ { { { 0x00016000, 0, 0, 0, 0, 0 } }, | ||
88 | { { 0, 0, 0, 0, 0, 0 } }, | ||
89 | { { 0, 0, 0, 0, 0, 0 } }, | ||
90 | { { 0, 0, 0, 0, 0, 0 } }, | ||
91 | { { 0, 0, 0, 0, 0, 0 } }, | ||
92 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
93 | static const struct IP_BASE MP1_BASE ={ { { { 0x00016000, 0, 0, 0, 0, 0 } }, | ||
94 | { { 0, 0, 0, 0, 0, 0 } }, | ||
95 | { { 0, 0, 0, 0, 0, 0 } }, | ||
96 | { { 0, 0, 0, 0, 0, 0 } }, | ||
97 | { { 0, 0, 0, 0, 0, 0 } }, | ||
98 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
99 | static const struct IP_BASE NBIO_BASE ={ { { { 0x00000000, 0x00000014, 0x00000D20, 0x00010400, 0, 0 } }, | ||
100 | { { 0, 0, 0, 0, 0, 0 } }, | ||
101 | { { 0, 0, 0, 0, 0, 0 } }, | ||
102 | { { 0, 0, 0, 0, 0, 0 } }, | ||
103 | { { 0, 0, 0, 0, 0, 0 } }, | ||
104 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
105 | static const struct IP_BASE OSSSYS_BASE ={ { { { 0x000010A0, 0, 0, 0, 0, 0 } }, | ||
106 | { { 0, 0, 0, 0, 0, 0 } }, | ||
107 | { { 0, 0, 0, 0, 0, 0 } }, | ||
108 | { { 0, 0, 0, 0, 0, 0 } }, | ||
109 | { { 0, 0, 0, 0, 0, 0 } }, | ||
110 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
111 | static const struct IP_BASE SDMA0_BASE ={ { { { 0x00001260, 0, 0, 0, 0, 0 } }, | ||
112 | { { 0, 0, 0, 0, 0, 0 } }, | ||
113 | { { 0, 0, 0, 0, 0, 0 } }, | ||
114 | { { 0, 0, 0, 0, 0, 0 } }, | ||
115 | { { 0, 0, 0, 0, 0, 0 } }, | ||
116 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
117 | static const struct IP_BASE SDMA1_BASE ={ { { { 0x00001860, 0, 0, 0, 0, 0 } }, | ||
118 | { { 0, 0, 0, 0, 0, 0 } }, | ||
119 | { { 0, 0, 0, 0, 0, 0 } }, | ||
120 | { { 0, 0, 0, 0, 0, 0 } }, | ||
121 | { { 0, 0, 0, 0, 0, 0 } }, | ||
122 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
123 | static const struct IP_BASE SMUIO_BASE ={ { { { 0x00016800, 0x00016A00, 0, 0, 0, 0 } }, | ||
124 | { { 0, 0, 0, 0, 0, 0 } }, | ||
125 | { { 0, 0, 0, 0, 0, 0 } }, | ||
126 | { { 0, 0, 0, 0, 0, 0 } }, | ||
127 | { { 0, 0, 0, 0, 0, 0 } }, | ||
128 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
129 | static const struct IP_BASE THM_BASE ={ { { { 0x00016600, 0, 0, 0, 0, 0 } }, | ||
130 | { { 0, 0, 0, 0, 0, 0 } }, | ||
131 | { { 0, 0, 0, 0, 0, 0 } }, | ||
132 | { { 0, 0, 0, 0, 0, 0 } }, | ||
133 | { { 0, 0, 0, 0, 0, 0 } }, | ||
134 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
135 | static const struct IP_BASE UMC_BASE ={ { { { 0x00014000, 0, 0, 0, 0, 0 } }, | ||
136 | { { 0, 0, 0, 0, 0, 0 } }, | ||
137 | { { 0, 0, 0, 0, 0, 0 } }, | ||
138 | { { 0, 0, 0, 0, 0, 0 } }, | ||
139 | { { 0, 0, 0, 0, 0, 0 } }, | ||
140 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
141 | static const struct IP_BASE UVD_BASE ={ { { { 0x00007800, 0x00007E00, 0, 0, 0, 0 } }, | ||
142 | { { 0, 0x00009000, 0, 0, 0, 0 } }, | ||
143 | { { 0, 0, 0, 0, 0, 0 } }, | ||
144 | { { 0, 0, 0, 0, 0, 0 } }, | ||
145 | { { 0, 0, 0, 0, 0, 0 } }, | ||
146 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
147 | /* Adjust VCE_BASE to make vce_4_1 use vce_4_0 offset header files*/ | ||
148 | static const struct IP_BASE VCE_BASE ={ { { { 0x00007E00/* 0x00008800 */, 0, 0, 0, 0, 0 } }, | ||
149 | { { 0, 0, 0, 0, 0, 0 } }, | ||
150 | { { 0, 0, 0, 0, 0, 0 } }, | ||
151 | { { 0, 0, 0, 0, 0, 0 } }, | ||
152 | { { 0, 0, 0, 0, 0, 0 } }, | ||
153 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
154 | static const struct IP_BASE XDMA_BASE ={ { { { 0x00003400, 0, 0, 0, 0, 0 } }, | ||
155 | { { 0, 0, 0, 0, 0, 0 } }, | ||
156 | { { 0, 0, 0, 0, 0, 0 } }, | ||
157 | { { 0, 0, 0, 0, 0, 0 } }, | ||
158 | { { 0, 0, 0, 0, 0, 0 } }, | ||
159 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
160 | static const struct IP_BASE RSMU_BASE ={ { { { 0x00012000, 0, 0, 0, 0, 0 } }, | ||
161 | { { 0, 0, 0, 0, 0, 0 } }, | ||
162 | { { 0, 0, 0, 0, 0, 0 } }, | ||
163 | { { 0, 0, 0, 0, 0, 0 } }, | ||
164 | { { 0, 0, 0, 0, 0, 0 } }, | ||
165 | { { 0, 0, 0, 0, 0, 0 } } } }; | ||
166 | |||
167 | |||
168 | #define ATHUB_BASE__INST0_SEG0 0x00000C20 | ||
169 | #define ATHUB_BASE__INST0_SEG1 0 | ||
170 | #define ATHUB_BASE__INST0_SEG2 0 | ||
171 | #define ATHUB_BASE__INST0_SEG3 0 | ||
172 | #define ATHUB_BASE__INST0_SEG4 0 | ||
173 | #define ATHUB_BASE__INST0_SEG5 0 | ||
174 | |||
175 | #define ATHUB_BASE__INST1_SEG0 0 | ||
176 | #define ATHUB_BASE__INST1_SEG1 0 | ||
177 | #define ATHUB_BASE__INST1_SEG2 0 | ||
178 | #define ATHUB_BASE__INST1_SEG3 0 | ||
179 | #define ATHUB_BASE__INST1_SEG4 0 | ||
180 | #define ATHUB_BASE__INST1_SEG5 0 | ||
181 | |||
182 | #define ATHUB_BASE__INST2_SEG0 0 | ||
183 | #define ATHUB_BASE__INST2_SEG1 0 | ||
184 | #define ATHUB_BASE__INST2_SEG2 0 | ||
185 | #define ATHUB_BASE__INST2_SEG3 0 | ||
186 | #define ATHUB_BASE__INST2_SEG4 0 | ||
187 | #define ATHUB_BASE__INST2_SEG5 0 | ||
188 | |||
189 | #define ATHUB_BASE__INST3_SEG0 0 | ||
190 | #define ATHUB_BASE__INST3_SEG1 0 | ||
191 | #define ATHUB_BASE__INST3_SEG2 0 | ||
192 | #define ATHUB_BASE__INST3_SEG3 0 | ||
193 | #define ATHUB_BASE__INST3_SEG4 0 | ||
194 | #define ATHUB_BASE__INST3_SEG5 0 | ||
195 | |||
196 | #define ATHUB_BASE__INST4_SEG0 0 | ||
197 | #define ATHUB_BASE__INST4_SEG1 0 | ||
198 | #define ATHUB_BASE__INST4_SEG2 0 | ||
199 | #define ATHUB_BASE__INST4_SEG3 0 | ||
200 | #define ATHUB_BASE__INST4_SEG4 0 | ||
201 | #define ATHUB_BASE__INST4_SEG5 0 | ||
202 | |||
203 | #define ATHUB_BASE__INST5_SEG0 0 | ||
204 | #define ATHUB_BASE__INST5_SEG1 0 | ||
205 | #define ATHUB_BASE__INST5_SEG2 0 | ||
206 | #define ATHUB_BASE__INST5_SEG3 0 | ||
207 | #define ATHUB_BASE__INST5_SEG4 0 | ||
208 | #define ATHUB_BASE__INST5_SEG5 0 | ||
209 | |||
210 | #define CLK_BASE__INST0_SEG0 0x00016C00 | ||
211 | #define CLK_BASE__INST0_SEG1 0x00016E00 | ||
212 | #define CLK_BASE__INST0_SEG2 0x00017000 | ||
213 | #define CLK_BASE__INST0_SEG3 0x00017200 | ||
214 | #define CLK_BASE__INST0_SEG4 0x0001B000 | ||
215 | #define CLK_BASE__INST0_SEG5 0x0001B200 | ||
216 | |||
217 | #define CLK_BASE__INST1_SEG0 0 | ||
218 | #define CLK_BASE__INST1_SEG1 0 | ||
219 | #define CLK_BASE__INST1_SEG2 0 | ||
220 | #define CLK_BASE__INST1_SEG3 0 | ||
221 | #define CLK_BASE__INST1_SEG4 0 | ||
222 | #define CLK_BASE__INST1_SEG5 0 | ||
223 | |||
224 | #define CLK_BASE__INST2_SEG0 0 | ||
225 | #define CLK_BASE__INST2_SEG1 0 | ||
226 | #define CLK_BASE__INST2_SEG2 0 | ||
227 | #define CLK_BASE__INST2_SEG3 0 | ||
228 | #define CLK_BASE__INST2_SEG4 0 | ||
229 | #define CLK_BASE__INST2_SEG5 0 | ||
230 | |||
231 | #define CLK_BASE__INST3_SEG0 0 | ||
232 | #define CLK_BASE__INST3_SEG1 0 | ||
233 | #define CLK_BASE__INST3_SEG2 0 | ||
234 | #define CLK_BASE__INST3_SEG3 0 | ||
235 | #define CLK_BASE__INST3_SEG4 0 | ||
236 | #define CLK_BASE__INST3_SEG5 0 | ||
237 | |||
238 | #define CLK_BASE__INST4_SEG0 0 | ||
239 | #define CLK_BASE__INST4_SEG1 0 | ||
240 | #define CLK_BASE__INST4_SEG2 0 | ||
241 | #define CLK_BASE__INST4_SEG3 0 | ||
242 | #define CLK_BASE__INST4_SEG4 0 | ||
243 | #define CLK_BASE__INST4_SEG5 0 | ||
244 | |||
245 | #define CLK_BASE__INST5_SEG0 0 | ||
246 | #define CLK_BASE__INST5_SEG1 0 | ||
247 | #define CLK_BASE__INST5_SEG2 0 | ||
248 | #define CLK_BASE__INST5_SEG3 0 | ||
249 | #define CLK_BASE__INST5_SEG4 0 | ||
250 | #define CLK_BASE__INST5_SEG5 0 | ||
251 | |||
252 | #define DCE_BASE__INST0_SEG0 0x00000012 | ||
253 | #define DCE_BASE__INST0_SEG1 0x000000C0 | ||
254 | #define DCE_BASE__INST0_SEG2 0x000034C0 | ||
255 | #define DCE_BASE__INST0_SEG3 0 | ||
256 | #define DCE_BASE__INST0_SEG4 0 | ||
257 | #define DCE_BASE__INST0_SEG5 0 | ||
258 | |||
259 | #define DCE_BASE__INST1_SEG0 0 | ||
260 | #define DCE_BASE__INST1_SEG1 0 | ||
261 | #define DCE_BASE__INST1_SEG2 0 | ||
262 | #define DCE_BASE__INST1_SEG3 0 | ||
263 | #define DCE_BASE__INST1_SEG4 0 | ||
264 | #define DCE_BASE__INST1_SEG5 0 | ||
265 | |||
266 | #define DCE_BASE__INST2_SEG0 0 | ||
267 | #define DCE_BASE__INST2_SEG1 0 | ||
268 | #define DCE_BASE__INST2_SEG2 0 | ||
269 | #define DCE_BASE__INST2_SEG3 0 | ||
270 | #define DCE_BASE__INST2_SEG4 0 | ||
271 | #define DCE_BASE__INST2_SEG5 0 | ||
272 | |||
273 | #define DCE_BASE__INST3_SEG0 0 | ||
274 | #define DCE_BASE__INST3_SEG1 0 | ||
275 | #define DCE_BASE__INST3_SEG2 0 | ||
276 | #define DCE_BASE__INST3_SEG3 0 | ||
277 | #define DCE_BASE__INST3_SEG4 0 | ||
278 | #define DCE_BASE__INST3_SEG5 0 | ||
279 | |||
280 | #define DCE_BASE__INST4_SEG0 0 | ||
281 | #define DCE_BASE__INST4_SEG1 0 | ||
282 | #define DCE_BASE__INST4_SEG2 0 | ||
283 | #define DCE_BASE__INST4_SEG3 0 | ||
284 | #define DCE_BASE__INST4_SEG4 0 | ||
285 | #define DCE_BASE__INST4_SEG5 0 | ||
286 | |||
287 | #define DCE_BASE__INST5_SEG0 0 | ||
288 | #define DCE_BASE__INST5_SEG1 0 | ||
289 | #define DCE_BASE__INST5_SEG2 0 | ||
290 | #define DCE_BASE__INST5_SEG3 0 | ||
291 | #define DCE_BASE__INST5_SEG4 0 | ||
292 | #define DCE_BASE__INST5_SEG5 0 | ||
293 | |||
294 | #define DF_BASE__INST0_SEG0 0x00007000 | ||
295 | #define DF_BASE__INST0_SEG1 0 | ||
296 | #define DF_BASE__INST0_SEG2 0 | ||
297 | #define DF_BASE__INST0_SEG3 0 | ||
298 | #define DF_BASE__INST0_SEG4 0 | ||
299 | #define DF_BASE__INST0_SEG5 0 | ||
300 | |||
301 | #define DF_BASE__INST1_SEG0 0 | ||
302 | #define DF_BASE__INST1_SEG1 0 | ||
303 | #define DF_BASE__INST1_SEG2 0 | ||
304 | #define DF_BASE__INST1_SEG3 0 | ||
305 | #define DF_BASE__INST1_SEG4 0 | ||
306 | #define DF_BASE__INST1_SEG5 0 | ||
307 | |||
308 | #define DF_BASE__INST2_SEG0 0 | ||
309 | #define DF_BASE__INST2_SEG1 0 | ||
310 | #define DF_BASE__INST2_SEG2 0 | ||
311 | #define DF_BASE__INST2_SEG3 0 | ||
312 | #define DF_BASE__INST2_SEG4 0 | ||
313 | #define DF_BASE__INST2_SEG5 0 | ||
314 | |||
315 | #define DF_BASE__INST3_SEG0 0 | ||
316 | #define DF_BASE__INST3_SEG1 0 | ||
317 | #define DF_BASE__INST3_SEG2 0 | ||
318 | #define DF_BASE__INST3_SEG3 0 | ||
319 | #define DF_BASE__INST3_SEG4 0 | ||
320 | #define DF_BASE__INST3_SEG5 0 | ||
321 | |||
322 | #define DF_BASE__INST4_SEG0 0 | ||
323 | #define DF_BASE__INST4_SEG1 0 | ||
324 | #define DF_BASE__INST4_SEG2 0 | ||
325 | #define DF_BASE__INST4_SEG3 0 | ||
326 | #define DF_BASE__INST4_SEG4 0 | ||
327 | #define DF_BASE__INST4_SEG5 0 | ||
328 | |||
329 | #define DF_BASE__INST5_SEG0 0 | ||
330 | #define DF_BASE__INST5_SEG1 0 | ||
331 | #define DF_BASE__INST5_SEG2 0 | ||
332 | #define DF_BASE__INST5_SEG3 0 | ||
333 | #define DF_BASE__INST5_SEG4 0 | ||
334 | #define DF_BASE__INST5_SEG5 0 | ||
335 | |||
336 | #define FUSE_BASE__INST0_SEG0 0x00017400 | ||
337 | #define FUSE_BASE__INST0_SEG1 0 | ||
338 | #define FUSE_BASE__INST0_SEG2 0 | ||
339 | #define FUSE_BASE__INST0_SEG3 0 | ||
340 | #define FUSE_BASE__INST0_SEG4 0 | ||
341 | #define FUSE_BASE__INST0_SEG5 0 | ||
342 | |||
343 | #define FUSE_BASE__INST1_SEG0 0 | ||
344 | #define FUSE_BASE__INST1_SEG1 0 | ||
345 | #define FUSE_BASE__INST1_SEG2 0 | ||
346 | #define FUSE_BASE__INST1_SEG3 0 | ||
347 | #define FUSE_BASE__INST1_SEG4 0 | ||
348 | #define FUSE_BASE__INST1_SEG5 0 | ||
349 | |||
350 | #define FUSE_BASE__INST2_SEG0 0 | ||
351 | #define FUSE_BASE__INST2_SEG1 0 | ||
352 | #define FUSE_BASE__INST2_SEG2 0 | ||
353 | #define FUSE_BASE__INST2_SEG3 0 | ||
354 | #define FUSE_BASE__INST2_SEG4 0 | ||
355 | #define FUSE_BASE__INST2_SEG5 0 | ||
356 | |||
357 | #define FUSE_BASE__INST3_SEG0 0 | ||
358 | #define FUSE_BASE__INST3_SEG1 0 | ||
359 | #define FUSE_BASE__INST3_SEG2 0 | ||
360 | #define FUSE_BASE__INST3_SEG3 0 | ||
361 | #define FUSE_BASE__INST3_SEG4 0 | ||
362 | #define FUSE_BASE__INST3_SEG5 0 | ||
363 | |||
364 | #define FUSE_BASE__INST4_SEG0 0 | ||
365 | #define FUSE_BASE__INST4_SEG1 0 | ||
366 | #define FUSE_BASE__INST4_SEG2 0 | ||
367 | #define FUSE_BASE__INST4_SEG3 0 | ||
368 | #define FUSE_BASE__INST4_SEG4 0 | ||
369 | #define FUSE_BASE__INST4_SEG5 0 | ||
370 | |||
371 | #define FUSE_BASE__INST5_SEG0 0 | ||
372 | #define FUSE_BASE__INST5_SEG1 0 | ||
373 | #define FUSE_BASE__INST5_SEG2 0 | ||
374 | #define FUSE_BASE__INST5_SEG3 0 | ||
375 | #define FUSE_BASE__INST5_SEG4 0 | ||
376 | #define FUSE_BASE__INST5_SEG5 0 | ||
377 | |||
378 | #define GC_BASE__INST0_SEG0 0x00002000 | ||
379 | #define GC_BASE__INST0_SEG1 0x0000A000 | ||
380 | #define GC_BASE__INST0_SEG2 0 | ||
381 | #define GC_BASE__INST0_SEG3 0 | ||
382 | #define GC_BASE__INST0_SEG4 0 | ||
383 | #define GC_BASE__INST0_SEG5 0 | ||
384 | |||
385 | #define GC_BASE__INST1_SEG0 0 | ||
386 | #define GC_BASE__INST1_SEG1 0 | ||
387 | #define GC_BASE__INST1_SEG2 0 | ||
388 | #define GC_BASE__INST1_SEG3 0 | ||
389 | #define GC_BASE__INST1_SEG4 0 | ||
390 | #define GC_BASE__INST1_SEG5 0 | ||
391 | |||
392 | #define GC_BASE__INST2_SEG0 0 | ||
393 | #define GC_BASE__INST2_SEG1 0 | ||
394 | #define GC_BASE__INST2_SEG2 0 | ||
395 | #define GC_BASE__INST2_SEG3 0 | ||
396 | #define GC_BASE__INST2_SEG4 0 | ||
397 | #define GC_BASE__INST2_SEG5 0 | ||
398 | |||
399 | #define GC_BASE__INST3_SEG0 0 | ||
400 | #define GC_BASE__INST3_SEG1 0 | ||
401 | #define GC_BASE__INST3_SEG2 0 | ||
402 | #define GC_BASE__INST3_SEG3 0 | ||
403 | #define GC_BASE__INST3_SEG4 0 | ||
404 | #define GC_BASE__INST3_SEG5 0 | ||
405 | |||
406 | #define GC_BASE__INST4_SEG0 0 | ||
407 | #define GC_BASE__INST4_SEG1 0 | ||
408 | #define GC_BASE__INST4_SEG2 0 | ||
409 | #define GC_BASE__INST4_SEG3 0 | ||
410 | #define GC_BASE__INST4_SEG4 0 | ||
411 | #define GC_BASE__INST4_SEG5 0 | ||
412 | |||
413 | #define GC_BASE__INST5_SEG0 0 | ||
414 | #define GC_BASE__INST5_SEG1 0 | ||
415 | #define GC_BASE__INST5_SEG2 0 | ||
416 | #define GC_BASE__INST5_SEG3 0 | ||
417 | #define GC_BASE__INST5_SEG4 0 | ||
418 | #define GC_BASE__INST5_SEG5 0 | ||
419 | |||
420 | #define HDP_BASE__INST0_SEG0 0x00000F20 | ||
421 | #define HDP_BASE__INST0_SEG1 0 | ||
422 | #define HDP_BASE__INST0_SEG2 0 | ||
423 | #define HDP_BASE__INST0_SEG3 0 | ||
424 | #define HDP_BASE__INST0_SEG4 0 | ||
425 | #define HDP_BASE__INST0_SEG5 0 | ||
426 | |||
427 | #define HDP_BASE__INST1_SEG0 0 | ||
428 | #define HDP_BASE__INST1_SEG1 0 | ||
429 | #define HDP_BASE__INST1_SEG2 0 | ||
430 | #define HDP_BASE__INST1_SEG3 0 | ||
431 | #define HDP_BASE__INST1_SEG4 0 | ||
432 | #define HDP_BASE__INST1_SEG5 0 | ||
433 | |||
434 | #define HDP_BASE__INST2_SEG0 0 | ||
435 | #define HDP_BASE__INST2_SEG1 0 | ||
436 | #define HDP_BASE__INST2_SEG2 0 | ||
437 | #define HDP_BASE__INST2_SEG3 0 | ||
438 | #define HDP_BASE__INST2_SEG4 0 | ||
439 | #define HDP_BASE__INST2_SEG5 0 | ||
440 | |||
441 | #define HDP_BASE__INST3_SEG0 0 | ||
442 | #define HDP_BASE__INST3_SEG1 0 | ||
443 | #define HDP_BASE__INST3_SEG2 0 | ||
444 | #define HDP_BASE__INST3_SEG3 0 | ||
445 | #define HDP_BASE__INST3_SEG4 0 | ||
446 | #define HDP_BASE__INST3_SEG5 0 | ||
447 | |||
448 | #define HDP_BASE__INST4_SEG0 0 | ||
449 | #define HDP_BASE__INST4_SEG1 0 | ||
450 | #define HDP_BASE__INST4_SEG2 0 | ||
451 | #define HDP_BASE__INST4_SEG3 0 | ||
452 | #define HDP_BASE__INST4_SEG4 0 | ||
453 | #define HDP_BASE__INST4_SEG5 0 | ||
454 | |||
455 | #define HDP_BASE__INST5_SEG0 0 | ||
456 | #define HDP_BASE__INST5_SEG1 0 | ||
457 | #define HDP_BASE__INST5_SEG2 0 | ||
458 | #define HDP_BASE__INST5_SEG3 0 | ||
459 | #define HDP_BASE__INST5_SEG4 0 | ||
460 | #define HDP_BASE__INST5_SEG5 0 | ||
461 | |||
462 | #define MMHUB_BASE__INST0_SEG0 0x0001A000 | ||
463 | #define MMHUB_BASE__INST0_SEG1 0 | ||
464 | #define MMHUB_BASE__INST0_SEG2 0 | ||
465 | #define MMHUB_BASE__INST0_SEG3 0 | ||
466 | #define MMHUB_BASE__INST0_SEG4 0 | ||
467 | #define MMHUB_BASE__INST0_SEG5 0 | ||
468 | |||
469 | #define MMHUB_BASE__INST1_SEG0 0 | ||
470 | #define MMHUB_BASE__INST1_SEG1 0 | ||
471 | #define MMHUB_BASE__INST1_SEG2 0 | ||
472 | #define MMHUB_BASE__INST1_SEG3 0 | ||
473 | #define MMHUB_BASE__INST1_SEG4 0 | ||
474 | #define MMHUB_BASE__INST1_SEG5 0 | ||
475 | |||
476 | #define MMHUB_BASE__INST2_SEG0 0 | ||
477 | #define MMHUB_BASE__INST2_SEG1 0 | ||
478 | #define MMHUB_BASE__INST2_SEG2 0 | ||
479 | #define MMHUB_BASE__INST2_SEG3 0 | ||
480 | #define MMHUB_BASE__INST2_SEG4 0 | ||
481 | #define MMHUB_BASE__INST2_SEG5 0 | ||
482 | |||
483 | #define MMHUB_BASE__INST3_SEG0 0 | ||
484 | #define MMHUB_BASE__INST3_SEG1 0 | ||
485 | #define MMHUB_BASE__INST3_SEG2 0 | ||
486 | #define MMHUB_BASE__INST3_SEG3 0 | ||
487 | #define MMHUB_BASE__INST3_SEG4 0 | ||
488 | #define MMHUB_BASE__INST3_SEG5 0 | ||
489 | |||
490 | #define MMHUB_BASE__INST4_SEG0 0 | ||
491 | #define MMHUB_BASE__INST4_SEG1 0 | ||
492 | #define MMHUB_BASE__INST4_SEG2 0 | ||
493 | #define MMHUB_BASE__INST4_SEG3 0 | ||
494 | #define MMHUB_BASE__INST4_SEG4 0 | ||
495 | #define MMHUB_BASE__INST4_SEG5 0 | ||
496 | |||
497 | #define MMHUB_BASE__INST5_SEG0 0 | ||
498 | #define MMHUB_BASE__INST5_SEG1 0 | ||
499 | #define MMHUB_BASE__INST5_SEG2 0 | ||
500 | #define MMHUB_BASE__INST5_SEG3 0 | ||
501 | #define MMHUB_BASE__INST5_SEG4 0 | ||
502 | #define MMHUB_BASE__INST5_SEG5 0 | ||
503 | |||
504 | #define MP0_BASE__INST0_SEG0 0x00016000 | ||
505 | #define MP0_BASE__INST0_SEG1 0 | ||
506 | #define MP0_BASE__INST0_SEG2 0 | ||
507 | #define MP0_BASE__INST0_SEG3 0 | ||
508 | #define MP0_BASE__INST0_SEG4 0 | ||
509 | #define MP0_BASE__INST0_SEG5 0 | ||
510 | |||
511 | #define MP0_BASE__INST1_SEG0 0 | ||
512 | #define MP0_BASE__INST1_SEG1 0 | ||
513 | #define MP0_BASE__INST1_SEG2 0 | ||
514 | #define MP0_BASE__INST1_SEG3 0 | ||
515 | #define MP0_BASE__INST1_SEG4 0 | ||
516 | #define MP0_BASE__INST1_SEG5 0 | ||
517 | |||
518 | #define MP0_BASE__INST2_SEG0 0 | ||
519 | #define MP0_BASE__INST2_SEG1 0 | ||
520 | #define MP0_BASE__INST2_SEG2 0 | ||
521 | #define MP0_BASE__INST2_SEG3 0 | ||
522 | #define MP0_BASE__INST2_SEG4 0 | ||
523 | #define MP0_BASE__INST2_SEG5 0 | ||
524 | |||
525 | #define MP0_BASE__INST3_SEG0 0 | ||
526 | #define MP0_BASE__INST3_SEG1 0 | ||
527 | #define MP0_BASE__INST3_SEG2 0 | ||
528 | #define MP0_BASE__INST3_SEG3 0 | ||
529 | #define MP0_BASE__INST3_SEG4 0 | ||
530 | #define MP0_BASE__INST3_SEG5 0 | ||
531 | |||
532 | #define MP0_BASE__INST4_SEG0 0 | ||
533 | #define MP0_BASE__INST4_SEG1 0 | ||
534 | #define MP0_BASE__INST4_SEG2 0 | ||
535 | #define MP0_BASE__INST4_SEG3 0 | ||
536 | #define MP0_BASE__INST4_SEG4 0 | ||
537 | #define MP0_BASE__INST4_SEG5 0 | ||
538 | |||
539 | #define MP0_BASE__INST5_SEG0 0 | ||
540 | #define MP0_BASE__INST5_SEG1 0 | ||
541 | #define MP0_BASE__INST5_SEG2 0 | ||
542 | #define MP0_BASE__INST5_SEG3 0 | ||
543 | #define MP0_BASE__INST5_SEG4 0 | ||
544 | #define MP0_BASE__INST5_SEG5 0 | ||
545 | |||
546 | #define MP1_BASE__INST0_SEG0 0x00016000 | ||
547 | #define MP1_BASE__INST0_SEG1 0 | ||
548 | #define MP1_BASE__INST0_SEG2 0 | ||
549 | #define MP1_BASE__INST0_SEG3 0 | ||
550 | #define MP1_BASE__INST0_SEG4 0 | ||
551 | #define MP1_BASE__INST0_SEG5 0 | ||
552 | |||
553 | #define MP1_BASE__INST1_SEG0 0 | ||
554 | #define MP1_BASE__INST1_SEG1 0 | ||
555 | #define MP1_BASE__INST1_SEG2 0 | ||
556 | #define MP1_BASE__INST1_SEG3 0 | ||
557 | #define MP1_BASE__INST1_SEG4 0 | ||
558 | #define MP1_BASE__INST1_SEG5 0 | ||
559 | |||
560 | #define MP1_BASE__INST2_SEG0 0 | ||
561 | #define MP1_BASE__INST2_SEG1 0 | ||
562 | #define MP1_BASE__INST2_SEG2 0 | ||
563 | #define MP1_BASE__INST2_SEG3 0 | ||
564 | #define MP1_BASE__INST2_SEG4 0 | ||
565 | #define MP1_BASE__INST2_SEG5 0 | ||
566 | |||
567 | #define MP1_BASE__INST3_SEG0 0 | ||
568 | #define MP1_BASE__INST3_SEG1 0 | ||
569 | #define MP1_BASE__INST3_SEG2 0 | ||
570 | #define MP1_BASE__INST3_SEG3 0 | ||
571 | #define MP1_BASE__INST3_SEG4 0 | ||
572 | #define MP1_BASE__INST3_SEG5 0 | ||
573 | |||
574 | #define MP1_BASE__INST4_SEG0 0 | ||
575 | #define MP1_BASE__INST4_SEG1 0 | ||
576 | #define MP1_BASE__INST4_SEG2 0 | ||
577 | #define MP1_BASE__INST4_SEG3 0 | ||
578 | #define MP1_BASE__INST4_SEG4 0 | ||
579 | #define MP1_BASE__INST4_SEG5 0 | ||
580 | |||
581 | #define MP1_BASE__INST5_SEG0 0 | ||
582 | #define MP1_BASE__INST5_SEG1 0 | ||
583 | #define MP1_BASE__INST5_SEG2 0 | ||
584 | #define MP1_BASE__INST5_SEG3 0 | ||
585 | #define MP1_BASE__INST5_SEG4 0 | ||
586 | #define MP1_BASE__INST5_SEG5 0 | ||
587 | |||
588 | #define NBIO_BASE__INST0_SEG0 0x00000000 | ||
589 | #define NBIO_BASE__INST0_SEG1 0x00000014 | ||
590 | #define NBIO_BASE__INST0_SEG2 0x00000D20 | ||
591 | #define NBIO_BASE__INST0_SEG3 0x00010400 | ||
592 | #define NBIO_BASE__INST0_SEG4 0 | ||
593 | #define NBIO_BASE__INST0_SEG5 0 | ||
594 | |||
595 | #define NBIO_BASE__INST1_SEG0 0 | ||
596 | #define NBIO_BASE__INST1_SEG1 0 | ||
597 | #define NBIO_BASE__INST1_SEG2 0 | ||
598 | #define NBIO_BASE__INST1_SEG3 0 | ||
599 | #define NBIO_BASE__INST1_SEG4 0 | ||
600 | #define NBIO_BASE__INST1_SEG5 0 | ||
601 | |||
602 | #define NBIO_BASE__INST2_SEG0 0 | ||
603 | #define NBIO_BASE__INST2_SEG1 0 | ||
604 | #define NBIO_BASE__INST2_SEG2 0 | ||
605 | #define NBIO_BASE__INST2_SEG3 0 | ||
606 | #define NBIO_BASE__INST2_SEG4 0 | ||
607 | #define NBIO_BASE__INST2_SEG5 0 | ||
608 | |||
609 | #define NBIO_BASE__INST3_SEG0 0 | ||
610 | #define NBIO_BASE__INST3_SEG1 0 | ||
611 | #define NBIO_BASE__INST3_SEG2 0 | ||
612 | #define NBIO_BASE__INST3_SEG3 0 | ||
613 | #define NBIO_BASE__INST3_SEG4 0 | ||
614 | #define NBIO_BASE__INST3_SEG5 0 | ||
615 | |||
616 | #define NBIO_BASE__INST4_SEG0 0 | ||
617 | #define NBIO_BASE__INST4_SEG1 0 | ||
618 | #define NBIO_BASE__INST4_SEG2 0 | ||
619 | #define NBIO_BASE__INST4_SEG3 0 | ||
620 | #define NBIO_BASE__INST4_SEG4 0 | ||
621 | #define NBIO_BASE__INST4_SEG5 0 | ||
622 | |||
623 | #define NBIO_BASE__INST5_SEG0 0 | ||
624 | #define NBIO_BASE__INST5_SEG1 0 | ||
625 | #define NBIO_BASE__INST5_SEG2 0 | ||
626 | #define NBIO_BASE__INST5_SEG3 0 | ||
627 | #define NBIO_BASE__INST5_SEG4 0 | ||
628 | #define NBIO_BASE__INST5_SEG5 0 | ||
629 | |||
630 | #define OSSSYS_BASE__INST0_SEG0 0x000010A0 | ||
631 | #define OSSSYS_BASE__INST0_SEG1 0 | ||
632 | #define OSSSYS_BASE__INST0_SEG2 0 | ||
633 | #define OSSSYS_BASE__INST0_SEG3 0 | ||
634 | #define OSSSYS_BASE__INST0_SEG4 0 | ||
635 | #define OSSSYS_BASE__INST0_SEG5 0 | ||
636 | |||
637 | #define OSSSYS_BASE__INST1_SEG0 0 | ||
638 | #define OSSSYS_BASE__INST1_SEG1 0 | ||
639 | #define OSSSYS_BASE__INST1_SEG2 0 | ||
640 | #define OSSSYS_BASE__INST1_SEG3 0 | ||
641 | #define OSSSYS_BASE__INST1_SEG4 0 | ||
642 | #define OSSSYS_BASE__INST1_SEG5 0 | ||
643 | |||
644 | #define OSSSYS_BASE__INST2_SEG0 0 | ||
645 | #define OSSSYS_BASE__INST2_SEG1 0 | ||
646 | #define OSSSYS_BASE__INST2_SEG2 0 | ||
647 | #define OSSSYS_BASE__INST2_SEG3 0 | ||
648 | #define OSSSYS_BASE__INST2_SEG4 0 | ||
649 | #define OSSSYS_BASE__INST2_SEG5 0 | ||
650 | |||
651 | #define OSSSYS_BASE__INST3_SEG0 0 | ||
652 | #define OSSSYS_BASE__INST3_SEG1 0 | ||
653 | #define OSSSYS_BASE__INST3_SEG2 0 | ||
654 | #define OSSSYS_BASE__INST3_SEG3 0 | ||
655 | #define OSSSYS_BASE__INST3_SEG4 0 | ||
656 | #define OSSSYS_BASE__INST3_SEG5 0 | ||
657 | |||
658 | #define OSSSYS_BASE__INST4_SEG0 0 | ||
659 | #define OSSSYS_BASE__INST4_SEG1 0 | ||
660 | #define OSSSYS_BASE__INST4_SEG2 0 | ||
661 | #define OSSSYS_BASE__INST4_SEG3 0 | ||
662 | #define OSSSYS_BASE__INST4_SEG4 0 | ||
663 | #define OSSSYS_BASE__INST4_SEG5 0 | ||
664 | |||
665 | #define OSSSYS_BASE__INST5_SEG0 0 | ||
666 | #define OSSSYS_BASE__INST5_SEG1 0 | ||
667 | #define OSSSYS_BASE__INST5_SEG2 0 | ||
668 | #define OSSSYS_BASE__INST5_SEG3 0 | ||
669 | #define OSSSYS_BASE__INST5_SEG4 0 | ||
670 | #define OSSSYS_BASE__INST5_SEG5 0 | ||
671 | |||
672 | #define SDMA0_BASE__INST0_SEG0 0x00001260 | ||
673 | #define SDMA0_BASE__INST0_SEG1 0 | ||
674 | #define SDMA0_BASE__INST0_SEG2 0 | ||
675 | #define SDMA0_BASE__INST0_SEG3 0 | ||
676 | #define SDMA0_BASE__INST0_SEG4 0 | ||
677 | #define SDMA0_BASE__INST0_SEG5 0 | ||
678 | |||
679 | #define SDMA0_BASE__INST1_SEG0 0 | ||
680 | #define SDMA0_BASE__INST1_SEG1 0 | ||
681 | #define SDMA0_BASE__INST1_SEG2 0 | ||
682 | #define SDMA0_BASE__INST1_SEG3 0 | ||
683 | #define SDMA0_BASE__INST1_SEG4 0 | ||
684 | #define SDMA0_BASE__INST1_SEG5 0 | ||
685 | |||
686 | #define SDMA0_BASE__INST2_SEG0 0 | ||
687 | #define SDMA0_BASE__INST2_SEG1 0 | ||
688 | #define SDMA0_BASE__INST2_SEG2 0 | ||
689 | #define SDMA0_BASE__INST2_SEG3 0 | ||
690 | #define SDMA0_BASE__INST2_SEG4 0 | ||
691 | #define SDMA0_BASE__INST2_SEG5 0 | ||
692 | |||
693 | #define SDMA0_BASE__INST3_SEG0 0 | ||
694 | #define SDMA0_BASE__INST3_SEG1 0 | ||
695 | #define SDMA0_BASE__INST3_SEG2 0 | ||
696 | #define SDMA0_BASE__INST3_SEG3 0 | ||
697 | #define SDMA0_BASE__INST3_SEG4 0 | ||
698 | #define SDMA0_BASE__INST3_SEG5 0 | ||
699 | |||
700 | #define SDMA0_BASE__INST4_SEG0 0 | ||
701 | #define SDMA0_BASE__INST4_SEG1 0 | ||
702 | #define SDMA0_BASE__INST4_SEG2 0 | ||
703 | #define SDMA0_BASE__INST4_SEG3 0 | ||
704 | #define SDMA0_BASE__INST4_SEG4 0 | ||
705 | #define SDMA0_BASE__INST4_SEG5 0 | ||
706 | |||
707 | #define SDMA0_BASE__INST5_SEG0 0 | ||
708 | #define SDMA0_BASE__INST5_SEG1 0 | ||
709 | #define SDMA0_BASE__INST5_SEG2 0 | ||
710 | #define SDMA0_BASE__INST5_SEG3 0 | ||
711 | #define SDMA0_BASE__INST5_SEG4 0 | ||
712 | #define SDMA0_BASE__INST5_SEG5 0 | ||
713 | |||
714 | #define SDMA1_BASE__INST0_SEG0 0x00001860 | ||
715 | #define SDMA1_BASE__INST0_SEG1 0 | ||
716 | #define SDMA1_BASE__INST0_SEG2 0 | ||
717 | #define SDMA1_BASE__INST0_SEG3 0 | ||
718 | #define SDMA1_BASE__INST0_SEG4 0 | ||
719 | #define SDMA1_BASE__INST0_SEG5 0 | ||
720 | |||
721 | #define SDMA1_BASE__INST1_SEG0 0 | ||
722 | #define SDMA1_BASE__INST1_SEG1 0 | ||
723 | #define SDMA1_BASE__INST1_SEG2 0 | ||
724 | #define SDMA1_BASE__INST1_SEG3 0 | ||
725 | #define SDMA1_BASE__INST1_SEG4 0 | ||
726 | #define SDMA1_BASE__INST1_SEG5 0 | ||
727 | |||
728 | #define SDMA1_BASE__INST2_SEG0 0 | ||
729 | #define SDMA1_BASE__INST2_SEG1 0 | ||
730 | #define SDMA1_BASE__INST2_SEG2 0 | ||
731 | #define SDMA1_BASE__INST2_SEG3 0 | ||
732 | #define SDMA1_BASE__INST2_SEG4 0 | ||
733 | #define SDMA1_BASE__INST2_SEG5 0 | ||
734 | |||
735 | #define SDMA1_BASE__INST3_SEG0 0 | ||
736 | #define SDMA1_BASE__INST3_SEG1 0 | ||
737 | #define SDMA1_BASE__INST3_SEG2 0 | ||
738 | #define SDMA1_BASE__INST3_SEG3 0 | ||
739 | #define SDMA1_BASE__INST3_SEG4 0 | ||
740 | #define SDMA1_BASE__INST3_SEG5 0 | ||
741 | |||
742 | #define SDMA1_BASE__INST4_SEG0 0 | ||
743 | #define SDMA1_BASE__INST4_SEG1 0 | ||
744 | #define SDMA1_BASE__INST4_SEG2 0 | ||
745 | #define SDMA1_BASE__INST4_SEG3 0 | ||
746 | #define SDMA1_BASE__INST4_SEG4 0 | ||
747 | #define SDMA1_BASE__INST4_SEG5 0 | ||
748 | |||
749 | #define SDMA1_BASE__INST5_SEG0 0 | ||
750 | #define SDMA1_BASE__INST5_SEG1 0 | ||
751 | #define SDMA1_BASE__INST5_SEG2 0 | ||
752 | #define SDMA1_BASE__INST5_SEG3 0 | ||
753 | #define SDMA1_BASE__INST5_SEG4 0 | ||
754 | #define SDMA1_BASE__INST5_SEG5 0 | ||
755 | |||
756 | #define SMUIO_BASE__INST0_SEG0 0x00016800 | ||
757 | #define SMUIO_BASE__INST0_SEG1 0x00016A00 | ||
758 | #define SMUIO_BASE__INST0_SEG2 0 | ||
759 | #define SMUIO_BASE__INST0_SEG3 0 | ||
760 | #define SMUIO_BASE__INST0_SEG4 0 | ||
761 | #define SMUIO_BASE__INST0_SEG5 0 | ||
762 | |||
763 | #define SMUIO_BASE__INST1_SEG0 0 | ||
764 | #define SMUIO_BASE__INST1_SEG1 0 | ||
765 | #define SMUIO_BASE__INST1_SEG2 0 | ||
766 | #define SMUIO_BASE__INST1_SEG3 0 | ||
767 | #define SMUIO_BASE__INST1_SEG4 0 | ||
768 | #define SMUIO_BASE__INST1_SEG5 0 | ||
769 | |||
770 | #define SMUIO_BASE__INST2_SEG0 0 | ||
771 | #define SMUIO_BASE__INST2_SEG1 0 | ||
772 | #define SMUIO_BASE__INST2_SEG2 0 | ||
773 | #define SMUIO_BASE__INST2_SEG3 0 | ||
774 | #define SMUIO_BASE__INST2_SEG4 0 | ||
775 | #define SMUIO_BASE__INST2_SEG5 0 | ||
776 | |||
777 | #define SMUIO_BASE__INST3_SEG0 0 | ||
778 | #define SMUIO_BASE__INST3_SEG1 0 | ||
779 | #define SMUIO_BASE__INST3_SEG2 0 | ||
780 | #define SMUIO_BASE__INST3_SEG3 0 | ||
781 | #define SMUIO_BASE__INST3_SEG4 0 | ||
782 | #define SMUIO_BASE__INST3_SEG5 0 | ||
783 | |||
784 | #define SMUIO_BASE__INST4_SEG0 0 | ||
785 | #define SMUIO_BASE__INST4_SEG1 0 | ||
786 | #define SMUIO_BASE__INST4_SEG2 0 | ||
787 | #define SMUIO_BASE__INST4_SEG3 0 | ||
788 | #define SMUIO_BASE__INST4_SEG4 0 | ||
789 | #define SMUIO_BASE__INST4_SEG5 0 | ||
790 | |||
791 | #define SMUIO_BASE__INST5_SEG0 0 | ||
792 | #define SMUIO_BASE__INST5_SEG1 0 | ||
793 | #define SMUIO_BASE__INST5_SEG2 0 | ||
794 | #define SMUIO_BASE__INST5_SEG3 0 | ||
795 | #define SMUIO_BASE__INST5_SEG4 0 | ||
796 | #define SMUIO_BASE__INST5_SEG5 0 | ||
797 | |||
798 | #define THM_BASE__INST0_SEG0 0x00016600 | ||
799 | #define THM_BASE__INST0_SEG1 0 | ||
800 | #define THM_BASE__INST0_SEG2 0 | ||
801 | #define THM_BASE__INST0_SEG3 0 | ||
802 | #define THM_BASE__INST0_SEG4 0 | ||
803 | #define THM_BASE__INST0_SEG5 0 | ||
804 | |||
805 | #define THM_BASE__INST1_SEG0 0 | ||
806 | #define THM_BASE__INST1_SEG1 0 | ||
807 | #define THM_BASE__INST1_SEG2 0 | ||
808 | #define THM_BASE__INST1_SEG3 0 | ||
809 | #define THM_BASE__INST1_SEG4 0 | ||
810 | #define THM_BASE__INST1_SEG5 0 | ||
811 | |||
812 | #define THM_BASE__INST2_SEG0 0 | ||
813 | #define THM_BASE__INST2_SEG1 0 | ||
814 | #define THM_BASE__INST2_SEG2 0 | ||
815 | #define THM_BASE__INST2_SEG3 0 | ||
816 | #define THM_BASE__INST2_SEG4 0 | ||
817 | #define THM_BASE__INST2_SEG5 0 | ||
818 | |||
819 | #define THM_BASE__INST3_SEG0 0 | ||
820 | #define THM_BASE__INST3_SEG1 0 | ||
821 | #define THM_BASE__INST3_SEG2 0 | ||
822 | #define THM_BASE__INST3_SEG3 0 | ||
823 | #define THM_BASE__INST3_SEG4 0 | ||
824 | #define THM_BASE__INST3_SEG5 0 | ||
825 | |||
826 | #define THM_BASE__INST4_SEG0 0 | ||
827 | #define THM_BASE__INST4_SEG1 0 | ||
828 | #define THM_BASE__INST4_SEG2 0 | ||
829 | #define THM_BASE__INST4_SEG3 0 | ||
830 | #define THM_BASE__INST4_SEG4 0 | ||
831 | #define THM_BASE__INST4_SEG5 0 | ||
832 | |||
833 | #define THM_BASE__INST5_SEG0 0 | ||
834 | #define THM_BASE__INST5_SEG1 0 | ||
835 | #define THM_BASE__INST5_SEG2 0 | ||
836 | #define THM_BASE__INST5_SEG3 0 | ||
837 | #define THM_BASE__INST5_SEG4 0 | ||
838 | #define THM_BASE__INST5_SEG5 0 | ||
839 | |||
840 | #define UMC_BASE__INST0_SEG0 0x00014000 | ||
841 | #define UMC_BASE__INST0_SEG1 0 | ||
842 | #define UMC_BASE__INST0_SEG2 0 | ||
843 | #define UMC_BASE__INST0_SEG3 0 | ||
844 | #define UMC_BASE__INST0_SEG4 0 | ||
845 | #define UMC_BASE__INST0_SEG5 0 | ||
846 | |||
847 | #define UMC_BASE__INST1_SEG0 0 | ||
848 | #define UMC_BASE__INST1_SEG1 0 | ||
849 | #define UMC_BASE__INST1_SEG2 0 | ||
850 | #define UMC_BASE__INST1_SEG3 0 | ||
851 | #define UMC_BASE__INST1_SEG4 0 | ||
852 | #define UMC_BASE__INST1_SEG5 0 | ||
853 | |||
854 | #define UMC_BASE__INST2_SEG0 0 | ||
855 | #define UMC_BASE__INST2_SEG1 0 | ||
856 | #define UMC_BASE__INST2_SEG2 0 | ||
857 | #define UMC_BASE__INST2_SEG3 0 | ||
858 | #define UMC_BASE__INST2_SEG4 0 | ||
859 | #define UMC_BASE__INST2_SEG5 0 | ||
860 | |||
861 | #define UMC_BASE__INST3_SEG0 0 | ||
862 | #define UMC_BASE__INST3_SEG1 0 | ||
863 | #define UMC_BASE__INST3_SEG2 0 | ||
864 | #define UMC_BASE__INST3_SEG3 0 | ||
865 | #define UMC_BASE__INST3_SEG4 0 | ||
866 | #define UMC_BASE__INST3_SEG5 0 | ||
867 | |||
868 | #define UMC_BASE__INST4_SEG0 0 | ||
869 | #define UMC_BASE__INST4_SEG1 0 | ||
870 | #define UMC_BASE__INST4_SEG2 0 | ||
871 | #define UMC_BASE__INST4_SEG3 0 | ||
872 | #define UMC_BASE__INST4_SEG4 0 | ||
873 | #define UMC_BASE__INST4_SEG5 0 | ||
874 | |||
875 | #define UMC_BASE__INST5_SEG0 0 | ||
876 | #define UMC_BASE__INST5_SEG1 0 | ||
877 | #define UMC_BASE__INST5_SEG2 0 | ||
878 | #define UMC_BASE__INST5_SEG3 0 | ||
879 | #define UMC_BASE__INST5_SEG4 0 | ||
880 | #define UMC_BASE__INST5_SEG5 0 | ||
881 | |||
882 | #define UVD_BASE__INST0_SEG0 0x00007800 | ||
883 | #define UVD_BASE__INST0_SEG1 0x00007E00 | ||
884 | #define UVD_BASE__INST0_SEG2 0 | ||
885 | #define UVD_BASE__INST0_SEG3 0 | ||
886 | #define UVD_BASE__INST0_SEG4 0 | ||
887 | #define UVD_BASE__INST0_SEG5 0 | ||
888 | |||
889 | #define UVD_BASE__INST1_SEG0 0 | ||
890 | #define UVD_BASE__INST1_SEG1 0x00009000 | ||
891 | #define UVD_BASE__INST1_SEG2 0 | ||
892 | #define UVD_BASE__INST1_SEG3 0 | ||
893 | #define UVD_BASE__INST1_SEG4 0 | ||
894 | #define UVD_BASE__INST1_SEG5 0 | ||
895 | |||
896 | #define UVD_BASE__INST2_SEG0 0 | ||
897 | #define UVD_BASE__INST2_SEG1 0 | ||
898 | #define UVD_BASE__INST2_SEG2 0 | ||
899 | #define UVD_BASE__INST2_SEG3 0 | ||
900 | #define UVD_BASE__INST2_SEG4 0 | ||
901 | #define UVD_BASE__INST2_SEG5 0 | ||
902 | |||
903 | #define UVD_BASE__INST3_SEG0 0 | ||
904 | #define UVD_BASE__INST3_SEG1 0 | ||
905 | #define UVD_BASE__INST3_SEG2 0 | ||
906 | #define UVD_BASE__INST3_SEG3 0 | ||
907 | #define UVD_BASE__INST3_SEG4 0 | ||
908 | #define UVD_BASE__INST3_SEG5 0 | ||
909 | |||
910 | #define UVD_BASE__INST4_SEG0 0 | ||
911 | #define UVD_BASE__INST4_SEG1 0 | ||
912 | #define UVD_BASE__INST4_SEG2 0 | ||
913 | #define UVD_BASE__INST4_SEG3 0 | ||
914 | #define UVD_BASE__INST4_SEG4 0 | ||
915 | #define UVD_BASE__INST4_SEG5 0 | ||
916 | |||
917 | #define UVD_BASE__INST5_SEG0 0 | ||
918 | #define UVD_BASE__INST5_SEG1 0 | ||
919 | #define UVD_BASE__INST5_SEG2 0 | ||
920 | #define UVD_BASE__INST5_SEG3 0 | ||
921 | #define UVD_BASE__INST5_SEG4 0 | ||
922 | #define UVD_BASE__INST5_SEG5 0 | ||
923 | |||
924 | #define VCE_BASE__INST0_SEG0 0x00008800 | ||
925 | #define VCE_BASE__INST0_SEG1 0 | ||
926 | #define VCE_BASE__INST0_SEG2 0 | ||
927 | #define VCE_BASE__INST0_SEG3 0 | ||
928 | #define VCE_BASE__INST0_SEG4 0 | ||
929 | #define VCE_BASE__INST0_SEG5 0 | ||
930 | |||
931 | #define VCE_BASE__INST1_SEG0 0 | ||
932 | #define VCE_BASE__INST1_SEG1 0 | ||
933 | #define VCE_BASE__INST1_SEG2 0 | ||
934 | #define VCE_BASE__INST1_SEG3 0 | ||
935 | #define VCE_BASE__INST1_SEG4 0 | ||
936 | #define VCE_BASE__INST1_SEG5 0 | ||
937 | |||
938 | #define VCE_BASE__INST2_SEG0 0 | ||
939 | #define VCE_BASE__INST2_SEG1 0 | ||
940 | #define VCE_BASE__INST2_SEG2 0 | ||
941 | #define VCE_BASE__INST2_SEG3 0 | ||
942 | #define VCE_BASE__INST2_SEG4 0 | ||
943 | #define VCE_BASE__INST2_SEG5 0 | ||
944 | |||
945 | #define VCE_BASE__INST3_SEG0 0 | ||
946 | #define VCE_BASE__INST3_SEG1 0 | ||
947 | #define VCE_BASE__INST3_SEG2 0 | ||
948 | #define VCE_BASE__INST3_SEG3 0 | ||
949 | #define VCE_BASE__INST3_SEG4 0 | ||
950 | #define VCE_BASE__INST3_SEG5 0 | ||
951 | |||
952 | #define VCE_BASE__INST4_SEG0 0 | ||
953 | #define VCE_BASE__INST4_SEG1 0 | ||
954 | #define VCE_BASE__INST4_SEG2 0 | ||
955 | #define VCE_BASE__INST4_SEG3 0 | ||
956 | #define VCE_BASE__INST4_SEG4 0 | ||
957 | #define VCE_BASE__INST4_SEG5 0 | ||
958 | |||
959 | #define VCE_BASE__INST5_SEG0 0 | ||
960 | #define VCE_BASE__INST5_SEG1 0 | ||
961 | #define VCE_BASE__INST5_SEG2 0 | ||
962 | #define VCE_BASE__INST5_SEG3 0 | ||
963 | #define VCE_BASE__INST5_SEG4 0 | ||
964 | #define VCE_BASE__INST5_SEG5 0 | ||
965 | |||
966 | #define XDMA_BASE__INST0_SEG0 0x00003400 | ||
967 | #define XDMA_BASE__INST0_SEG1 0 | ||
968 | #define XDMA_BASE__INST0_SEG2 0 | ||
969 | #define XDMA_BASE__INST0_SEG3 0 | ||
970 | #define XDMA_BASE__INST0_SEG4 0 | ||
971 | #define XDMA_BASE__INST0_SEG5 0 | ||
972 | |||
973 | #define XDMA_BASE__INST1_SEG0 0 | ||
974 | #define XDMA_BASE__INST1_SEG1 0 | ||
975 | #define XDMA_BASE__INST1_SEG2 0 | ||
976 | #define XDMA_BASE__INST1_SEG3 0 | ||
977 | #define XDMA_BASE__INST1_SEG4 0 | ||
978 | #define XDMA_BASE__INST1_SEG5 0 | ||
979 | |||
980 | #define XDMA_BASE__INST2_SEG0 0 | ||
981 | #define XDMA_BASE__INST2_SEG1 0 | ||
982 | #define XDMA_BASE__INST2_SEG2 0 | ||
983 | #define XDMA_BASE__INST2_SEG3 0 | ||
984 | #define XDMA_BASE__INST2_SEG4 0 | ||
985 | #define XDMA_BASE__INST2_SEG5 0 | ||
986 | |||
987 | #define XDMA_BASE__INST3_SEG0 0 | ||
988 | #define XDMA_BASE__INST3_SEG1 0 | ||
989 | #define XDMA_BASE__INST3_SEG2 0 | ||
990 | #define XDMA_BASE__INST3_SEG3 0 | ||
991 | #define XDMA_BASE__INST3_SEG4 0 | ||
992 | #define XDMA_BASE__INST3_SEG5 0 | ||
993 | |||
994 | #define XDMA_BASE__INST4_SEG0 0 | ||
995 | #define XDMA_BASE__INST4_SEG1 0 | ||
996 | #define XDMA_BASE__INST4_SEG2 0 | ||
997 | #define XDMA_BASE__INST4_SEG3 0 | ||
998 | #define XDMA_BASE__INST4_SEG4 0 | ||
999 | #define XDMA_BASE__INST4_SEG5 0 | ||
1000 | |||
1001 | #define XDMA_BASE__INST5_SEG0 0 | ||
1002 | #define XDMA_BASE__INST5_SEG1 0 | ||
1003 | #define XDMA_BASE__INST5_SEG2 0 | ||
1004 | #define XDMA_BASE__INST5_SEG3 0 | ||
1005 | #define XDMA_BASE__INST5_SEG4 0 | ||
1006 | #define XDMA_BASE__INST5_SEG5 0 | ||
1007 | |||
1008 | #define RSMU_BASE__INST0_SEG0 0x00012000 | ||
1009 | #define RSMU_BASE__INST0_SEG1 0 | ||
1010 | #define RSMU_BASE__INST0_SEG2 0 | ||
1011 | #define RSMU_BASE__INST0_SEG3 0 | ||
1012 | #define RSMU_BASE__INST0_SEG4 0 | ||
1013 | #define RSMU_BASE__INST0_SEG5 0 | ||
1014 | |||
1015 | #define RSMU_BASE__INST1_SEG0 0 | ||
1016 | #define RSMU_BASE__INST1_SEG1 0 | ||
1017 | #define RSMU_BASE__INST1_SEG2 0 | ||
1018 | #define RSMU_BASE__INST1_SEG3 0 | ||
1019 | #define RSMU_BASE__INST1_SEG4 0 | ||
1020 | #define RSMU_BASE__INST1_SEG5 0 | ||
1021 | |||
1022 | #define RSMU_BASE__INST2_SEG0 0 | ||
1023 | #define RSMU_BASE__INST2_SEG1 0 | ||
1024 | #define RSMU_BASE__INST2_SEG2 0 | ||
1025 | #define RSMU_BASE__INST2_SEG3 0 | ||
1026 | #define RSMU_BASE__INST2_SEG4 0 | ||
1027 | #define RSMU_BASE__INST2_SEG5 0 | ||
1028 | |||
1029 | #define RSMU_BASE__INST3_SEG0 0 | ||
1030 | #define RSMU_BASE__INST3_SEG1 0 | ||
1031 | #define RSMU_BASE__INST3_SEG2 0 | ||
1032 | #define RSMU_BASE__INST3_SEG3 0 | ||
1033 | #define RSMU_BASE__INST3_SEG4 0 | ||
1034 | #define RSMU_BASE__INST3_SEG5 0 | ||
1035 | |||
1036 | #define RSMU_BASE__INST4_SEG0 0 | ||
1037 | #define RSMU_BASE__INST4_SEG1 0 | ||
1038 | #define RSMU_BASE__INST4_SEG2 0 | ||
1039 | #define RSMU_BASE__INST4_SEG3 0 | ||
1040 | #define RSMU_BASE__INST4_SEG4 0 | ||
1041 | #define RSMU_BASE__INST4_SEG5 0 | ||
1042 | |||
1043 | #define RSMU_BASE__INST5_SEG0 0 | ||
1044 | #define RSMU_BASE__INST5_SEG1 0 | ||
1045 | #define RSMU_BASE__INST5_SEG2 0 | ||
1046 | #define RSMU_BASE__INST5_SEG3 0 | ||
1047 | #define RSMU_BASE__INST5_SEG4 0 | ||
1048 | #define RSMU_BASE__INST5_SEG5 0 | ||
1049 | |||
1050 | #endif | ||
1051 | |||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c index e411012b3dcb..a0bb921fac22 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | |||
@@ -132,6 +132,15 @@ int phm_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | |||
132 | return 0; | 132 | return 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | int phm_apply_clock_adjust_rules(struct pp_hwmgr *hwmgr) | ||
136 | { | ||
137 | PHM_FUNC_CHECK(hwmgr); | ||
138 | |||
139 | if (hwmgr->hwmgr_func->apply_clocks_adjust_rules != NULL) | ||
140 | return hwmgr->hwmgr_func->apply_clocks_adjust_rules(hwmgr); | ||
141 | return 0; | ||
142 | } | ||
143 | |||
135 | int phm_powerdown_uvd(struct pp_hwmgr *hwmgr) | 144 | int phm_powerdown_uvd(struct pp_hwmgr *hwmgr) |
136 | { | 145 | { |
137 | PHM_FUNC_CHECK(hwmgr); | 146 | PHM_FUNC_CHECK(hwmgr); |
@@ -161,6 +170,16 @@ int phm_disable_clock_power_gatings(struct pp_hwmgr *hwmgr) | |||
161 | return 0; | 170 | return 0; |
162 | } | 171 | } |
163 | 172 | ||
173 | int phm_pre_display_configuration_changed(struct pp_hwmgr *hwmgr) | ||
174 | { | ||
175 | PHM_FUNC_CHECK(hwmgr); | ||
176 | |||
177 | if (NULL != hwmgr->hwmgr_func->pre_display_config_changed) | ||
178 | hwmgr->hwmgr_func->pre_display_config_changed(hwmgr); | ||
179 | |||
180 | return 0; | ||
181 | |||
182 | } | ||
164 | 183 | ||
165 | int phm_display_configuration_changed(struct pp_hwmgr *hwmgr) | 184 | int phm_display_configuration_changed(struct pp_hwmgr *hwmgr) |
166 | { | 185 | { |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c index 71b42331f185..e63bc47dc715 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | |||
@@ -151,6 +151,7 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr) | |||
151 | hwmgr->feature_mask &= ~PP_GFXOFF_MASK; | 151 | hwmgr->feature_mask &= ~PP_GFXOFF_MASK; |
152 | switch (hwmgr->chip_id) { | 152 | switch (hwmgr->chip_id) { |
153 | case CHIP_VEGA10: | 153 | case CHIP_VEGA10: |
154 | case CHIP_VEGA20: | ||
154 | hwmgr->smumgr_funcs = &vega10_smu_funcs; | 155 | hwmgr->smumgr_funcs = &vega10_smu_funcs; |
155 | vega10_hwmgr_init(hwmgr); | 156 | vega10_hwmgr_init(hwmgr); |
156 | break; | 157 | break; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c index 308bff2b5d1d..0af13c154328 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c | |||
@@ -265,6 +265,15 @@ int psm_adjust_power_state_dynamic(struct pp_hwmgr *hwmgr, bool skip, | |||
265 | if (skip) | 265 | if (skip) |
266 | return 0; | 266 | return 0; |
267 | 267 | ||
268 | if (!hwmgr->ps) | ||
269 | /* | ||
270 | * for vega12/vega20 which does not support power state manager | ||
271 | * DAL clock limits should also be honoured | ||
272 | */ | ||
273 | phm_apply_clock_adjust_rules(hwmgr); | ||
274 | |||
275 | phm_pre_display_configuration_changed(hwmgr); | ||
276 | |||
268 | phm_display_configuration_changed(hwmgr); | 277 | phm_display_configuration_changed(hwmgr); |
269 | 278 | ||
270 | if (hwmgr->ps) | 279 | if (hwmgr->ps) |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c index cf99c5eaf080..7047e29755c3 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c | |||
@@ -320,7 +320,7 @@ int atomctrl_get_memory_pll_dividers_ai(struct pp_hwmgr *hwmgr, | |||
320 | pp_atomctrl_memory_clock_param_ai *mpll_param) | 320 | pp_atomctrl_memory_clock_param_ai *mpll_param) |
321 | { | 321 | { |
322 | struct amdgpu_device *adev = hwmgr->adev; | 322 | struct amdgpu_device *adev = hwmgr->adev; |
323 | COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_3 mpll_parameters = {0}; | 323 | COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_3 mpll_parameters = {{0}, 0, 0}; |
324 | int result; | 324 | int result; |
325 | 325 | ||
326 | mpll_parameters.ulClock.ulClock = cpu_to_le32(clock_value); | 326 | mpll_parameters.ulClock.ulClock = cpu_to_le32(clock_value); |
@@ -1104,10 +1104,8 @@ int atomctrl_get_voltage_evv_on_sclk( | |||
1104 | GetIndexIntoMasterTable(COMMAND, GetVoltageInfo), | 1104 | GetIndexIntoMasterTable(COMMAND, GetVoltageInfo), |
1105 | (uint32_t *)&get_voltage_info_param_space); | 1105 | (uint32_t *)&get_voltage_info_param_space); |
1106 | 1106 | ||
1107 | if (0 != result) | 1107 | *voltage = result ? 0 : |
1108 | return result; | 1108 | le16_to_cpu(((GET_EVV_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_2 *) |
1109 | |||
1110 | *voltage = le16_to_cpu(((GET_EVV_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_2 *) | ||
1111 | (&get_voltage_info_param_space))->usVoltageLevel); | 1109 | (&get_voltage_info_param_space))->usVoltageLevel); |
1112 | 1110 | ||
1113 | return result; | 1111 | return result; |
@@ -1312,8 +1310,7 @@ int atomctrl_read_efuse(struct pp_hwmgr *hwmgr, uint16_t start_index, | |||
1312 | result = amdgpu_atom_execute_table(adev->mode_info.atom_context, | 1310 | result = amdgpu_atom_execute_table(adev->mode_info.atom_context, |
1313 | GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), | 1311 | GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), |
1314 | (uint32_t *)&efuse_param); | 1312 | (uint32_t *)&efuse_param); |
1315 | if (!result) | 1313 | *efuse = result ? 0 : le32_to_cpu(efuse_param.ulEfuseValue) & mask; |
1316 | *efuse = le32_to_cpu(efuse_param.ulEfuseValue) & mask; | ||
1317 | 1314 | ||
1318 | return result; | 1315 | return result; |
1319 | } | 1316 | } |
@@ -1354,11 +1351,8 @@ int atomctrl_get_voltage_evv_on_sclk_ai(struct pp_hwmgr *hwmgr, uint8_t voltage_ | |||
1354 | GetIndexIntoMasterTable(COMMAND, GetVoltageInfo), | 1351 | GetIndexIntoMasterTable(COMMAND, GetVoltageInfo), |
1355 | (uint32_t *)&get_voltage_info_param_space); | 1352 | (uint32_t *)&get_voltage_info_param_space); |
1356 | 1353 | ||
1357 | if (0 != result) | 1354 | *voltage = result ? 0 : |
1358 | return result; | 1355 | le32_to_cpu(((GET_EVV_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_3 *)(&get_voltage_info_param_space))->ulVoltageLevel); |
1359 | |||
1360 | *voltage = le32_to_cpu(((GET_EVV_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_3 *) | ||
1361 | (&get_voltage_info_param_space))->ulVoltageLevel); | ||
1362 | 1356 | ||
1363 | return result; | 1357 | return result; |
1364 | } | 1358 | } |
@@ -1552,15 +1546,17 @@ void atomctrl_get_voltage_range(struct pp_hwmgr *hwmgr, uint32_t *max_vddc, | |||
1552 | case CHIP_FIJI: | 1546 | case CHIP_FIJI: |
1553 | *max_vddc = le32_to_cpu(((ATOM_ASIC_PROFILING_INFO_V3_3 *)profile)->ulMaxVddc/4); | 1547 | *max_vddc = le32_to_cpu(((ATOM_ASIC_PROFILING_INFO_V3_3 *)profile)->ulMaxVddc/4); |
1554 | *min_vddc = le32_to_cpu(((ATOM_ASIC_PROFILING_INFO_V3_3 *)profile)->ulMinVddc/4); | 1548 | *min_vddc = le32_to_cpu(((ATOM_ASIC_PROFILING_INFO_V3_3 *)profile)->ulMinVddc/4); |
1555 | break; | 1549 | return; |
1556 | case CHIP_POLARIS11: | 1550 | case CHIP_POLARIS11: |
1557 | case CHIP_POLARIS10: | 1551 | case CHIP_POLARIS10: |
1558 | case CHIP_POLARIS12: | 1552 | case CHIP_POLARIS12: |
1559 | *max_vddc = le32_to_cpu(((ATOM_ASIC_PROFILING_INFO_V3_6 *)profile)->ulMaxVddc/100); | 1553 | *max_vddc = le32_to_cpu(((ATOM_ASIC_PROFILING_INFO_V3_6 *)profile)->ulMaxVddc/100); |
1560 | *min_vddc = le32_to_cpu(((ATOM_ASIC_PROFILING_INFO_V3_6 *)profile)->ulMinVddc/100); | 1554 | *min_vddc = le32_to_cpu(((ATOM_ASIC_PROFILING_INFO_V3_6 *)profile)->ulMinVddc/100); |
1561 | break; | ||
1562 | default: | ||
1563 | return; | 1555 | return; |
1556 | default: | ||
1557 | break; | ||
1564 | } | 1558 | } |
1565 | } | 1559 | } |
1560 | *max_vddc = 0; | ||
1561 | *min_vddc = 0; | ||
1566 | } | 1562 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c index 2f69bfa478a7..85f84f4d8be5 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | |||
@@ -600,7 +600,10 @@ static int smu10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | |||
600 | data->gfx_min_freq_limit/100); | 600 | data->gfx_min_freq_limit/100); |
601 | smum_send_msg_to_smc_with_parameter(hwmgr, | 601 | smum_send_msg_to_smc_with_parameter(hwmgr, |
602 | PPSMC_MSG_SetHardMinFclkByFreq, | 602 | PPSMC_MSG_SetHardMinFclkByFreq, |
603 | hwmgr->display_config->num_display > 3 ? | ||
604 | SMU10_UMD_PSTATE_PEAK_FCLK : | ||
603 | SMU10_UMD_PSTATE_MIN_FCLK); | 605 | SMU10_UMD_PSTATE_MIN_FCLK); |
606 | |||
604 | smum_send_msg_to_smc_with_parameter(hwmgr, | 607 | smum_send_msg_to_smc_with_parameter(hwmgr, |
605 | PPSMC_MSG_SetHardMinSocclkByFreq, | 608 | PPSMC_MSG_SetHardMinSocclkByFreq, |
606 | SMU10_UMD_PSTATE_MIN_SOCCLK); | 609 | SMU10_UMD_PSTATE_MIN_SOCCLK); |
@@ -1125,6 +1128,23 @@ static int smu10_set_mmhub_powergating_by_smu(struct pp_hwmgr *hwmgr) | |||
1125 | return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerGateMmHub); | 1128 | return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerGateMmHub); |
1126 | } | 1129 | } |
1127 | 1130 | ||
1131 | static void smu10_powergate_vcn(struct pp_hwmgr *hwmgr, bool bgate) | ||
1132 | { | ||
1133 | if (bgate) { | ||
1134 | amdgpu_device_ip_set_powergating_state(hwmgr->adev, | ||
1135 | AMD_IP_BLOCK_TYPE_VCN, | ||
1136 | AMD_PG_STATE_GATE); | ||
1137 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
1138 | PPSMC_MSG_PowerDownVcn, 0); | ||
1139 | } else { | ||
1140 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
1141 | PPSMC_MSG_PowerUpVcn, 0); | ||
1142 | amdgpu_device_ip_set_powergating_state(hwmgr->adev, | ||
1143 | AMD_IP_BLOCK_TYPE_VCN, | ||
1144 | AMD_PG_STATE_UNGATE); | ||
1145 | } | ||
1146 | } | ||
1147 | |||
1128 | static const struct pp_hwmgr_func smu10_hwmgr_funcs = { | 1148 | static const struct pp_hwmgr_func smu10_hwmgr_funcs = { |
1129 | .backend_init = smu10_hwmgr_backend_init, | 1149 | .backend_init = smu10_hwmgr_backend_init, |
1130 | .backend_fini = smu10_hwmgr_backend_fini, | 1150 | .backend_fini = smu10_hwmgr_backend_fini, |
@@ -1133,7 +1153,7 @@ static const struct pp_hwmgr_func smu10_hwmgr_funcs = { | |||
1133 | .force_dpm_level = smu10_dpm_force_dpm_level, | 1153 | .force_dpm_level = smu10_dpm_force_dpm_level, |
1134 | .get_power_state_size = smu10_get_power_state_size, | 1154 | .get_power_state_size = smu10_get_power_state_size, |
1135 | .powerdown_uvd = NULL, | 1155 | .powerdown_uvd = NULL, |
1136 | .powergate_uvd = NULL, | 1156 | .powergate_uvd = smu10_powergate_vcn, |
1137 | .powergate_vce = NULL, | 1157 | .powergate_vce = NULL, |
1138 | .get_mclk = smu10_dpm_get_mclk, | 1158 | .get_mclk = smu10_dpm_get_mclk, |
1139 | .get_sclk = smu10_dpm_get_sclk, | 1159 | .get_sclk = smu10_dpm_get_sclk, |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c index 8eb3f5176646..45e9b8cb169d 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | |||
@@ -860,7 +860,8 @@ static void smu7_setup_voltage_range_from_vbios(struct pp_hwmgr *hwmgr) | |||
860 | struct phm_ppt_v1_clock_voltage_dependency_table *dep_sclk_table; | 860 | struct phm_ppt_v1_clock_voltage_dependency_table *dep_sclk_table; |
861 | struct phm_ppt_v1_information *table_info = | 861 | struct phm_ppt_v1_information *table_info = |
862 | (struct phm_ppt_v1_information *)(hwmgr->pptable); | 862 | (struct phm_ppt_v1_information *)(hwmgr->pptable); |
863 | uint32_t min_vddc, max_vddc; | 863 | uint32_t min_vddc = 0; |
864 | uint32_t max_vddc = 0; | ||
864 | 865 | ||
865 | if (!table_info) | 866 | if (!table_info) |
866 | return; | 867 | return; |
@@ -1018,7 +1019,7 @@ static int smu7_enable_sclk_mclk_dpm(struct pp_hwmgr *hwmgr) | |||
1018 | struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); | 1019 | struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); |
1019 | 1020 | ||
1020 | /* enable SCLK dpm */ | 1021 | /* enable SCLK dpm */ |
1021 | if (!data->sclk_dpm_key_disabled) | 1022 | if (!data->sclk_dpm_key_disabled) { |
1022 | if (hwmgr->chip_id == CHIP_VEGAM) | 1023 | if (hwmgr->chip_id == CHIP_VEGAM) |
1023 | smu7_disable_sclk_vce_handshake(hwmgr); | 1024 | smu7_disable_sclk_vce_handshake(hwmgr); |
1024 | 1025 | ||
@@ -1026,6 +1027,7 @@ static int smu7_enable_sclk_mclk_dpm(struct pp_hwmgr *hwmgr) | |||
1026 | (0 == smum_send_msg_to_smc(hwmgr, PPSMC_MSG_DPM_Enable)), | 1027 | (0 == smum_send_msg_to_smc(hwmgr, PPSMC_MSG_DPM_Enable)), |
1027 | "Failed to enable SCLK DPM during DPM Start Function!", | 1028 | "Failed to enable SCLK DPM during DPM Start Function!", |
1028 | return -EINVAL); | 1029 | return -EINVAL); |
1030 | } | ||
1029 | 1031 | ||
1030 | /* enable MCLK dpm */ | 1032 | /* enable MCLK dpm */ |
1031 | if (0 == data->mclk_dpm_key_disabled) { | 1033 | if (0 == data->mclk_dpm_key_disabled) { |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c index 99b29ff45d91..c952845833d7 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c | |||
@@ -936,45 +936,49 @@ int smu7_enable_didt_config(struct pp_hwmgr *hwmgr) | |||
936 | 936 | ||
937 | if (hwmgr->chip_id == CHIP_POLARIS10) { | 937 | if (hwmgr->chip_id == CHIP_POLARIS10) { |
938 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris10); | 938 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris10); |
939 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | 939 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", goto error); |
940 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris10); | 940 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris10); |
941 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | 941 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", goto error); |
942 | } else if (hwmgr->chip_id == CHIP_POLARIS11) { | 942 | } else if (hwmgr->chip_id == CHIP_POLARIS11) { |
943 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11); | 943 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11); |
944 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | 944 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", goto error); |
945 | if (hwmgr->is_kicker) | 945 | if (hwmgr->is_kicker) |
946 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11_Kicker); | 946 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11_Kicker); |
947 | else | 947 | else |
948 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11); | 948 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11); |
949 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | 949 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", goto error); |
950 | } else if (hwmgr->chip_id == CHIP_POLARIS12) { | 950 | } else if (hwmgr->chip_id == CHIP_POLARIS12) { |
951 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11); | 951 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11); |
952 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | 952 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", goto error); |
953 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris12); | 953 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris12); |
954 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | 954 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", goto error); |
955 | } else if (hwmgr->chip_id == CHIP_VEGAM) { | 955 | } else if (hwmgr->chip_id == CHIP_VEGAM) { |
956 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_VegaM); | 956 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_VegaM); |
957 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | 957 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", goto error); |
958 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_VegaM); | 958 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_VegaM); |
959 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | 959 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", goto error); |
960 | } | 960 | } |
961 | } | 961 | } |
962 | cgs_write_register(hwmgr->device, mmGRBM_GFX_INDEX, value2); | 962 | cgs_write_register(hwmgr->device, mmGRBM_GFX_INDEX, value2); |
963 | 963 | ||
964 | result = smu7_enable_didt(hwmgr, true); | 964 | result = smu7_enable_didt(hwmgr, true); |
965 | PP_ASSERT_WITH_CODE((result == 0), "EnableDiDt failed.", return result); | 965 | PP_ASSERT_WITH_CODE((result == 0), "EnableDiDt failed.", goto error); |
966 | 966 | ||
967 | if (hwmgr->chip_id == CHIP_POLARIS11) { | 967 | if (hwmgr->chip_id == CHIP_POLARIS11) { |
968 | result = smum_send_msg_to_smc(hwmgr, | 968 | result = smum_send_msg_to_smc(hwmgr, |
969 | (uint16_t)(PPSMC_MSG_EnableDpmDidt)); | 969 | (uint16_t)(PPSMC_MSG_EnableDpmDidt)); |
970 | PP_ASSERT_WITH_CODE((0 == result), | 970 | PP_ASSERT_WITH_CODE((0 == result), |
971 | "Failed to enable DPM DIDT.", return result); | 971 | "Failed to enable DPM DIDT.", goto error); |
972 | } | 972 | } |
973 | mutex_unlock(&adev->grbm_idx_mutex); | 973 | mutex_unlock(&adev->grbm_idx_mutex); |
974 | adev->gfx.rlc.funcs->exit_safe_mode(adev); | 974 | adev->gfx.rlc.funcs->exit_safe_mode(adev); |
975 | } | 975 | } |
976 | 976 | ||
977 | return 0; | 977 | return 0; |
978 | error: | ||
979 | mutex_unlock(&adev->grbm_idx_mutex); | ||
980 | adev->gfx.rlc.funcs->exit_safe_mode(adev); | ||
981 | return result; | ||
978 | } | 982 | } |
979 | 983 | ||
980 | int smu7_disable_didt_config(struct pp_hwmgr *hwmgr) | 984 | int smu7_disable_didt_config(struct pp_hwmgr *hwmgr) |
@@ -992,17 +996,20 @@ int smu7_disable_didt_config(struct pp_hwmgr *hwmgr) | |||
992 | result = smu7_enable_didt(hwmgr, false); | 996 | result = smu7_enable_didt(hwmgr, false); |
993 | PP_ASSERT_WITH_CODE((result == 0), | 997 | PP_ASSERT_WITH_CODE((result == 0), |
994 | "Post DIDT enable clock gating failed.", | 998 | "Post DIDT enable clock gating failed.", |
995 | return result); | 999 | goto error); |
996 | if (hwmgr->chip_id == CHIP_POLARIS11) { | 1000 | if (hwmgr->chip_id == CHIP_POLARIS11) { |
997 | result = smum_send_msg_to_smc(hwmgr, | 1001 | result = smum_send_msg_to_smc(hwmgr, |
998 | (uint16_t)(PPSMC_MSG_DisableDpmDidt)); | 1002 | (uint16_t)(PPSMC_MSG_DisableDpmDidt)); |
999 | PP_ASSERT_WITH_CODE((0 == result), | 1003 | PP_ASSERT_WITH_CODE((0 == result), |
1000 | "Failed to disable DPM DIDT.", return result); | 1004 | "Failed to disable DPM DIDT.", goto error); |
1001 | } | 1005 | } |
1002 | adev->gfx.rlc.funcs->exit_safe_mode(adev); | 1006 | adev->gfx.rlc.funcs->exit_safe_mode(adev); |
1003 | } | 1007 | } |
1004 | 1008 | ||
1005 | return 0; | 1009 | return 0; |
1010 | error: | ||
1011 | adev->gfx.rlc.funcs->exit_safe_mode(adev); | ||
1012 | return result; | ||
1006 | } | 1013 | } |
1007 | 1014 | ||
1008 | int smu7_enable_smc_cac(struct pp_hwmgr *hwmgr) | 1015 | int smu7_enable_smc_cac(struct pp_hwmgr *hwmgr) |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h index 9bb87857a20f..a202247c9894 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h | |||
@@ -410,7 +410,10 @@ extern int phm_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | |||
410 | struct pp_power_state *adjusted_ps, | 410 | struct pp_power_state *adjusted_ps, |
411 | const struct pp_power_state *current_ps); | 411 | const struct pp_power_state *current_ps); |
412 | 412 | ||
413 | extern int phm_apply_clock_adjust_rules(struct pp_hwmgr *hwmgr); | ||
414 | |||
413 | extern int phm_force_dpm_levels(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level); | 415 | extern int phm_force_dpm_levels(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level); |
416 | extern int phm_pre_display_configuration_changed(struct pp_hwmgr *hwmgr); | ||
414 | extern int phm_display_configuration_changed(struct pp_hwmgr *hwmgr); | 417 | extern int phm_display_configuration_changed(struct pp_hwmgr *hwmgr); |
415 | extern int phm_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr); | 418 | extern int phm_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr); |
416 | extern int phm_register_irq_handlers(struct pp_hwmgr *hwmgr); | 419 | extern int phm_register_irq_handlers(struct pp_hwmgr *hwmgr); |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h index 3c321c7d9626..b99fb8ac822c 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | |||
@@ -229,6 +229,8 @@ struct pp_hwmgr_func { | |||
229 | struct pp_power_state *prequest_ps, | 229 | struct pp_power_state *prequest_ps, |
230 | const struct pp_power_state *pcurrent_ps); | 230 | const struct pp_power_state *pcurrent_ps); |
231 | 231 | ||
232 | int (*apply_clocks_adjust_rules)(struct pp_hwmgr *hwmgr); | ||
233 | |||
232 | int (*force_dpm_level)(struct pp_hwmgr *hw_mgr, | 234 | int (*force_dpm_level)(struct pp_hwmgr *hw_mgr, |
233 | enum amd_dpm_forced_level level); | 235 | enum amd_dpm_forced_level level); |
234 | 236 | ||
@@ -252,6 +254,7 @@ struct pp_hwmgr_func { | |||
252 | const void *state); | 254 | const void *state); |
253 | int (*enable_clock_power_gating)(struct pp_hwmgr *hwmgr); | 255 | int (*enable_clock_power_gating)(struct pp_hwmgr *hwmgr); |
254 | int (*notify_smc_display_config_after_ps_adjustment)(struct pp_hwmgr *hwmgr); | 256 | int (*notify_smc_display_config_after_ps_adjustment)(struct pp_hwmgr *hwmgr); |
257 | int (*pre_display_config_changed)(struct pp_hwmgr *hwmgr); | ||
255 | int (*display_config_changed)(struct pp_hwmgr *hwmgr); | 258 | int (*display_config_changed)(struct pp_hwmgr *hwmgr); |
256 | int (*disable_clock_power_gating)(struct pp_hwmgr *hwmgr); | 259 | int (*disable_clock_power_gating)(struct pp_hwmgr *hwmgr); |
257 | int (*update_clock_gatings)(struct pp_hwmgr *hwmgr, | 260 | int (*update_clock_gatings)(struct pp_hwmgr *hwmgr, |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c index 64d33b775906..d644a9bb9078 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c | |||
@@ -283,11 +283,9 @@ int smu7_read_smc_sram_dword(struct pp_hwmgr *hwmgr, uint32_t smc_addr, uint32_t | |||
283 | 283 | ||
284 | result = smu7_set_smc_sram_address(hwmgr, smc_addr, limit); | 284 | result = smu7_set_smc_sram_address(hwmgr, smc_addr, limit); |
285 | 285 | ||
286 | if (result) | 286 | *value = result ? 0 : cgs_read_register(hwmgr->device, mmSMC_IND_DATA_11); |
287 | return result; | ||
288 | 287 | ||
289 | *value = cgs_read_register(hwmgr->device, mmSMC_IND_DATA_11); | 288 | return result; |
290 | return 0; | ||
291 | } | 289 | } |
292 | 290 | ||
293 | int smu7_write_smc_sram_dword(struct pp_hwmgr *hwmgr, uint32_t smc_addr, uint32_t value, uint32_t limit) | 291 | int smu7_write_smc_sram_dword(struct pp_hwmgr *hwmgr, uint32_t smc_addr, uint32_t value, uint32_t limit) |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c index ee236dfbf1d6..c9837935f0f5 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c | |||
@@ -45,6 +45,7 @@ MODULE_FIRMWARE("amdgpu/vegam_smc.bin"); | |||
45 | MODULE_FIRMWARE("amdgpu/vega10_smc.bin"); | 45 | MODULE_FIRMWARE("amdgpu/vega10_smc.bin"); |
46 | MODULE_FIRMWARE("amdgpu/vega10_acg_smc.bin"); | 46 | MODULE_FIRMWARE("amdgpu/vega10_acg_smc.bin"); |
47 | MODULE_FIRMWARE("amdgpu/vega12_smc.bin"); | 47 | MODULE_FIRMWARE("amdgpu/vega12_smc.bin"); |
48 | MODULE_FIRMWARE("amdgpu/vega20_smc.bin"); | ||
48 | 49 | ||
49 | int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr) | 50 | int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr) |
50 | { | 51 | { |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c index c9a563399330..2de48959ac93 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c | |||
@@ -1366,10 +1366,12 @@ static int vegam_program_memory_timing_parameters(struct pp_hwmgr *hwmgr) | |||
1366 | { | 1366 | { |
1367 | struct smu7_hwmgr *hw_data = (struct smu7_hwmgr *)(hwmgr->backend); | 1367 | struct smu7_hwmgr *hw_data = (struct smu7_hwmgr *)(hwmgr->backend); |
1368 | struct vegam_smumgr *smu_data = (struct vegam_smumgr *)(hwmgr->smu_backend); | 1368 | struct vegam_smumgr *smu_data = (struct vegam_smumgr *)(hwmgr->smu_backend); |
1369 | struct SMU75_Discrete_MCArbDramTimingTable arb_regs = {0}; | 1369 | struct SMU75_Discrete_MCArbDramTimingTable arb_regs; |
1370 | uint32_t i, j; | 1370 | uint32_t i, j; |
1371 | int result = 0; | 1371 | int result = 0; |
1372 | 1372 | ||
1373 | memset(&arb_regs, 0, sizeof(SMU75_Discrete_MCArbDramTimingTable)); | ||
1374 | |||
1373 | for (i = 0; i < hw_data->dpm_table.sclk_table.count; i++) { | 1375 | for (i = 0; i < hw_data->dpm_table.sclk_table.count; i++) { |
1374 | for (j = 0; j < hw_data->dpm_table.mclk_table.count; j++) { | 1376 | for (j = 0; j < hw_data->dpm_table.mclk_table.count; j++) { |
1375 | result = vegam_populate_memory_timing_parameters(hwmgr, | 1377 | result = vegam_populate_memory_timing_parameters(hwmgr, |
@@ -2377,6 +2379,5 @@ const struct pp_smumgr_func vegam_smu_funcs = { | |||
2377 | .update_sclk_threshold = vegam_update_sclk_threshold, | 2379 | .update_sclk_threshold = vegam_update_sclk_threshold, |
2378 | .is_hw_avfs_present = vegam_is_hw_avfs_present, | 2380 | .is_hw_avfs_present = vegam_is_hw_avfs_present, |
2379 | .thermal_avfs_enable = vegam_thermal_avfs_enable, | 2381 | .thermal_avfs_enable = vegam_thermal_avfs_enable, |
2380 | .is_dpm_running = vegam_is_dpm_running, | ||
2381 | .thermal_setup_fan_table = vegam_thermal_setup_fan_table, | 2382 | .thermal_setup_fan_table = vegam_thermal_setup_fan_table, |
2382 | }; | 2383 | }; |
diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index a364fc0b38c3..df1578d6f42e 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c | |||
@@ -139,7 +139,6 @@ int drm_sched_entity_init(struct drm_gpu_scheduler *sched, | |||
139 | entity->last_scheduled = NULL; | 139 | entity->last_scheduled = NULL; |
140 | 140 | ||
141 | spin_lock_init(&entity->rq_lock); | 141 | spin_lock_init(&entity->rq_lock); |
142 | spin_lock_init(&entity->queue_lock); | ||
143 | spsc_queue_init(&entity->job_queue); | 142 | spsc_queue_init(&entity->job_queue); |
144 | 143 | ||
145 | atomic_set(&entity->fence_seq, 0); | 144 | atomic_set(&entity->fence_seq, 0); |
@@ -413,6 +412,10 @@ drm_sched_entity_pop_job(struct drm_sched_entity *entity) | |||
413 | * | 412 | * |
414 | * @sched_job The pointer to job required to submit | 413 | * @sched_job The pointer to job required to submit |
415 | * | 414 | * |
415 | * Note: To guarantee that the order of insertion to queue matches | ||
416 | * the job's fence sequence number this function should be | ||
417 | * called with drm_sched_job_init under common lock. | ||
418 | * | ||
416 | * Returns 0 for success, negative error code otherwise. | 419 | * Returns 0 for success, negative error code otherwise. |
417 | */ | 420 | */ |
418 | void drm_sched_entity_push_job(struct drm_sched_job *sched_job, | 421 | void drm_sched_entity_push_job(struct drm_sched_job *sched_job, |
@@ -423,11 +426,8 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, | |||
423 | 426 | ||
424 | trace_drm_sched_job(sched_job, entity); | 427 | trace_drm_sched_job(sched_job, entity); |
425 | 428 | ||
426 | spin_lock(&entity->queue_lock); | ||
427 | first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node); | 429 | first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node); |
428 | 430 | ||
429 | spin_unlock(&entity->queue_lock); | ||
430 | |||
431 | /* first job wakes up scheduler */ | 431 | /* first job wakes up scheduler */ |
432 | if (first) { | 432 | if (first) { |
433 | /* Add the entity to the run queue */ | 433 | /* Add the entity to the run queue */ |
@@ -593,7 +593,12 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) | |||
593 | } | 593 | } |
594 | EXPORT_SYMBOL(drm_sched_job_recovery); | 594 | EXPORT_SYMBOL(drm_sched_job_recovery); |
595 | 595 | ||
596 | /* init a sched_job with basic field */ | 596 | /** |
597 | * Init a sched_job with basic field | ||
598 | * | ||
599 | * Note: Refer to drm_sched_entity_push_job documentation | ||
600 | * for locking considerations. | ||
601 | */ | ||
597 | int drm_sched_job_init(struct drm_sched_job *job, | 602 | int drm_sched_job_init(struct drm_sched_job *job, |
598 | struct drm_gpu_scheduler *sched, | 603 | struct drm_gpu_scheduler *sched, |
599 | struct drm_sched_entity *entity, | 604 | struct drm_sched_entity *entity, |
diff --git a/drivers/gpu/drm/scheduler/sched_fence.c b/drivers/gpu/drm/scheduler/sched_fence.c index 69aab086b913..df4461648e3f 100644 --- a/drivers/gpu/drm/scheduler/sched_fence.c +++ b/drivers/gpu/drm/scheduler/sched_fence.c | |||
@@ -87,7 +87,7 @@ static bool drm_sched_fence_enable_signaling(struct dma_fence *f) | |||
87 | } | 87 | } |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * amd_sched_fence_free - free up the fence memory | 90 | * drm_sched_fence_free - free up the fence memory |
91 | * | 91 | * |
92 | * @rcu: RCU callback head | 92 | * @rcu: RCU callback head |
93 | * | 93 | * |
@@ -98,12 +98,11 @@ static void drm_sched_fence_free(struct rcu_head *rcu) | |||
98 | struct dma_fence *f = container_of(rcu, struct dma_fence, rcu); | 98 | struct dma_fence *f = container_of(rcu, struct dma_fence, rcu); |
99 | struct drm_sched_fence *fence = to_drm_sched_fence(f); | 99 | struct drm_sched_fence *fence = to_drm_sched_fence(f); |
100 | 100 | ||
101 | dma_fence_put(fence->parent); | ||
102 | kmem_cache_free(sched_fence_slab, fence); | 101 | kmem_cache_free(sched_fence_slab, fence); |
103 | } | 102 | } |
104 | 103 | ||
105 | /** | 104 | /** |
106 | * amd_sched_fence_release_scheduled - callback that fence can be freed | 105 | * drm_sched_fence_release_scheduled - callback that fence can be freed |
107 | * | 106 | * |
108 | * @fence: fence | 107 | * @fence: fence |
109 | * | 108 | * |
@@ -114,11 +113,12 @@ static void drm_sched_fence_release_scheduled(struct dma_fence *f) | |||
114 | { | 113 | { |
115 | struct drm_sched_fence *fence = to_drm_sched_fence(f); | 114 | struct drm_sched_fence *fence = to_drm_sched_fence(f); |
116 | 115 | ||
116 | dma_fence_put(fence->parent); | ||
117 | call_rcu(&fence->finished.rcu, drm_sched_fence_free); | 117 | call_rcu(&fence->finished.rcu, drm_sched_fence_free); |
118 | } | 118 | } |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * amd_sched_fence_release_finished - drop extra reference | 121 | * drm_sched_fence_release_finished - drop extra reference |
122 | * | 122 | * |
123 | * @f: fence | 123 | * @f: fence |
124 | * | 124 | * |
diff --git a/include/drm/amd_asic_type.h b/include/drm/amd_asic_type.h index 695bde7eb055..dd63d08cc54e 100644 --- a/include/drm/amd_asic_type.h +++ b/include/drm/amd_asic_type.h | |||
@@ -47,6 +47,7 @@ enum amd_asic_type { | |||
47 | CHIP_VEGAM, | 47 | CHIP_VEGAM, |
48 | CHIP_VEGA10, | 48 | CHIP_VEGA10, |
49 | CHIP_VEGA12, | 49 | CHIP_VEGA12, |
50 | CHIP_VEGA20, | ||
50 | CHIP_RAVEN, | 51 | CHIP_RAVEN, |
51 | CHIP_LAST, | 52 | CHIP_LAST, |
52 | }; | 53 | }; |
diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 52380067a43f..dec655894d08 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h | |||
@@ -56,7 +56,6 @@ struct drm_sched_entity { | |||
56 | spinlock_t rq_lock; | 56 | spinlock_t rq_lock; |
57 | struct drm_gpu_scheduler *sched; | 57 | struct drm_gpu_scheduler *sched; |
58 | 58 | ||
59 | spinlock_t queue_lock; | ||
60 | struct spsc_queue job_queue; | 59 | struct spsc_queue job_queue; |
61 | 60 | ||
62 | atomic_t fence_seq; | 61 | atomic_t fence_seq; |