Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'amd-drm-next-5.15-2021-08-20' of https://gitlab.freedesktop.org/agd5f/linux into drm-next

amd-drm-next-5.15-2021-08-20:

amdgpu:
- embed hw fence into job
- Misc SMU fixes
- PSP TA code cleanup
- RAS fixes
- PWM fan speed fixes
- DC workqueue cleanups
- SR-IOV fixes
- gfxoff delayed work fix
- Pin domain check fix

amdkfd:
- SVM fixes

radeon:
- Code cleanup

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210820172335.4190-1-alexander.deucher@amd.com

+2229 -1317
-1
drivers/gpu/drm/Kconfig
··· 256 256 select HWMON 257 257 select BACKLIGHT_CLASS_DEVICE 258 258 select INTERVAL_TREE 259 - select CHASH 260 259 help 261 260 Choose this option if you have a recent AMD Radeon graphics card. 262 261
+2
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 1271 1271 1272 1272 #define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter)); 1273 1273 1274 + #define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) 1275 + 1274 1276 /* Common functions */ 1275 1277 bool amdgpu_device_has_job_running(struct amdgpu_device *adev); 1276 1278 bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);
-1
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
··· 714 714 ret = dma_fence_wait(f, false); 715 715 716 716 err_ib_sched: 717 - dma_fence_put(f); 718 717 amdgpu_job_free(job); 719 718 err: 720 719 return ret;
+31
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c
··· 560 560 case KFD_PREEMPT_TYPE_WAVEFRONT_RESET: 561 561 type = RESET_WAVES; 562 562 break; 563 + case KFD_PREEMPT_TYPE_WAVEFRONT_SAVE: 564 + type = SAVE_WAVES; 565 + break; 563 566 default: 564 567 type = DRAIN_PIPE; 565 568 break; ··· 757 754 adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); 758 755 } 759 756 757 + static void program_trap_handler_settings(struct kgd_dev *kgd, 758 + uint32_t vmid, uint64_t tba_addr, uint64_t tma_addr) 759 + { 760 + struct amdgpu_device *adev = get_amdgpu_device(kgd); 761 + 762 + lock_srbm(kgd, 0, 0, 0, vmid); 763 + 764 + /* 765 + * Program TBA registers 766 + */ 767 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TBA_LO), 768 + lower_32_bits(tba_addr >> 8)); 769 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TBA_HI), 770 + upper_32_bits(tba_addr >> 8) | 771 + (1 << SQ_SHADER_TBA_HI__TRAP_EN__SHIFT)); 772 + 773 + /* 774 + * Program TMA registers 775 + */ 776 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TMA_LO), 777 + lower_32_bits(tma_addr >> 8)); 778 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TMA_HI), 779 + upper_32_bits(tma_addr >> 8)); 780 + 781 + unlock_srbm(kgd); 782 + } 783 + 760 784 const struct kfd2kgd_calls gfx_v10_kfd2kgd = { 761 785 .program_sh_mem_settings = kgd_program_sh_mem_settings, 762 786 .set_pasid_vmid_mapping = kgd_set_pasid_vmid_mapping, ··· 804 774 .get_atc_vmid_pasid_mapping_info = 805 775 get_atc_vmid_pasid_mapping_info, 806 776 .set_vm_context_page_table_base = set_vm_context_page_table_base, 777 + .program_trap_handler_settings = program_trap_handler_settings, 807 778 };
+31
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c
··· 537 537 case KFD_PREEMPT_TYPE_WAVEFRONT_RESET: 538 538 type = RESET_WAVES; 539 539 break; 540 + case KFD_PREEMPT_TYPE_WAVEFRONT_SAVE: 541 + type = SAVE_WAVES; 542 + break; 540 543 default: 541 544 type = DRAIN_PIPE; 542 545 break; ··· 659 656 660 657 /* SDMA is on gfxhub as well for Navi1* series */ 661 658 adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); 659 + } 660 + 661 + static void program_trap_handler_settings_v10_3(struct kgd_dev *kgd, 662 + uint32_t vmid, uint64_t tba_addr, uint64_t tma_addr) 663 + { 664 + struct amdgpu_device *adev = get_amdgpu_device(kgd); 665 + 666 + lock_srbm(kgd, 0, 0, 0, vmid); 667 + 668 + /* 669 + * Program TBA registers 670 + */ 671 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TBA_LO), 672 + lower_32_bits(tba_addr >> 8)); 673 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TBA_HI), 674 + upper_32_bits(tba_addr >> 8) | 675 + (1 << SQ_SHADER_TBA_HI__TRAP_EN__SHIFT)); 676 + 677 + /* 678 + * Program TMA registers 679 + */ 680 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TMA_LO), 681 + lower_32_bits(tma_addr >> 8)); 682 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TMA_HI), 683 + upper_32_bits(tma_addr >> 8)); 684 + 685 + unlock_srbm(kgd); 662 686 } 663 687 664 688 #if 0 ··· 850 820 .address_watch_get_offset = address_watch_get_offset_v10_3, 851 821 .get_atc_vmid_pasid_mapping_info = NULL, 852 822 .set_vm_context_page_table_base = set_vm_context_page_table_base_v10_3, 823 + .program_trap_handler_settings = program_trap_handler_settings_v10_3, 853 824 #if 0 854 825 .enable_debug_trap = enable_debug_trap_v10_3, 855 826 .disable_debug_trap = disable_debug_trap_v10_3,
+32 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
··· 42 42 enum hqd_dequeue_request_type { 43 43 NO_ACTION = 0, 44 44 DRAIN_PIPE, 45 - RESET_WAVES 45 + RESET_WAVES, 46 + SAVE_WAVES 46 47 }; 47 48 48 49 static inline struct amdgpu_device *get_amdgpu_device(struct kgd_dev *kgd) ··· 567 566 case KFD_PREEMPT_TYPE_WAVEFRONT_RESET: 568 567 type = RESET_WAVES; 569 568 break; 569 + case KFD_PREEMPT_TYPE_WAVEFRONT_SAVE: 570 + type = SAVE_WAVES; 571 + break; 570 572 default: 571 573 type = DRAIN_PIPE; 572 574 break; ··· 882 878 adev->gfx.cu_info.max_waves_per_simd; 883 879 } 884 880 881 + static void kgd_gfx_v9_program_trap_handler_settings(struct kgd_dev *kgd, 882 + uint32_t vmid, uint64_t tba_addr, uint64_t tma_addr) 883 + { 884 + struct amdgpu_device *adev = get_amdgpu_device(kgd); 885 + 886 + lock_srbm(kgd, 0, 0, 0, vmid); 887 + 888 + /* 889 + * Program TBA registers 890 + */ 891 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TBA_LO), 892 + lower_32_bits(tba_addr >> 8)); 893 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TBA_HI), 894 + upper_32_bits(tba_addr >> 8)); 895 + 896 + /* 897 + * Program TMA registers 898 + */ 899 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TMA_LO), 900 + lower_32_bits(tma_addr >> 8)); 901 + WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_SHADER_TMA_HI), 902 + upper_32_bits(tma_addr >> 8)); 903 + 904 + unlock_srbm(kgd); 905 + } 906 + 885 907 const struct kfd2kgd_calls gfx_v9_kfd2kgd = { 886 908 .program_sh_mem_settings = kgd_gfx_v9_program_sh_mem_settings, 887 909 .set_pasid_vmid_mapping = kgd_gfx_v9_set_pasid_vmid_mapping, ··· 929 899 kgd_gfx_v9_get_atc_vmid_pasid_mapping_info, 930 900 .set_vm_context_page_table_base = kgd_gfx_v9_set_vm_context_page_table_base, 931 901 .get_cu_occupancy = kgd_gfx_v9_get_cu_occupancy, 902 + .program_trap_handler_settings = kgd_gfx_v9_program_trap_handler_settings, 932 903 };
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
··· 1414 1414 continue; 1415 1415 } 1416 1416 job = to_amdgpu_job(s_job); 1417 - if (preempted && job->fence == fence) 1417 + if (preempted && (&job->hw_fence) == fence) 1418 1418 /* mark the job as preempted */ 1419 1419 job->preemption_status |= AMDGPU_IB_PREEMPTED; 1420 1420 }
+21 -8
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 2829 2829 struct amdgpu_device *adev = 2830 2830 container_of(work, struct amdgpu_device, gfx.gfx_off_delay_work.work); 2831 2831 2832 - mutex_lock(&adev->gfx.gfx_off_mutex); 2833 - if (!adev->gfx.gfx_off_state && !adev->gfx.gfx_off_req_count) { 2834 - if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true)) 2835 - adev->gfx.gfx_off_state = true; 2836 - } 2837 - mutex_unlock(&adev->gfx.gfx_off_mutex); 2832 + WARN_ON_ONCE(adev->gfx.gfx_off_state); 2833 + WARN_ON_ONCE(adev->gfx.gfx_off_req_count); 2834 + 2835 + if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true)) 2836 + adev->gfx.gfx_off_state = true; 2838 2837 } 2839 2838 2840 2839 /** ··· 3825 3826 { 3826 3827 dev_info(adev->dev, "amdgpu: finishing device.\n"); 3827 3828 flush_delayed_work(&adev->delayed_init_work); 3828 - ttm_bo_lock_delayed_workqueue(&adev->mman.bdev); 3829 + if (adev->mman.initialized) { 3830 + flush_delayed_work(&adev->mman.bdev.wq); 3831 + ttm_bo_lock_delayed_workqueue(&adev->mman.bdev); 3832 + } 3829 3833 adev->shutdown = true; 3830 3834 3831 3835 /* make sure IB test finished before entering exclusive mode ··· 4450 4448 int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, 4451 4449 struct amdgpu_reset_context *reset_context) 4452 4450 { 4453 - int i, r = 0; 4451 + int i, j, r = 0; 4454 4452 struct amdgpu_job *job = NULL; 4455 4453 bool need_full_reset = 4456 4454 test_bit(AMDGPU_NEED_FULL_RESET, &reset_context->flags); ··· 4474 4472 if (!ring || !ring->sched.thread) 4475 4473 continue; 4476 4474 4475 + /*clear job fence from fence drv to avoid force_completion 4476 + *leave NULL and vm flush fence in fence drv */ 4477 + for (j = 0; j <= ring->fence_drv.num_fences_mask; j++) { 4478 + struct dma_fence *old, **ptr; 4479 + 4480 + ptr = &ring->fence_drv.fences[j]; 4481 + old = rcu_dereference_protected(*ptr, 1); 4482 + if (old && test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &old->flags)) { 4483 + RCU_INIT_POINTER(*ptr, NULL); 4484 + } 4485 + } 4477 4486 /* after all hw jobs are reset, hw fence is meaningless, so force_completion */ 4478 4487 amdgpu_fence_driver_force_completion(ring); 4479 4488 }
+9 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
··· 299 299 ip->major, ip->minor, 300 300 ip->revision); 301 301 302 + if (le16_to_cpu(ip->hw_id) == VCN_HWID) 303 + adev->vcn.num_vcn_inst++; 304 + 302 305 for (k = 0; k < num_base_address; k++) { 303 306 /* 304 307 * convert the endianness of base addresses in place, ··· 388 385 { 389 386 struct binary_header *bhdr; 390 387 struct harvest_table *harvest_info; 391 - int i; 388 + int i, vcn_harvest_count = 0; 392 389 393 390 bhdr = (struct binary_header *)adev->mman.discovery_bin; 394 391 harvest_info = (struct harvest_table *)(adev->mman.discovery_bin + ··· 400 397 401 398 switch (le32_to_cpu(harvest_info->list[i].hw_id)) { 402 399 case VCN_HWID: 403 - adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK; 404 - adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK; 400 + vcn_harvest_count++; 405 401 break; 406 402 case DMU_HWID: 407 403 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK; ··· 408 406 default: 409 407 break; 410 408 } 409 + } 410 + if (vcn_harvest_count == adev->vcn.num_vcn_inst) { 411 + adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK; 412 + adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK; 411 413 } 412 414 } 413 415
-3
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
··· 273 273 return 0; 274 274 275 275 out: 276 - if (abo) { 277 - 278 - } 279 276 if (fb && ret) { 280 277 drm_gem_object_put(gobj); 281 278 drm_framebuffer_unregister_private(fb);
+67 -19
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
··· 129 129 * 130 130 * @ring: ring the fence is associated with 131 131 * @f: resulting fence object 132 + * @job: job the fence is embedded in 132 133 * @flags: flags to pass into the subordinate .emit_fence() call 133 134 * 134 135 * Emits a fence command on the requested ring (all asics). 135 136 * Returns 0 on success, -ENOMEM on failure. 136 137 */ 137 - int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f, 138 + int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f, struct amdgpu_job *job, 138 139 unsigned flags) 139 140 { 140 141 struct amdgpu_device *adev = ring->adev; 141 - struct amdgpu_fence *fence; 142 + struct dma_fence *fence; 143 + struct amdgpu_fence *am_fence; 142 144 struct dma_fence __rcu **ptr; 143 145 uint32_t seq; 144 146 int r; 145 147 146 - fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_KERNEL); 147 - if (fence == NULL) 148 - return -ENOMEM; 148 + if (job == NULL) { 149 + /* create a sperate hw fence */ 150 + am_fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_ATOMIC); 151 + if (am_fence == NULL) 152 + return -ENOMEM; 153 + fence = &am_fence->base; 154 + am_fence->ring = ring; 155 + } else { 156 + /* take use of job-embedded fence */ 157 + fence = &job->hw_fence; 158 + } 149 159 150 160 seq = ++ring->fence_drv.sync_seq; 151 - fence->ring = ring; 152 - dma_fence_init(&fence->base, &amdgpu_fence_ops, 153 - &ring->fence_drv.lock, 154 - adev->fence_context + ring->idx, 155 - seq); 161 + if (job != NULL && job->job_run_counter) { 162 + /* reinit seq for resubmitted jobs */ 163 + fence->seqno = seq; 164 + } else { 165 + dma_fence_init(fence, &amdgpu_fence_ops, 166 + &ring->fence_drv.lock, 167 + adev->fence_context + ring->idx, 168 + seq); 169 + } 170 + 171 + if (job != NULL) { 172 + /* mark this fence has a parent job */ 173 + set_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &fence->flags); 174 + } 175 + 156 176 amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr, 157 177 seq, flags | AMDGPU_FENCE_FLAG_INT); 158 178 pm_runtime_get_noresume(adev_to_drm(adev)->dev); ··· 195 175 /* This function can't be called concurrently anyway, otherwise 196 176 * emitting the fence would mess up the hardware ring buffer. 197 177 */ 198 - rcu_assign_pointer(*ptr, dma_fence_get(&fence->base)); 178 + rcu_assign_pointer(*ptr, dma_fence_get(fence)); 199 179 200 - *f = &fence->base; 180 + *f = fence; 201 181 202 182 return 0; 203 183 } ··· 641 621 642 622 static const char *amdgpu_fence_get_timeline_name(struct dma_fence *f) 643 623 { 644 - struct amdgpu_fence *fence = to_amdgpu_fence(f); 645 - return (const char *)fence->ring->name; 624 + struct amdgpu_ring *ring; 625 + 626 + if (test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &f->flags)) { 627 + struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence); 628 + 629 + ring = to_amdgpu_ring(job->base.sched); 630 + } else { 631 + ring = to_amdgpu_fence(f)->ring; 632 + } 633 + return (const char *)ring->name; 646 634 } 647 635 648 636 /** ··· 663 635 */ 664 636 static bool amdgpu_fence_enable_signaling(struct dma_fence *f) 665 637 { 666 - struct amdgpu_fence *fence = to_amdgpu_fence(f); 667 - struct amdgpu_ring *ring = fence->ring; 638 + struct amdgpu_ring *ring; 639 + 640 + if (test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &f->flags)) { 641 + struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence); 642 + 643 + ring = to_amdgpu_ring(job->base.sched); 644 + } else { 645 + ring = to_amdgpu_fence(f)->ring; 646 + } 668 647 669 648 if (!timer_pending(&ring->fence_drv.fallback_timer)) 670 649 amdgpu_fence_schedule_fallback(ring); 671 650 672 - DMA_FENCE_TRACE(&fence->base, "armed on ring %i!\n", ring->idx); 651 + DMA_FENCE_TRACE(f, "armed on ring %i!\n", ring->idx); 673 652 674 653 return true; 675 654 } ··· 691 656 static void amdgpu_fence_free(struct rcu_head *rcu) 692 657 { 693 658 struct dma_fence *f = container_of(rcu, struct dma_fence, rcu); 694 - struct amdgpu_fence *fence = to_amdgpu_fence(f); 695 - kmem_cache_free(amdgpu_fence_slab, fence); 659 + 660 + if (test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &f->flags)) { 661 + /* free job if fence has a parent job */ 662 + struct amdgpu_job *job; 663 + 664 + job = container_of(f, struct amdgpu_job, hw_fence); 665 + kfree(job); 666 + } else { 667 + /* free fence_slab if it's separated fence*/ 668 + struct amdgpu_fence *fence; 669 + 670 + fence = to_amdgpu_fence(f); 671 + kmem_cache_free(amdgpu_fence_slab, fence); 672 + } 696 673 } 697 674 698 675 /** ··· 726 679 .enable_signaling = amdgpu_fence_enable_signaling, 727 680 .release = amdgpu_fence_release, 728 681 }; 682 + 729 683 730 684 /* 731 685 * Fence debugfs
+25 -12
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
··· 563 563 564 564 mutex_lock(&adev->gfx.gfx_off_mutex); 565 565 566 - if (!enable) 567 - adev->gfx.gfx_off_req_count++; 568 - else if (adev->gfx.gfx_off_req_count > 0) 566 + if (enable) { 567 + /* If the count is already 0, it means there's an imbalance bug somewhere. 568 + * Note that the bug may be in a different caller than the one which triggers the 569 + * WARN_ON_ONCE. 570 + */ 571 + if (WARN_ON_ONCE(adev->gfx.gfx_off_req_count == 0)) 572 + goto unlock; 573 + 569 574 adev->gfx.gfx_off_req_count--; 570 575 571 - if (enable && !adev->gfx.gfx_off_state && !adev->gfx.gfx_off_req_count) { 572 - schedule_delayed_work(&adev->gfx.gfx_off_delay_work, GFX_OFF_DELAY_ENABLE); 573 - } else if (!enable && adev->gfx.gfx_off_state) { 574 - if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false)) { 575 - adev->gfx.gfx_off_state = false; 576 + if (adev->gfx.gfx_off_req_count == 0 && !adev->gfx.gfx_off_state) 577 + schedule_delayed_work(&adev->gfx.gfx_off_delay_work, GFX_OFF_DELAY_ENABLE); 578 + } else { 579 + if (adev->gfx.gfx_off_req_count == 0) { 580 + cancel_delayed_work_sync(&adev->gfx.gfx_off_delay_work); 576 581 577 - if (adev->gfx.funcs->init_spm_golden) { 578 - dev_dbg(adev->dev, "GFXOFF is disabled, re-init SPM golden settings\n"); 579 - amdgpu_gfx_init_spm_golden(adev); 582 + if (adev->gfx.gfx_off_state && 583 + !amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false)) { 584 + adev->gfx.gfx_off_state = false; 585 + 586 + if (adev->gfx.funcs->init_spm_golden) { 587 + dev_dbg(adev->dev, 588 + "GFXOFF is disabled, re-init SPM golden settings\n"); 589 + amdgpu_gfx_init_spm_golden(adev); 590 + } 580 591 } 581 592 } 593 + 594 + adev->gfx.gfx_off_req_count++; 582 595 } 583 596 597 + unlock: 584 598 mutex_unlock(&adev->gfx.gfx_off_mutex); 585 599 } 586 600 ··· 629 615 adev->gfx.ras_if->block = AMDGPU_RAS_BLOCK__GFX; 630 616 adev->gfx.ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE; 631 617 adev->gfx.ras_if->sub_block_index = 0; 632 - strcpy(adev->gfx.ras_if->name, "gfx"); 633 618 } 634 619 fs_info.head = ih_info.head = *adev->gfx.ras_if; 635 620 r = amdgpu_ras_late_init(adev, adev->gfx.ras_if,
-1
drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.c
··· 41 41 adev->hdp.ras_if->block = AMDGPU_RAS_BLOCK__HDP; 42 42 adev->hdp.ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE; 43 43 adev->hdp.ras_if->sub_block_index = 0; 44 - strcpy(adev->hdp.ras_if->name, "hdp"); 45 44 } 46 45 ih_info.head = fs_info.head = *adev->hdp.ras_if; 47 46 r = amdgpu_ras_late_init(adev, adev->hdp.ras_if,
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
··· 339 339 void 340 340 amdgpu_i2c_router_select_ddc_port(const struct amdgpu_connector *amdgpu_connector) 341 341 { 342 - u8 val; 342 + u8 val = 0; 343 343 344 344 if (!amdgpu_connector->router.ddc_valid) 345 345 return;
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
··· 262 262 fence_flags | AMDGPU_FENCE_FLAG_64BIT); 263 263 } 264 264 265 - r = amdgpu_fence_emit(ring, f, fence_flags); 265 + r = amdgpu_fence_emit(ring, f, job, fence_flags); 266 266 if (r) { 267 267 dev_err(adev->dev, "failed to emit fence (%d)\n", r); 268 268 if (job && job->vmid)
+28 -11
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
··· 127 127 { 128 128 struct amdgpu_ring *ring = to_amdgpu_ring(job->base.sched); 129 129 struct dma_fence *f; 130 + struct dma_fence *hw_fence; 130 131 unsigned i; 131 132 132 - /* use sched fence if available */ 133 - f = job->base.s_fence ? &job->base.s_fence->finished : job->fence; 133 + if (job->hw_fence.ops == NULL) 134 + hw_fence = job->external_hw_fence; 135 + else 136 + hw_fence = &job->hw_fence; 134 137 138 + /* use sched fence if available */ 139 + f = job->base.s_fence ? &job->base.s_fence->finished : hw_fence; 135 140 for (i = 0; i < job->num_ibs; ++i) 136 141 amdgpu_ib_free(ring->adev, &job->ibs[i], f); 137 142 } ··· 147 142 148 143 drm_sched_job_cleanup(s_job); 149 144 150 - dma_fence_put(job->fence); 151 145 amdgpu_sync_free(&job->sync); 152 146 amdgpu_sync_free(&job->sched_sync); 153 - kfree(job); 147 + 148 + /* only put the hw fence if has embedded fence */ 149 + if (job->hw_fence.ops != NULL) 150 + dma_fence_put(&job->hw_fence); 151 + else 152 + kfree(job); 154 153 } 155 154 156 155 void amdgpu_job_free(struct amdgpu_job *job) 157 156 { 158 157 amdgpu_job_free_resources(job); 159 - 160 - dma_fence_put(job->fence); 161 158 amdgpu_sync_free(&job->sync); 162 159 amdgpu_sync_free(&job->sched_sync); 163 - kfree(job); 160 + 161 + /* only put the hw fence if has embedded fence */ 162 + if (job->hw_fence.ops != NULL) 163 + dma_fence_put(&job->hw_fence); 164 + else 165 + kfree(job); 164 166 } 165 167 166 168 int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity, ··· 196 184 197 185 job->base.sched = &ring->sched; 198 186 r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs, NULL, fence); 199 - job->fence = dma_fence_get(*fence); 187 + /* record external_hw_fence for direct submit */ 188 + job->external_hw_fence = dma_fence_get(*fence); 200 189 if (r) 201 190 return r; 202 191 203 192 amdgpu_job_free(job); 193 + dma_fence_put(*fence); 194 + 204 195 return 0; 205 196 } 206 197 ··· 261 246 if (r) 262 247 DRM_ERROR("Error scheduling IBs (%d)\n", r); 263 248 } 264 - /* if gpu reset, hw fence will be replaced here */ 265 - dma_fence_put(job->fence); 266 - job->fence = dma_fence_get(fence); 267 249 250 + if (!job->job_run_counter) 251 + dma_fence_get(fence); 252 + else if (finished->error < 0) 253 + dma_fence_put(&job->hw_fence); 254 + job->job_run_counter++; 268 255 amdgpu_job_free_resources(job); 269 256 270 257 fence = r ? ERR_PTR(r) : fence;
+5 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
··· 46 46 struct amdgpu_sync sync; 47 47 struct amdgpu_sync sched_sync; 48 48 struct amdgpu_ib *ibs; 49 - struct dma_fence *fence; /* the hw fence */ 49 + struct dma_fence hw_fence; 50 + struct dma_fence *external_hw_fence; 50 51 uint32_t preamble_status; 51 52 uint32_t preemption_status; 52 53 uint32_t num_ibs; ··· 63 62 /* user fence handling */ 64 63 uint64_t uf_addr; 65 64 uint64_t uf_sequence; 65 + 66 + /* job_run_counter >= 1 means a resubmit job */ 67 + uint32_t job_run_counter; 66 68 }; 67 69 68 70 int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
+8 -8
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
··· 341 341 switch (query_fw->index) { 342 342 case TA_FW_TYPE_PSP_XGMI: 343 343 fw_info->ver = adev->psp.ta_fw_version; 344 - fw_info->feature = adev->psp.ta_xgmi_ucode_version; 344 + fw_info->feature = adev->psp.xgmi.feature_version; 345 345 break; 346 346 case TA_FW_TYPE_PSP_RAS: 347 347 fw_info->ver = adev->psp.ta_fw_version; 348 - fw_info->feature = adev->psp.ta_ras_ucode_version; 348 + fw_info->feature = adev->psp.ras.feature_version; 349 349 break; 350 350 case TA_FW_TYPE_PSP_HDCP: 351 351 fw_info->ver = adev->psp.ta_fw_version; 352 - fw_info->feature = adev->psp.ta_hdcp_ucode_version; 352 + fw_info->feature = adev->psp.hdcp.feature_version; 353 353 break; 354 354 case TA_FW_TYPE_PSP_DTM: 355 355 fw_info->ver = adev->psp.ta_fw_version; 356 - fw_info->feature = adev->psp.ta_dtm_ucode_version; 356 + fw_info->feature = adev->psp.dtm.feature_version; 357 357 break; 358 358 case TA_FW_TYPE_PSP_RAP: 359 359 fw_info->ver = adev->psp.ta_fw_version; 360 - fw_info->feature = adev->psp.ta_rap_ucode_version; 360 + fw_info->feature = adev->psp.rap.feature_version; 361 361 break; 362 362 case TA_FW_TYPE_PSP_SECUREDISPLAY: 363 363 fw_info->ver = adev->psp.ta_fw_version; 364 - fw_info->feature = adev->psp.ta_securedisplay_ucode_version; 364 + fw_info->feature = adev->psp.securedisplay.feature_version; 365 365 break; 366 366 default: 367 367 return -EINVAL; ··· 378 378 fw_info->feature = adev->psp.sos.feature_version; 379 379 break; 380 380 case AMDGPU_INFO_FW_ASD: 381 - fw_info->ver = adev->psp.asd_fw_version; 382 - fw_info->feature = adev->psp.asd_feature_version; 381 + fw_info->ver = adev->psp.asd.fw_version; 382 + fw_info->feature = adev->psp.asd.feature_version; 383 383 break; 384 384 case AMDGPU_INFO_FW_DMCU: 385 385 fw_info->ver = adev->dm.dmcu_fw_version;
-1
drivers/gpu/drm/amd/amdgpu/amdgpu_mmhub.c
··· 41 41 adev->mmhub.ras_if->block = AMDGPU_RAS_BLOCK__MMHUB; 42 42 adev->mmhub.ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE; 43 43 adev->mmhub.ras_if->sub_block_index = 0; 44 - strcpy(adev->mmhub.ras_if->name, "mmhub"); 45 44 } 46 45 ih_info.head = fs_info.head = *adev->mmhub.ras_if; 47 46 r = amdgpu_ras_late_init(adev, adev->mmhub.ras_if,
-1
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c
··· 39 39 adev->nbio.ras_if->block = AMDGPU_RAS_BLOCK__PCIE_BIF; 40 40 adev->nbio.ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE; 41 41 adev->nbio.ras_if->sub_block_index = 0; 42 - strcpy(adev->nbio.ras_if->name, "pcie_bif"); 43 42 } 44 43 ih_info.head = fs_info.head = *adev->nbio.ras_if; 45 44 r = amdgpu_ras_late_init(adev, adev->nbio.ras_if,
+5 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 920 920 return -EINVAL; 921 921 } 922 922 923 - /* This assumes only APU display buffers are pinned with (VRAM|GTT). 924 - * See function amdgpu_display_supported_domains() 925 - */ 926 - domain = amdgpu_bo_get_preferred_pin_domain(adev, domain); 927 - 928 923 if (bo->tbo.pin_count) { 929 924 uint32_t mem_type = bo->tbo.resource->mem_type; 930 925 uint32_t mem_flags = bo->tbo.resource->placement; ··· 943 948 944 949 return 0; 945 950 } 951 + 952 + /* This assumes only APU display buffers are pinned with (VRAM|GTT). 953 + * See function amdgpu_display_supported_domains() 954 + */ 955 + domain = amdgpu_bo_get_preferred_pin_domain(adev, domain); 946 956 947 957 if (bo->tbo.base.import_attach) 948 958 dma_buf_pin(bo->tbo.base.import_attach);
+253 -179
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 29 29 #include "amdgpu.h" 30 30 #include "amdgpu_psp.h" 31 31 #include "amdgpu_ucode.h" 32 + #include "amdgpu_xgmi.h" 32 33 #include "soc15_common.h" 33 34 #include "psp_v3_1.h" 34 35 #include "psp_v10_0.h" ··· 800 799 * add workaround to bypass it for sriov now. 801 800 * TODO: add version check to make it common 802 801 */ 803 - if (amdgpu_sriov_vf(psp->adev) || !psp->asd_ucode_size) 802 + if (amdgpu_sriov_vf(psp->adev) || !psp->asd.size_bytes) 804 803 return 0; 805 804 806 805 cmd = acquire_psp_cmd_buf(psp); 807 806 808 - psp_copy_fw(psp, psp->asd_start_addr, psp->asd_ucode_size); 807 + psp_copy_fw(psp, psp->asd.start_addr, psp->asd.size_bytes); 809 808 810 809 psp_prep_asd_load_cmd_buf(cmd, psp->fw_pri_mc_addr, 811 - psp->asd_ucode_size); 810 + psp->asd.size_bytes); 812 811 813 812 ret = psp_cmd_submit_buf(psp, NULL, cmd, 814 813 psp->fence_buf_mc_addr); ··· 909 908 */ 910 909 ret = amdgpu_bo_create_kernel(psp->adev, PSP_XGMI_SHARED_MEM_SIZE, 911 910 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, 912 - &psp->xgmi_context.xgmi_shared_bo, 913 - &psp->xgmi_context.xgmi_shared_mc_addr, 914 - &psp->xgmi_context.xgmi_shared_buf); 911 + &psp->xgmi_context.context.mem_context.shared_bo, 912 + &psp->xgmi_context.context.mem_context.shared_mc_addr, 913 + &psp->xgmi_context.context.mem_context.shared_buf); 915 914 916 915 return ret; 917 916 } ··· 953 952 954 953 cmd = acquire_psp_cmd_buf(psp); 955 954 956 - psp_copy_fw(psp, psp->ta_xgmi_start_addr, psp->ta_xgmi_ucode_size); 955 + psp_copy_fw(psp, psp->xgmi.start_addr, psp->xgmi.size_bytes); 957 956 958 957 psp_prep_ta_load_cmd_buf(cmd, 959 958 psp->fw_pri_mc_addr, 960 - psp->ta_xgmi_ucode_size, 961 - psp->xgmi_context.xgmi_shared_mc_addr, 959 + psp->xgmi.size_bytes, 960 + psp->xgmi_context.context.mem_context.shared_mc_addr, 962 961 PSP_XGMI_SHARED_MEM_SIZE); 963 962 964 963 ret = psp_cmd_submit_buf(psp, NULL, cmd, 965 964 psp->fence_buf_mc_addr); 966 965 967 966 if (!ret) { 968 - psp->xgmi_context.initialized = 1; 969 - psp->xgmi_context.session_id = cmd->resp.session_id; 967 + psp->xgmi_context.context.initialized = true; 968 + psp->xgmi_context.context.session_id = cmd->resp.session_id; 970 969 } 971 970 972 971 release_psp_cmd_buf(psp); ··· 991 990 992 991 cmd = acquire_psp_cmd_buf(psp); 993 992 994 - psp_prep_ta_unload_cmd_buf(cmd, psp->xgmi_context.session_id); 993 + psp_prep_ta_unload_cmd_buf(cmd, psp->xgmi_context.context.session_id); 995 994 996 995 ret = psp_cmd_submit_buf(psp, NULL, cmd, 997 996 psp->fence_buf_mc_addr); ··· 1003 1002 1004 1003 int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id) 1005 1004 { 1006 - return psp_ta_invoke(psp, ta_cmd_id, psp->xgmi_context.session_id); 1005 + return psp_ta_invoke(psp, ta_cmd_id, psp->xgmi_context.context.session_id); 1007 1006 } 1008 1007 1009 1008 int psp_xgmi_terminate(struct psp_context *psp) 1010 1009 { 1011 1010 int ret; 1012 1011 1013 - if (!psp->xgmi_context.initialized) 1012 + if (!psp->xgmi_context.context.initialized) 1014 1013 return 0; 1015 1014 1016 1015 ret = psp_xgmi_unload(psp); 1017 1016 if (ret) 1018 1017 return ret; 1019 1018 1020 - psp->xgmi_context.initialized = 0; 1019 + psp->xgmi_context.context.initialized = false; 1021 1020 1022 1021 /* free xgmi shared memory */ 1023 - amdgpu_bo_free_kernel(&psp->xgmi_context.xgmi_shared_bo, 1024 - &psp->xgmi_context.xgmi_shared_mc_addr, 1025 - &psp->xgmi_context.xgmi_shared_buf); 1022 + amdgpu_bo_free_kernel(&psp->xgmi_context.context.mem_context.shared_bo, 1023 + &psp->xgmi_context.context.mem_context.shared_mc_addr, 1024 + &psp->xgmi_context.context.mem_context.shared_buf); 1026 1025 1027 1026 return 0; 1028 1027 } 1029 1028 1030 - int psp_xgmi_initialize(struct psp_context *psp) 1029 + int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool load_ta) 1031 1030 { 1032 1031 struct ta_xgmi_shared_memory *xgmi_cmd; 1033 1032 int ret; 1034 1033 1035 - if (!psp->adev->psp.ta_fw || 1036 - !psp->adev->psp.ta_xgmi_ucode_size || 1037 - !psp->adev->psp.ta_xgmi_start_addr) 1034 + if (!psp->ta_fw || 1035 + !psp->xgmi.size_bytes || 1036 + !psp->xgmi.start_addr) 1038 1037 return -ENOENT; 1039 1038 1040 - if (!psp->xgmi_context.initialized) { 1039 + if (!load_ta) 1040 + goto invoke; 1041 + 1042 + if (!psp->xgmi_context.context.initialized) { 1041 1043 ret = psp_xgmi_init_shared_buf(psp); 1042 1044 if (ret) 1043 1045 return ret; ··· 1051 1047 if (ret) 1052 1048 return ret; 1053 1049 1050 + invoke: 1054 1051 /* Initialize XGMI session */ 1055 - xgmi_cmd = (struct ta_xgmi_shared_memory *)(psp->xgmi_context.xgmi_shared_buf); 1052 + xgmi_cmd = (struct ta_xgmi_shared_memory *)(psp->xgmi_context.context.mem_context.shared_buf); 1056 1053 memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory)); 1054 + xgmi_cmd->flag_extend_link_record = set_extended_data; 1057 1055 xgmi_cmd->cmd_id = TA_COMMAND_XGMI__INITIALIZE; 1058 1056 1059 1057 ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id); ··· 1068 1062 struct ta_xgmi_shared_memory *xgmi_cmd; 1069 1063 int ret; 1070 1064 1071 - xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.xgmi_shared_buf; 1065 + xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.context.mem_context.shared_buf; 1072 1066 memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory)); 1073 1067 1074 1068 xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_HIVE_ID; ··· 1088 1082 struct ta_xgmi_shared_memory *xgmi_cmd; 1089 1083 int ret; 1090 1084 1091 - xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.xgmi_shared_buf; 1085 + xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.context.mem_context.shared_buf; 1092 1086 memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory)); 1093 1087 1094 1088 xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_NODE_ID; ··· 1106 1100 static bool psp_xgmi_peer_link_info_supported(struct psp_context *psp) 1107 1101 { 1108 1102 return psp->adev->asic_type == CHIP_ALDEBARAN && 1109 - psp->ta_xgmi_ucode_version >= 0x2000000b; 1103 + psp->xgmi.feature_version >= 0x2000000b; 1104 + } 1105 + 1106 + /* 1107 + * Chips that support extended topology information require the driver to 1108 + * reflect topology information in the opposite direction. This is 1109 + * because the TA has already exceeded its link record limit and if the 1110 + * TA holds bi-directional information, the driver would have to do 1111 + * multiple fetches instead of just two. 1112 + */ 1113 + static void psp_xgmi_reflect_topology_info(struct psp_context *psp, 1114 + struct psp_xgmi_node_info node_info) 1115 + { 1116 + struct amdgpu_device *mirror_adev; 1117 + struct amdgpu_hive_info *hive; 1118 + uint64_t src_node_id = psp->adev->gmc.xgmi.node_id; 1119 + uint64_t dst_node_id = node_info.node_id; 1120 + uint8_t dst_num_hops = node_info.num_hops; 1121 + uint8_t dst_num_links = node_info.num_links; 1122 + 1123 + hive = amdgpu_get_xgmi_hive(psp->adev); 1124 + list_for_each_entry(mirror_adev, &hive->device_list, gmc.xgmi.head) { 1125 + struct psp_xgmi_topology_info *mirror_top_info; 1126 + int j; 1127 + 1128 + if (mirror_adev->gmc.xgmi.node_id != dst_node_id) 1129 + continue; 1130 + 1131 + mirror_top_info = &mirror_adev->psp.xgmi_context.top_info; 1132 + for (j = 0; j < mirror_top_info->num_nodes; j++) { 1133 + if (mirror_top_info->nodes[j].node_id != src_node_id) 1134 + continue; 1135 + 1136 + mirror_top_info->nodes[j].num_hops = dst_num_hops; 1137 + /* 1138 + * prevent 0 num_links value re-reflection since reflection 1139 + * criteria is based on num_hops (direct or indirect). 1140 + * 1141 + */ 1142 + if (dst_num_links) 1143 + mirror_top_info->nodes[j].num_links = dst_num_links; 1144 + 1145 + break; 1146 + } 1147 + 1148 + break; 1149 + } 1110 1150 } 1111 1151 1112 1152 int psp_xgmi_get_topology_info(struct psp_context *psp, 1113 1153 int number_devices, 1114 - struct psp_xgmi_topology_info *topology) 1154 + struct psp_xgmi_topology_info *topology, 1155 + bool get_extended_data) 1115 1156 { 1116 1157 struct ta_xgmi_shared_memory *xgmi_cmd; 1117 1158 struct ta_xgmi_cmd_get_topology_info_input *topology_info_input; ··· 1169 1116 if (!topology || topology->num_nodes > TA_XGMI__MAX_CONNECTED_NODES) 1170 1117 return -EINVAL; 1171 1118 1172 - xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.xgmi_shared_buf; 1119 + xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.context.mem_context.shared_buf; 1173 1120 memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory)); 1121 + xgmi_cmd->flag_extend_link_record = get_extended_data; 1174 1122 1175 1123 /* Fill in the shared memory with topology information as input */ 1176 1124 topology_info_input = &xgmi_cmd->xgmi_in_message.get_topology_info; ··· 1194 1140 topology_info_output = &xgmi_cmd->xgmi_out_message.get_topology_info; 1195 1141 topology->num_nodes = xgmi_cmd->xgmi_out_message.get_topology_info.num_nodes; 1196 1142 for (i = 0; i < topology->num_nodes; i++) { 1197 - topology->nodes[i].node_id = topology_info_output->nodes[i].node_id; 1198 - topology->nodes[i].num_hops = topology_info_output->nodes[i].num_hops; 1199 - topology->nodes[i].is_sharing_enabled = topology_info_output->nodes[i].is_sharing_enabled; 1200 - topology->nodes[i].sdma_engine = topology_info_output->nodes[i].sdma_engine; 1143 + /* extended data will either be 0 or equal to non-extended data */ 1144 + if (topology_info_output->nodes[i].num_hops) 1145 + topology->nodes[i].num_hops = topology_info_output->nodes[i].num_hops; 1146 + 1147 + /* non-extended data gets everything here so no need to update */ 1148 + if (!get_extended_data) { 1149 + topology->nodes[i].node_id = topology_info_output->nodes[i].node_id; 1150 + topology->nodes[i].is_sharing_enabled = 1151 + topology_info_output->nodes[i].is_sharing_enabled; 1152 + topology->nodes[i].sdma_engine = 1153 + topology_info_output->nodes[i].sdma_engine; 1154 + } 1155 + 1201 1156 } 1202 1157 1203 1158 /* Invoke xgmi ta again to get the link information */ ··· 1221 1158 return ret; 1222 1159 1223 1160 link_info_output = &xgmi_cmd->xgmi_out_message.get_link_info; 1224 - for (i = 0; i < topology->num_nodes; i++) 1225 - topology->nodes[i].num_links = 1161 + for (i = 0; i < topology->num_nodes; i++) { 1162 + /* accumulate num_links on extended data */ 1163 + topology->nodes[i].num_links = get_extended_data ? 1164 + topology->nodes[i].num_links + 1165 + link_info_output->nodes[i].num_links : 1226 1166 link_info_output->nodes[i].num_links; 1167 + 1168 + /* reflect the topology information for bi-directionality */ 1169 + if (psp->xgmi_context.supports_extended_data && 1170 + get_extended_data && topology->nodes[i].num_hops) 1171 + psp_xgmi_reflect_topology_info(psp, topology->nodes[i]); 1172 + } 1227 1173 } 1228 1174 1229 1175 return 0; ··· 1249 1177 if (!topology || topology->num_nodes > TA_XGMI__MAX_CONNECTED_NODES) 1250 1178 return -EINVAL; 1251 1179 1252 - xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.xgmi_shared_buf; 1180 + xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.context.mem_context.shared_buf; 1253 1181 memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory)); 1254 1182 1255 1183 topology_info_input = &xgmi_cmd->xgmi_in_message.get_topology_info; ··· 1278 1206 */ 1279 1207 ret = amdgpu_bo_create_kernel(psp->adev, PSP_RAS_SHARED_MEM_SIZE, 1280 1208 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, 1281 - &psp->ras.ras_shared_bo, 1282 - &psp->ras.ras_shared_mc_addr, 1283 - &psp->ras.ras_shared_buf); 1209 + &psp->ras_context.context.mem_context.shared_bo, 1210 + &psp->ras_context.context.mem_context.shared_mc_addr, 1211 + &psp->ras_context.context.mem_context.shared_buf); 1284 1212 1285 1213 return ret; 1286 1214 } ··· 1297 1225 if (amdgpu_sriov_vf(psp->adev)) 1298 1226 return 0; 1299 1227 1300 - psp_copy_fw(psp, psp->ta_ras_start_addr, psp->ta_ras_ucode_size); 1228 + psp_copy_fw(psp, psp->ras.start_addr, psp->ras.size_bytes); 1301 1229 1302 - ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf; 1230 + ras_cmd = (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; 1303 1231 1304 1232 if (psp->adev->gmc.xgmi.connected_to_cpu) 1305 1233 ras_cmd->ras_in_message.init_flags.poison_mode_en = 1; ··· 1310 1238 1311 1239 psp_prep_ta_load_cmd_buf(cmd, 1312 1240 psp->fw_pri_mc_addr, 1313 - psp->ta_ras_ucode_size, 1314 - psp->ras.ras_shared_mc_addr, 1241 + psp->ras.size_bytes, 1242 + psp->ras_context.context.mem_context.shared_mc_addr, 1315 1243 PSP_RAS_SHARED_MEM_SIZE); 1316 1244 1317 1245 ret = psp_cmd_submit_buf(psp, NULL, cmd, 1318 1246 psp->fence_buf_mc_addr); 1319 1247 1320 1248 if (!ret) { 1321 - psp->ras.session_id = cmd->resp.session_id; 1249 + psp->ras_context.context.session_id = cmd->resp.session_id; 1322 1250 1323 1251 if (!ras_cmd->ras_status) 1324 - psp->ras.ras_initialized = true; 1252 + psp->ras_context.context.initialized = true; 1325 1253 else 1326 1254 dev_warn(psp->adev->dev, "RAS Init Status: 0x%X\n", ras_cmd->ras_status); 1327 1255 } ··· 1347 1275 1348 1276 cmd = acquire_psp_cmd_buf(psp); 1349 1277 1350 - psp_prep_ta_unload_cmd_buf(cmd, psp->ras.session_id); 1278 + psp_prep_ta_unload_cmd_buf(cmd, psp->ras_context.context.session_id); 1351 1279 1352 1280 ret = psp_cmd_submit_buf(psp, NULL, cmd, 1353 1281 psp->fence_buf_mc_addr); ··· 1362 1290 struct ta_ras_shared_memory *ras_cmd; 1363 1291 int ret; 1364 1292 1365 - ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf; 1293 + ras_cmd = (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; 1366 1294 1367 1295 /* 1368 1296 * TODO: bypass the loading in sriov for now ··· 1370 1298 if (amdgpu_sriov_vf(psp->adev)) 1371 1299 return 0; 1372 1300 1373 - ret = psp_ta_invoke(psp, ta_cmd_id, psp->ras.session_id); 1301 + ret = psp_ta_invoke(psp, ta_cmd_id, psp->ras_context.context.session_id); 1374 1302 1375 1303 if (amdgpu_ras_intr_triggered()) 1376 1304 return ret; ··· 1426 1354 struct ta_ras_shared_memory *ras_cmd; 1427 1355 int ret; 1428 1356 1429 - if (!psp->ras.ras_initialized) 1357 + if (!psp->ras_context.context.initialized) 1430 1358 return -EINVAL; 1431 1359 1432 - ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf; 1360 + ras_cmd = (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; 1433 1361 memset(ras_cmd, 0, sizeof(struct ta_ras_shared_memory)); 1434 1362 1435 1363 if (enable) ··· 1456 1384 if (amdgpu_sriov_vf(psp->adev)) 1457 1385 return 0; 1458 1386 1459 - if (!psp->ras.ras_initialized) 1387 + if (!psp->ras_context.context.initialized) 1460 1388 return 0; 1461 1389 1462 1390 ret = psp_ras_unload(psp); 1463 1391 if (ret) 1464 1392 return ret; 1465 1393 1466 - psp->ras.ras_initialized = false; 1394 + psp->ras_context.context.initialized = false; 1467 1395 1468 1396 /* free ras shared memory */ 1469 - amdgpu_bo_free_kernel(&psp->ras.ras_shared_bo, 1470 - &psp->ras.ras_shared_mc_addr, 1471 - &psp->ras.ras_shared_buf); 1397 + amdgpu_bo_free_kernel(&psp->ras_context.context.mem_context.shared_bo, 1398 + &psp->ras_context.context.mem_context.shared_mc_addr, 1399 + &psp->ras_context.context.mem_context.shared_buf); 1472 1400 1473 1401 return 0; 1474 1402 } ··· 1485 1413 if (amdgpu_sriov_vf(adev)) 1486 1414 return 0; 1487 1415 1488 - if (!adev->psp.ta_ras_ucode_size || 1489 - !adev->psp.ta_ras_start_addr) { 1416 + if (!adev->psp.ras.size_bytes || 1417 + !adev->psp.ras.start_addr) { 1490 1418 dev_info(adev->dev, "RAS: optional ras ta ucode is not available\n"); 1491 1419 return 0; 1492 1420 } ··· 1532 1460 } 1533 1461 } 1534 1462 1535 - if (!psp->ras.ras_initialized) { 1463 + if (!psp->ras_context.context.initialized) { 1536 1464 ret = psp_ras_init_shared_buf(psp); 1537 1465 if (ret) 1538 1466 return ret; ··· 1551 1479 struct ta_ras_shared_memory *ras_cmd; 1552 1480 int ret; 1553 1481 1554 - if (!psp->ras.ras_initialized) 1482 + if (!psp->ras_context.context.initialized) 1555 1483 return -EINVAL; 1556 1484 1557 - ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf; 1485 + ras_cmd = (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; 1558 1486 memset(ras_cmd, 0, sizeof(struct ta_ras_shared_memory)); 1559 1487 1560 1488 ras_cmd->cmd_id = TA_RAS_COMMAND__TRIGGER_ERROR; ··· 1584 1512 */ 1585 1513 ret = amdgpu_bo_create_kernel(psp->adev, PSP_HDCP_SHARED_MEM_SIZE, 1586 1514 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, 1587 - &psp->hdcp_context.hdcp_shared_bo, 1588 - &psp->hdcp_context.hdcp_shared_mc_addr, 1589 - &psp->hdcp_context.hdcp_shared_buf); 1515 + &psp->hdcp_context.context.mem_context.shared_bo, 1516 + &psp->hdcp_context.context.mem_context.shared_mc_addr, 1517 + &psp->hdcp_context.context.mem_context.shared_buf); 1590 1518 1591 1519 return ret; 1592 1520 } ··· 1602 1530 if (amdgpu_sriov_vf(psp->adev)) 1603 1531 return 0; 1604 1532 1605 - psp_copy_fw(psp, psp->ta_hdcp_start_addr, 1606 - psp->ta_hdcp_ucode_size); 1533 + psp_copy_fw(psp, psp->hdcp.start_addr, 1534 + psp->hdcp.size_bytes); 1607 1535 1608 1536 cmd = acquire_psp_cmd_buf(psp); 1609 1537 1610 1538 psp_prep_ta_load_cmd_buf(cmd, 1611 1539 psp->fw_pri_mc_addr, 1612 - psp->ta_hdcp_ucode_size, 1613 - psp->hdcp_context.hdcp_shared_mc_addr, 1540 + psp->hdcp.size_bytes, 1541 + psp->hdcp_context.context.mem_context.shared_mc_addr, 1614 1542 PSP_HDCP_SHARED_MEM_SIZE); 1615 1543 1616 1544 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 1617 1545 1618 1546 if (!ret) { 1619 - psp->hdcp_context.hdcp_initialized = true; 1620 - psp->hdcp_context.session_id = cmd->resp.session_id; 1547 + psp->hdcp_context.context.initialized = true; 1548 + psp->hdcp_context.context.session_id = cmd->resp.session_id; 1621 1549 mutex_init(&psp->hdcp_context.mutex); 1622 1550 } 1623 1551 ··· 1635 1563 if (amdgpu_sriov_vf(psp->adev)) 1636 1564 return 0; 1637 1565 1638 - if (!psp->adev->psp.ta_hdcp_ucode_size || 1639 - !psp->adev->psp.ta_hdcp_start_addr) { 1566 + if (!psp->hdcp.size_bytes || 1567 + !psp->hdcp.start_addr) { 1640 1568 dev_info(psp->adev->dev, "HDCP: optional hdcp ta ucode is not available\n"); 1641 1569 return 0; 1642 1570 } 1643 1571 1644 - if (!psp->hdcp_context.hdcp_initialized) { 1572 + if (!psp->hdcp_context.context.initialized) { 1645 1573 ret = psp_hdcp_init_shared_buf(psp); 1646 1574 if (ret) 1647 1575 return ret; ··· 1667 1595 1668 1596 cmd = acquire_psp_cmd_buf(psp); 1669 1597 1670 - psp_prep_ta_unload_cmd_buf(cmd, psp->hdcp_context.session_id); 1598 + psp_prep_ta_unload_cmd_buf(cmd, psp->hdcp_context.context.session_id); 1671 1599 1672 1600 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 1673 1601 ··· 1684 1612 if (amdgpu_sriov_vf(psp->adev)) 1685 1613 return 0; 1686 1614 1687 - return psp_ta_invoke(psp, ta_cmd_id, psp->hdcp_context.session_id); 1615 + return psp_ta_invoke(psp, ta_cmd_id, psp->hdcp_context.context.session_id); 1688 1616 } 1689 1617 1690 1618 static int psp_hdcp_terminate(struct psp_context *psp) ··· 1697 1625 if (amdgpu_sriov_vf(psp->adev)) 1698 1626 return 0; 1699 1627 1700 - if (!psp->hdcp_context.hdcp_initialized) { 1701 - if (psp->hdcp_context.hdcp_shared_buf) 1628 + if (!psp->hdcp_context.context.initialized) { 1629 + if (psp->hdcp_context.context.mem_context.shared_buf) 1702 1630 goto out; 1703 1631 else 1704 1632 return 0; ··· 1708 1636 if (ret) 1709 1637 return ret; 1710 1638 1711 - psp->hdcp_context.hdcp_initialized = false; 1639 + psp->hdcp_context.context.initialized = false; 1712 1640 1713 1641 out: 1714 1642 /* free hdcp shared memory */ 1715 - amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo, 1716 - &psp->hdcp_context.hdcp_shared_mc_addr, 1717 - &psp->hdcp_context.hdcp_shared_buf); 1643 + amdgpu_bo_free_kernel(&psp->hdcp_context.context.mem_context.shared_bo, 1644 + &psp->hdcp_context.context.mem_context.shared_mc_addr, 1645 + &psp->hdcp_context.context.mem_context.shared_buf); 1718 1646 1719 1647 return 0; 1720 1648 } ··· 1731 1659 */ 1732 1660 ret = amdgpu_bo_create_kernel(psp->adev, PSP_DTM_SHARED_MEM_SIZE, 1733 1661 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, 1734 - &psp->dtm_context.dtm_shared_bo, 1735 - &psp->dtm_context.dtm_shared_mc_addr, 1736 - &psp->dtm_context.dtm_shared_buf); 1662 + &psp->dtm_context.context.mem_context.shared_bo, 1663 + &psp->dtm_context.context.mem_context.shared_mc_addr, 1664 + &psp->dtm_context.context.mem_context.shared_buf); 1737 1665 1738 1666 return ret; 1739 1667 } ··· 1749 1677 if (amdgpu_sriov_vf(psp->adev)) 1750 1678 return 0; 1751 1679 1752 - psp_copy_fw(psp, psp->ta_dtm_start_addr, psp->ta_dtm_ucode_size); 1680 + psp_copy_fw(psp, psp->dtm.start_addr, psp->dtm.size_bytes); 1753 1681 1754 1682 cmd = acquire_psp_cmd_buf(psp); 1755 1683 1756 1684 psp_prep_ta_load_cmd_buf(cmd, 1757 1685 psp->fw_pri_mc_addr, 1758 - psp->ta_dtm_ucode_size, 1759 - psp->dtm_context.dtm_shared_mc_addr, 1686 + psp->dtm.size_bytes, 1687 + psp->dtm_context.context.mem_context.shared_mc_addr, 1760 1688 PSP_DTM_SHARED_MEM_SIZE); 1761 1689 1762 1690 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 1763 1691 1764 1692 if (!ret) { 1765 - psp->dtm_context.dtm_initialized = true; 1766 - psp->dtm_context.session_id = cmd->resp.session_id; 1693 + psp->dtm_context.context.initialized = true; 1694 + psp->dtm_context.context.session_id = cmd->resp.session_id; 1767 1695 mutex_init(&psp->dtm_context.mutex); 1768 1696 } 1769 1697 ··· 1782 1710 if (amdgpu_sriov_vf(psp->adev)) 1783 1711 return 0; 1784 1712 1785 - if (!psp->adev->psp.ta_dtm_ucode_size || 1786 - !psp->adev->psp.ta_dtm_start_addr) { 1713 + if (!psp->dtm.size_bytes || 1714 + !psp->dtm.start_addr) { 1787 1715 dev_info(psp->adev->dev, "DTM: optional dtm ta ucode is not available\n"); 1788 1716 return 0; 1789 1717 } 1790 1718 1791 - if (!psp->dtm_context.dtm_initialized) { 1719 + if (!psp->dtm_context.context.initialized) { 1792 1720 ret = psp_dtm_init_shared_buf(psp); 1793 1721 if (ret) 1794 1722 return ret; ··· 1814 1742 1815 1743 cmd = acquire_psp_cmd_buf(psp); 1816 1744 1817 - psp_prep_ta_unload_cmd_buf(cmd, psp->dtm_context.session_id); 1745 + psp_prep_ta_unload_cmd_buf(cmd, psp->dtm_context.context.session_id); 1818 1746 1819 1747 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 1820 1748 ··· 1831 1759 if (amdgpu_sriov_vf(psp->adev)) 1832 1760 return 0; 1833 1761 1834 - return psp_ta_invoke(psp, ta_cmd_id, psp->dtm_context.session_id); 1762 + return psp_ta_invoke(psp, ta_cmd_id, psp->dtm_context.context.session_id); 1835 1763 } 1836 1764 1837 1765 static int psp_dtm_terminate(struct psp_context *psp) ··· 1844 1772 if (amdgpu_sriov_vf(psp->adev)) 1845 1773 return 0; 1846 1774 1847 - if (!psp->dtm_context.dtm_initialized) { 1848 - if (psp->dtm_context.dtm_shared_buf) 1775 + if (!psp->dtm_context.context.initialized) { 1776 + if (psp->dtm_context.context.mem_context.shared_buf) 1849 1777 goto out; 1850 1778 else 1851 1779 return 0; ··· 1855 1783 if (ret) 1856 1784 return ret; 1857 1785 1858 - psp->dtm_context.dtm_initialized = false; 1786 + psp->dtm_context.context.initialized = false; 1859 1787 1860 1788 out: 1861 1789 /* free hdcp shared memory */ 1862 - amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo, 1863 - &psp->dtm_context.dtm_shared_mc_addr, 1864 - &psp->dtm_context.dtm_shared_buf); 1790 + amdgpu_bo_free_kernel(&psp->dtm_context.context.mem_context.shared_bo, 1791 + &psp->dtm_context.context.mem_context.shared_mc_addr, 1792 + &psp->dtm_context.context.mem_context.shared_buf); 1865 1793 1866 1794 return 0; 1867 1795 } ··· 1878 1806 */ 1879 1807 ret = amdgpu_bo_create_kernel(psp->adev, PSP_RAP_SHARED_MEM_SIZE, 1880 1808 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, 1881 - &psp->rap_context.rap_shared_bo, 1882 - &psp->rap_context.rap_shared_mc_addr, 1883 - &psp->rap_context.rap_shared_buf); 1809 + &psp->rap_context.context.mem_context.shared_bo, 1810 + &psp->rap_context.context.mem_context.shared_mc_addr, 1811 + &psp->rap_context.context.mem_context.shared_buf); 1884 1812 1885 1813 return ret; 1886 1814 } ··· 1890 1818 int ret; 1891 1819 struct psp_gfx_cmd_resp *cmd; 1892 1820 1893 - psp_copy_fw(psp, psp->ta_rap_start_addr, psp->ta_rap_ucode_size); 1821 + psp_copy_fw(psp, psp->rap.start_addr, psp->rap.size_bytes); 1894 1822 1895 1823 cmd = acquire_psp_cmd_buf(psp); 1896 1824 1897 1825 psp_prep_ta_load_cmd_buf(cmd, 1898 1826 psp->fw_pri_mc_addr, 1899 - psp->ta_rap_ucode_size, 1900 - psp->rap_context.rap_shared_mc_addr, 1827 + psp->rap.size_bytes, 1828 + psp->rap_context.context.mem_context.shared_mc_addr, 1901 1829 PSP_RAP_SHARED_MEM_SIZE); 1902 1830 1903 1831 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 1904 1832 1905 1833 if (!ret) { 1906 - psp->rap_context.rap_initialized = true; 1907 - psp->rap_context.session_id = cmd->resp.session_id; 1834 + psp->rap_context.context.initialized = true; 1835 + psp->rap_context.context.session_id = cmd->resp.session_id; 1908 1836 mutex_init(&psp->rap_context.mutex); 1909 1837 } 1910 1838 ··· 1918 1846 int ret; 1919 1847 struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); 1920 1848 1921 - psp_prep_ta_unload_cmd_buf(cmd, psp->rap_context.session_id); 1849 + psp_prep_ta_unload_cmd_buf(cmd, psp->rap_context.context.session_id); 1922 1850 1923 1851 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 1924 1852 ··· 1938 1866 if (amdgpu_sriov_vf(psp->adev)) 1939 1867 return 0; 1940 1868 1941 - if (!psp->adev->psp.ta_rap_ucode_size || 1942 - !psp->adev->psp.ta_rap_start_addr) { 1869 + if (!psp->rap.size_bytes || 1870 + !psp->rap.start_addr) { 1943 1871 dev_info(psp->adev->dev, "RAP: optional rap ta ucode is not available\n"); 1944 1872 return 0; 1945 1873 } 1946 1874 1947 - if (!psp->rap_context.rap_initialized) { 1875 + if (!psp->rap_context.context.initialized) { 1948 1876 ret = psp_rap_init_shared_buf(psp); 1949 1877 if (ret) 1950 1878 return ret; ··· 1958 1886 if (ret || status != TA_RAP_STATUS__SUCCESS) { 1959 1887 psp_rap_unload(psp); 1960 1888 1961 - amdgpu_bo_free_kernel(&psp->rap_context.rap_shared_bo, 1962 - &psp->rap_context.rap_shared_mc_addr, 1963 - &psp->rap_context.rap_shared_buf); 1889 + amdgpu_bo_free_kernel(&psp->rap_context.context.mem_context.shared_bo, 1890 + &psp->rap_context.context.mem_context.shared_mc_addr, 1891 + &psp->rap_context.context.mem_context.shared_buf); 1964 1892 1965 - psp->rap_context.rap_initialized = false; 1893 + psp->rap_context.context.initialized = false; 1966 1894 1967 1895 dev_warn(psp->adev->dev, "RAP TA initialize fail (%d) status %d.\n", 1968 1896 ret, status); ··· 1977 1905 { 1978 1906 int ret; 1979 1907 1980 - if (!psp->rap_context.rap_initialized) 1908 + if (!psp->rap_context.context.initialized) 1981 1909 return 0; 1982 1910 1983 1911 ret = psp_rap_unload(psp); 1984 1912 1985 - psp->rap_context.rap_initialized = false; 1913 + psp->rap_context.context.initialized = false; 1986 1914 1987 1915 /* free rap shared memory */ 1988 - amdgpu_bo_free_kernel(&psp->rap_context.rap_shared_bo, 1989 - &psp->rap_context.rap_shared_mc_addr, 1990 - &psp->rap_context.rap_shared_buf); 1916 + amdgpu_bo_free_kernel(&psp->rap_context.context.mem_context.shared_bo, 1917 + &psp->rap_context.context.mem_context.shared_mc_addr, 1918 + &psp->rap_context.context.mem_context.shared_buf); 1991 1919 1992 1920 return ret; 1993 1921 } ··· 1997 1925 struct ta_rap_shared_memory *rap_cmd; 1998 1926 int ret = 0; 1999 1927 2000 - if (!psp->rap_context.rap_initialized) 1928 + if (!psp->rap_context.context.initialized) 2001 1929 return 0; 2002 1930 2003 1931 if (ta_cmd_id != TA_CMD_RAP__INITIALIZE && ··· 2007 1935 mutex_lock(&psp->rap_context.mutex); 2008 1936 2009 1937 rap_cmd = (struct ta_rap_shared_memory *) 2010 - psp->rap_context.rap_shared_buf; 1938 + psp->rap_context.context.mem_context.shared_buf; 2011 1939 memset(rap_cmd, 0, sizeof(struct ta_rap_shared_memory)); 2012 1940 2013 1941 rap_cmd->cmd_id = ta_cmd_id; 2014 1942 rap_cmd->validation_method_id = METHOD_A; 2015 1943 2016 - ret = psp_ta_invoke(psp, rap_cmd->cmd_id, psp->rap_context.session_id); 1944 + ret = psp_ta_invoke(psp, rap_cmd->cmd_id, psp->rap_context.context.session_id); 2017 1945 if (ret) 2018 1946 goto out_unlock; 2019 1947 ··· 2038 1966 */ 2039 1967 ret = amdgpu_bo_create_kernel(psp->adev, PSP_SECUREDISPLAY_SHARED_MEM_SIZE, 2040 1968 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, 2041 - &psp->securedisplay_context.securedisplay_shared_bo, 2042 - &psp->securedisplay_context.securedisplay_shared_mc_addr, 2043 - &psp->securedisplay_context.securedisplay_shared_buf); 1969 + &psp->securedisplay_context.context.mem_context.shared_bo, 1970 + &psp->securedisplay_context.context.mem_context.shared_mc_addr, 1971 + &psp->securedisplay_context.context.mem_context.shared_buf); 2044 1972 2045 1973 return ret; 2046 1974 } ··· 2051 1979 struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); 2052 1980 2053 1981 memset(psp->fw_pri_buf, 0, PSP_1_MEG); 2054 - memcpy(psp->fw_pri_buf, psp->ta_securedisplay_start_addr, psp->ta_securedisplay_ucode_size); 1982 + memcpy(psp->fw_pri_buf, psp->securedisplay.start_addr, psp->securedisplay.size_bytes); 2055 1983 2056 1984 psp_prep_ta_load_cmd_buf(cmd, 2057 1985 psp->fw_pri_mc_addr, 2058 - psp->ta_securedisplay_ucode_size, 2059 - psp->securedisplay_context.securedisplay_shared_mc_addr, 1986 + psp->securedisplay.size_bytes, 1987 + psp->securedisplay_context.context.mem_context.shared_mc_addr, 2060 1988 PSP_SECUREDISPLAY_SHARED_MEM_SIZE); 2061 1989 2062 1990 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 2063 1991 2064 1992 if (!ret) { 2065 - psp->securedisplay_context.securedisplay_initialized = true; 2066 - psp->securedisplay_context.session_id = cmd->resp.session_id; 1993 + psp->securedisplay_context.context.initialized = true; 1994 + psp->securedisplay_context.context.session_id = cmd->resp.session_id; 2067 1995 mutex_init(&psp->securedisplay_context.mutex); 2068 1996 } 2069 1997 ··· 2077 2005 int ret; 2078 2006 struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); 2079 2007 2080 - psp_prep_ta_unload_cmd_buf(cmd, psp->securedisplay_context.session_id); 2008 + psp_prep_ta_unload_cmd_buf(cmd, psp->securedisplay_context.context.session_id); 2081 2009 2082 2010 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 2083 2011 ··· 2097 2025 if (amdgpu_sriov_vf(psp->adev)) 2098 2026 return 0; 2099 2027 2100 - if (!psp->adev->psp.ta_securedisplay_ucode_size || 2101 - !psp->adev->psp.ta_securedisplay_start_addr) { 2028 + if (!psp->securedisplay.size_bytes || 2029 + !psp->securedisplay.start_addr) { 2102 2030 dev_info(psp->adev->dev, "SECUREDISPLAY: securedisplay ta ucode is not available\n"); 2103 2031 return 0; 2104 2032 } 2105 2033 2106 - if (!psp->securedisplay_context.securedisplay_initialized) { 2034 + if (!psp->securedisplay_context.context.initialized) { 2107 2035 ret = psp_securedisplay_init_shared_buf(psp); 2108 2036 if (ret) 2109 2037 return ret; ··· 2120 2048 if (ret) { 2121 2049 psp_securedisplay_unload(psp); 2122 2050 2123 - amdgpu_bo_free_kernel(&psp->securedisplay_context.securedisplay_shared_bo, 2124 - &psp->securedisplay_context.securedisplay_shared_mc_addr, 2125 - &psp->securedisplay_context.securedisplay_shared_buf); 2051 + amdgpu_bo_free_kernel(&psp->securedisplay_context.context.mem_context.shared_bo, 2052 + &psp->securedisplay_context.context.mem_context.shared_mc_addr, 2053 + &psp->securedisplay_context.context.mem_context.shared_buf); 2126 2054 2127 - psp->securedisplay_context.securedisplay_initialized = false; 2055 + psp->securedisplay_context.context.initialized = false; 2128 2056 2129 2057 dev_err(psp->adev->dev, "SECUREDISPLAY TA initialize fail.\n"); 2130 2058 return -EINVAL; ··· 2149 2077 if (amdgpu_sriov_vf(psp->adev)) 2150 2078 return 0; 2151 2079 2152 - if (!psp->securedisplay_context.securedisplay_initialized) 2080 + if (!psp->securedisplay_context.context.initialized) 2153 2081 return 0; 2154 2082 2155 2083 ret = psp_securedisplay_unload(psp); 2156 2084 if (ret) 2157 2085 return ret; 2158 2086 2159 - psp->securedisplay_context.securedisplay_initialized = false; 2087 + psp->securedisplay_context.context.initialized = false; 2160 2088 2161 2089 /* free securedisplay shared memory */ 2162 - amdgpu_bo_free_kernel(&psp->securedisplay_context.securedisplay_shared_bo, 2163 - &psp->securedisplay_context.securedisplay_shared_mc_addr, 2164 - &psp->securedisplay_context.securedisplay_shared_buf); 2090 + amdgpu_bo_free_kernel(&psp->securedisplay_context.context.mem_context.shared_bo, 2091 + &psp->securedisplay_context.context.mem_context.shared_mc_addr, 2092 + &psp->securedisplay_context.context.mem_context.shared_buf); 2165 2093 2166 2094 return ret; 2167 2095 } ··· 2170 2098 { 2171 2099 int ret; 2172 2100 2173 - if (!psp->securedisplay_context.securedisplay_initialized) 2101 + if (!psp->securedisplay_context.context.initialized) 2174 2102 return -EINVAL; 2175 2103 2176 2104 if (ta_cmd_id != TA_SECUREDISPLAY_COMMAND__QUERY_TA && ··· 2179 2107 2180 2108 mutex_lock(&psp->securedisplay_context.mutex); 2181 2109 2182 - ret = psp_ta_invoke(psp, ta_cmd_id, psp->securedisplay_context.session_id); 2110 + ret = psp_ta_invoke(psp, ta_cmd_id, psp->securedisplay_context.context.session_id); 2183 2111 2184 2112 mutex_unlock(&psp->securedisplay_context.mutex); 2185 2113 ··· 2492 2420 struct amdgpu_device *adev = psp->adev; 2493 2421 struct amdgpu_firmware_info *ucode = 2494 2422 &adev->firmware.ucode[AMDGPU_UCODE_ID_SMC]; 2495 - struct amdgpu_ras *ras = psp->ras.ras; 2423 + struct amdgpu_ras *ras = psp->ras_context.ras; 2496 2424 2497 2425 if (!ucode->fw || amdgpu_sriov_vf(psp->adev)) 2498 2426 return 0; ··· 2697 2625 return ret; 2698 2626 } 2699 2627 2700 - if (psp->adev->psp.ta_fw) { 2628 + if (psp->ta_fw) { 2701 2629 ret = psp_ras_initialize(psp); 2702 2630 if (ret) 2703 2631 dev_err(psp->adev->dev, ··· 2769 2697 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 2770 2698 struct psp_context *psp = &adev->psp; 2771 2699 2772 - if (psp->adev->psp.ta_fw) { 2700 + if (psp->ta_fw) { 2773 2701 psp_ras_terminate(psp); 2774 2702 psp_securedisplay_terminate(psp); 2775 2703 psp_rap_terminate(psp); ··· 2799 2727 struct psp_context *psp = &adev->psp; 2800 2728 2801 2729 if (adev->gmc.xgmi.num_physical_nodes > 1 && 2802 - psp->xgmi_context.initialized == 1) { 2730 + psp->xgmi_context.context.initialized) { 2803 2731 ret = psp_xgmi_terminate(psp); 2804 2732 if (ret) { 2805 2733 DRM_ERROR("Failed to terminate xgmi ta\n"); ··· 2807 2735 } 2808 2736 } 2809 2737 2810 - if (psp->adev->psp.ta_fw) { 2738 + if (psp->ta_fw) { 2811 2739 ret = psp_ras_terminate(psp); 2812 2740 if (ret) { 2813 2741 DRM_ERROR("Failed to terminate ras ta\n"); ··· 2889 2817 } 2890 2818 2891 2819 if (adev->gmc.xgmi.num_physical_nodes > 1) { 2892 - ret = psp_xgmi_initialize(psp); 2820 + ret = psp_xgmi_initialize(psp, false, true); 2893 2821 /* Warning the XGMI seesion initialize failure 2894 2822 * Instead of stop driver initialization 2895 2823 */ ··· 2898 2826 "XGMI: Failed to initialize XGMI session\n"); 2899 2827 } 2900 2828 2901 - if (psp->adev->psp.ta_fw) { 2829 + if (psp->ta_fw) { 2902 2830 ret = psp_ras_initialize(psp); 2903 2831 if (ret) 2904 2832 dev_err(psp->adev->dev, ··· 3050 2978 goto out; 3051 2979 3052 2980 asd_hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.asd_fw->data; 3053 - adev->psp.asd_fw_version = le32_to_cpu(asd_hdr->header.ucode_version); 3054 - adev->psp.asd_feature_version = le32_to_cpu(asd_hdr->sos.fw_version); 3055 - adev->psp.asd_ucode_size = le32_to_cpu(asd_hdr->header.ucode_size_bytes); 3056 - adev->psp.asd_start_addr = (uint8_t *)asd_hdr + 2981 + adev->psp.asd.fw_version = le32_to_cpu(asd_hdr->header.ucode_version); 2982 + adev->psp.asd.feature_version = le32_to_cpu(asd_hdr->sos.fw_version); 2983 + adev->psp.asd.size_bytes = le32_to_cpu(asd_hdr->header.ucode_size_bytes); 2984 + adev->psp.asd.start_addr = (uint8_t *)asd_hdr + 3057 2985 le32_to_cpu(asd_hdr->header.ucode_array_offset_bytes); 3058 2986 return 0; 3059 2987 out: ··· 3195 3123 adev->psp.sos.size_bytes = le32_to_cpu(sos_hdr->sos.size_bytes); 3196 3124 adev->psp.sos.start_addr = ucode_array_start_addr + 3197 3125 le32_to_cpu(sos_hdr->sos.offset_bytes); 3126 + adev->psp.xgmi_context.supports_extended_data = false; 3198 3127 } else { 3199 3128 /* Load alternate PSP SOS FW */ 3200 3129 sos_hdr_v1_3 = (const struct psp_firmware_header_v1_3 *)adev->psp.sos_fw->data; ··· 3210 3137 adev->psp.sos.size_bytes = le32_to_cpu(sos_hdr_v1_3->sos_aux.size_bytes); 3211 3138 adev->psp.sos.start_addr = ucode_array_start_addr + 3212 3139 le32_to_cpu(sos_hdr_v1_3->sos_aux.offset_bytes); 3140 + adev->psp.xgmi_context.supports_extended_data = true; 3213 3141 } 3214 3142 3215 3143 if ((adev->psp.sys.size_bytes == 0) || (adev->psp.sos.size_bytes == 0)) { ··· 3340 3266 3341 3267 switch (desc->fw_type) { 3342 3268 case TA_FW_TYPE_PSP_ASD: 3343 - psp->asd_fw_version = le32_to_cpu(desc->fw_version); 3344 - psp->asd_feature_version = le32_to_cpu(desc->fw_version); 3345 - psp->asd_ucode_size = le32_to_cpu(desc->size_bytes); 3346 - psp->asd_start_addr = ucode_start_addr; 3269 + psp->asd.fw_version = le32_to_cpu(desc->fw_version); 3270 + psp->asd.feature_version = le32_to_cpu(desc->fw_version); 3271 + psp->asd.size_bytes = le32_to_cpu(desc->size_bytes); 3272 + psp->asd.start_addr = ucode_start_addr; 3347 3273 break; 3348 3274 case TA_FW_TYPE_PSP_XGMI: 3349 - psp->ta_xgmi_ucode_version = le32_to_cpu(desc->fw_version); 3350 - psp->ta_xgmi_ucode_size = le32_to_cpu(desc->size_bytes); 3351 - psp->ta_xgmi_start_addr = ucode_start_addr; 3275 + psp->xgmi.feature_version = le32_to_cpu(desc->fw_version); 3276 + psp->xgmi.size_bytes = le32_to_cpu(desc->size_bytes); 3277 + psp->xgmi.start_addr = ucode_start_addr; 3352 3278 break; 3353 3279 case TA_FW_TYPE_PSP_RAS: 3354 - psp->ta_ras_ucode_version = le32_to_cpu(desc->fw_version); 3355 - psp->ta_ras_ucode_size = le32_to_cpu(desc->size_bytes); 3356 - psp->ta_ras_start_addr = ucode_start_addr; 3280 + psp->ras.feature_version = le32_to_cpu(desc->fw_version); 3281 + psp->ras.size_bytes = le32_to_cpu(desc->size_bytes); 3282 + psp->ras.start_addr = ucode_start_addr; 3357 3283 break; 3358 3284 case TA_FW_TYPE_PSP_HDCP: 3359 - psp->ta_hdcp_ucode_version = le32_to_cpu(desc->fw_version); 3360 - psp->ta_hdcp_ucode_size = le32_to_cpu(desc->size_bytes); 3361 - psp->ta_hdcp_start_addr = ucode_start_addr; 3285 + psp->hdcp.feature_version = le32_to_cpu(desc->fw_version); 3286 + psp->hdcp.size_bytes = le32_to_cpu(desc->size_bytes); 3287 + psp->hdcp.start_addr = ucode_start_addr; 3362 3288 break; 3363 3289 case TA_FW_TYPE_PSP_DTM: 3364 - psp->ta_dtm_ucode_version = le32_to_cpu(desc->fw_version); 3365 - psp->ta_dtm_ucode_size = le32_to_cpu(desc->size_bytes); 3366 - psp->ta_dtm_start_addr = ucode_start_addr; 3290 + psp->dtm.feature_version = le32_to_cpu(desc->fw_version); 3291 + psp->dtm.size_bytes = le32_to_cpu(desc->size_bytes); 3292 + psp->dtm.start_addr = ucode_start_addr; 3367 3293 break; 3368 3294 case TA_FW_TYPE_PSP_RAP: 3369 - psp->ta_rap_ucode_version = le32_to_cpu(desc->fw_version); 3370 - psp->ta_rap_ucode_size = le32_to_cpu(desc->size_bytes); 3371 - psp->ta_rap_start_addr = ucode_start_addr; 3295 + psp->rap.feature_version = le32_to_cpu(desc->fw_version); 3296 + psp->rap.size_bytes = le32_to_cpu(desc->size_bytes); 3297 + psp->rap.start_addr = ucode_start_addr; 3372 3298 break; 3373 3299 case TA_FW_TYPE_PSP_SECUREDISPLAY: 3374 - psp->ta_securedisplay_ucode_version = le32_to_cpu(desc->fw_version); 3375 - psp->ta_securedisplay_ucode_size = le32_to_cpu(desc->size_bytes); 3376 - psp->ta_securedisplay_start_addr = ucode_start_addr; 3300 + psp->securedisplay.feature_version = le32_to_cpu(desc->fw_version); 3301 + psp->securedisplay.size_bytes = le32_to_cpu(desc->size_bytes); 3302 + psp->securedisplay.start_addr = ucode_start_addr; 3377 3303 break; 3378 3304 default: 3379 3305 dev_warn(psp->adev->dev, "Unsupported TA type: %d\n", desc->fw_type);
+37 -82
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
··· 136 136 uint32_t session_id; 137 137 }; 138 138 139 + struct ta_mem_context { 140 + struct amdgpu_bo *shared_bo; 141 + uint64_t shared_mc_addr; 142 + void *shared_buf; 143 + }; 144 + 145 + struct ta_context { 146 + bool initialized; 147 + uint32_t session_id; 148 + struct ta_mem_context mem_context; 149 + }; 150 + 151 + struct ta_cp_context { 152 + struct ta_context context; 153 + struct mutex mutex; 154 + }; 155 + 139 156 struct psp_xgmi_context { 140 - uint8_t initialized; 141 - uint32_t session_id; 142 - struct amdgpu_bo *xgmi_shared_bo; 143 - uint64_t xgmi_shared_mc_addr; 144 - void *xgmi_shared_buf; 157 + struct ta_context context; 145 158 struct psp_xgmi_topology_info top_info; 159 + bool supports_extended_data; 146 160 }; 147 161 148 162 struct psp_ras_context { 149 - /*ras fw*/ 150 - bool ras_initialized; 151 - uint32_t session_id; 152 - struct amdgpu_bo *ras_shared_bo; 153 - uint64_t ras_shared_mc_addr; 154 - void *ras_shared_buf; 155 - struct amdgpu_ras *ras; 156 - }; 157 - 158 - struct psp_hdcp_context { 159 - bool hdcp_initialized; 160 - uint32_t session_id; 161 - struct amdgpu_bo *hdcp_shared_bo; 162 - uint64_t hdcp_shared_mc_addr; 163 - void *hdcp_shared_buf; 164 - struct mutex mutex; 165 - }; 166 - 167 - struct psp_dtm_context { 168 - bool dtm_initialized; 169 - uint32_t session_id; 170 - struct amdgpu_bo *dtm_shared_bo; 171 - uint64_t dtm_shared_mc_addr; 172 - void *dtm_shared_buf; 173 - struct mutex mutex; 174 - }; 175 - 176 - struct psp_rap_context { 177 - bool rap_initialized; 178 - uint32_t session_id; 179 - struct amdgpu_bo *rap_shared_bo; 180 - uint64_t rap_shared_mc_addr; 181 - void *rap_shared_buf; 182 - struct mutex mutex; 183 - }; 184 - 185 - struct psp_securedisplay_context { 186 - bool securedisplay_initialized; 187 - uint32_t session_id; 188 - struct amdgpu_bo *securedisplay_shared_bo; 189 - uint64_t securedisplay_shared_mc_addr; 190 - void *securedisplay_shared_buf; 191 - struct mutex mutex; 163 + struct ta_context context; 164 + struct amdgpu_ras *ras; 192 165 }; 193 166 194 167 #define MEM_TRAIN_SYSTEM_SIGNATURE 0x54534942 ··· 300 327 uint64_t tmr_mc_addr; 301 328 302 329 /* asd firmware */ 303 - const struct firmware *asd_fw; 304 - uint32_t asd_fw_version; 305 - uint32_t asd_feature_version; 306 - uint32_t asd_ucode_size; 307 - uint8_t *asd_start_addr; 330 + const struct firmware *asd_fw; 331 + struct psp_bin_desc asd; 308 332 309 333 /* toc firmware */ 310 334 const struct firmware *toc_fw; ··· 326 356 /* xgmi ta firmware and buffer */ 327 357 const struct firmware *ta_fw; 328 358 uint32_t ta_fw_version; 329 - uint32_t ta_xgmi_ucode_version; 330 - uint32_t ta_xgmi_ucode_size; 331 - uint8_t *ta_xgmi_start_addr; 332 - uint32_t ta_ras_ucode_version; 333 - uint32_t ta_ras_ucode_size; 334 - uint8_t *ta_ras_start_addr; 335 - 336 - uint32_t ta_hdcp_ucode_version; 337 - uint32_t ta_hdcp_ucode_size; 338 - uint8_t *ta_hdcp_start_addr; 339 - 340 - uint32_t ta_dtm_ucode_version; 341 - uint32_t ta_dtm_ucode_size; 342 - uint8_t *ta_dtm_start_addr; 343 - 344 - uint32_t ta_rap_ucode_version; 345 - uint32_t ta_rap_ucode_size; 346 - uint8_t *ta_rap_start_addr; 347 - 348 - uint32_t ta_securedisplay_ucode_version; 349 - uint32_t ta_securedisplay_ucode_size; 350 - uint8_t *ta_securedisplay_start_addr; 359 + struct psp_bin_desc xgmi; 360 + struct psp_bin_desc ras; 361 + struct psp_bin_desc hdcp; 362 + struct psp_bin_desc dtm; 363 + struct psp_bin_desc rap; 364 + struct psp_bin_desc securedisplay; 351 365 352 366 struct psp_asd_context asd_context; 353 367 struct psp_xgmi_context xgmi_context; 354 - struct psp_ras_context ras; 355 - struct psp_hdcp_context hdcp_context; 356 - struct psp_dtm_context dtm_context; 357 - struct psp_rap_context rap_context; 358 - struct psp_securedisplay_context securedisplay_context; 368 + struct psp_ras_context ras_context; 369 + struct ta_cp_context hdcp_context; 370 + struct ta_cp_context dtm_context; 371 + struct ta_cp_context rap_context; 372 + struct ta_cp_context securedisplay_context; 359 373 struct mutex mutex; 360 374 struct psp_memory_training_context mem_train_ctx; 361 375 ··· 406 452 int psp_update_vcn_sram(struct amdgpu_device *adev, int inst_idx, 407 453 uint64_t cmd_gpu_addr, int cmd_size); 408 454 409 - int psp_xgmi_initialize(struct psp_context *psp); 455 + int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool load_ta); 410 456 int psp_xgmi_terminate(struct psp_context *psp); 411 457 int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id); 412 458 int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id); 413 459 int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id); 414 460 int psp_xgmi_get_topology_info(struct psp_context *psp, 415 461 int number_devices, 416 - struct psp_xgmi_topology_info *topology); 462 + struct psp_xgmi_topology_info *topology, 463 + bool get_extended_data); 417 464 int psp_xgmi_set_topology_info(struct psp_context *psp, 418 465 int number_devices, 419 466 struct psp_xgmi_topology_info *topology);
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c
··· 76 76 dev_info(adev->dev, "RAP L0 validate test success.\n"); 77 77 } else { 78 78 rap_shared_mem = (struct ta_rap_shared_memory *) 79 - adev->psp.rap_context.rap_shared_buf; 79 + adev->psp.rap_context.context.mem_context.shared_buf; 80 80 rap_cmd_output = &(rap_shared_mem->rap_out_message.output); 81 81 82 82 dev_info(adev->dev, "RAP test failed, the output is:\n"); ··· 119 119 #if defined(CONFIG_DEBUG_FS) 120 120 struct drm_minor *minor = adev_to_drm(adev)->primary; 121 121 122 - if (!adev->psp.rap_context.rap_initialized) 122 + if (!adev->psp.rap_context.context.initialized) 123 123 return; 124 124 125 125 debugfs_create_file("rap_test", S_IWUSR, minor->debugfs_root,
+2 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
··· 64 64 }; 65 65 66 66 #define ras_err_str(i) (ras_error_string[ffs(i)]) 67 - #define ras_block_str(i) (ras_block_string[i]) 68 67 69 68 #define RAS_DEFAULT_FLAGS (AMDGPU_RAS_FLAG_INIT_BY_VBIOS) 70 69 ··· 529 530 if (obj && (--obj->use == 0)) 530 531 list_del(&obj->node); 531 532 if (obj && (obj->use < 0)) 532 - DRM_ERROR("RAS ERROR: Unbalance obj(%s) use\n", obj->head.name); 533 + DRM_ERROR("RAS ERROR: Unbalance obj(%s) use\n", ras_block_str(obj->head.block)); 533 534 } 534 535 535 536 /* make one obj and return it. */ ··· 792 793 .type = default_ras_type, 793 794 .sub_block_index = 0, 794 795 }; 795 - strcpy(head.name, ras_block_str(i)); 796 796 if (bypass) { 797 797 /* 798 798 * bypass psp. vbios enable ras for us. ··· 1864 1866 static int amdgpu_ras_load_bad_pages(struct amdgpu_device *adev) 1865 1867 { 1866 1868 struct amdgpu_ras_eeprom_control *control = 1867 - &adev->psp.ras.ras->eeprom_control; 1869 + &adev->psp.ras_context.ras->eeprom_control; 1868 1870 struct eeprom_table_record *bps; 1869 1871 int ret; 1870 1872
+5 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
··· 53 53 AMDGPU_RAS_BLOCK__LAST 54 54 }; 55 55 56 + extern const char *ras_block_string[]; 57 + 58 + #define ras_block_str(i) (ras_block_string[i]) 56 59 #define AMDGPU_RAS_BLOCK_COUNT AMDGPU_RAS_BLOCK__LAST 57 60 #define AMDGPU_RAS_BLOCK_MASK ((1ULL << AMDGPU_RAS_BLOCK_COUNT) - 1) 58 61 ··· 309 306 enum amdgpu_ras_block block; 310 307 enum amdgpu_ras_error_type type; 311 308 uint32_t sub_block_index; 312 - /* block name */ 313 - char name[32]; 314 309 }; 315 310 316 311 struct amdgpu_ras { ··· 471 470 * 8: feature disable 472 471 */ 473 472 474 - #define amdgpu_ras_get_context(adev) ((adev)->psp.ras.ras) 475 - #define amdgpu_ras_set_context(adev, ras_con) ((adev)->psp.ras.ras = (ras_con)) 473 + #define amdgpu_ras_get_context(adev) ((adev)->psp.ras_context.ras) 474 + #define amdgpu_ras_set_context(adev, ras_con) ((adev)->psp.ras_context.ras = (ras_con)) 476 475 477 476 /* check if ras is supported on block, say, sdma, gfx */ 478 477 static inline int amdgpu_ras_is_supported(struct amdgpu_device *adev,
+4 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
··· 48 48 #define AMDGPU_FENCE_FLAG_INT (1 << 1) 49 49 #define AMDGPU_FENCE_FLAG_TC_WB_ONLY (1 << 2) 50 50 51 + /* fence flag bit to indicate the face is embedded in job*/ 52 + #define AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT (DMA_FENCE_FLAG_USER_BITS + 1) 53 + 51 54 #define to_amdgpu_ring(s) container_of((s), struct amdgpu_ring, sched) 52 55 53 56 #define AMDGPU_IB_POOL_SIZE (1024 * 1024) ··· 121 118 void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev); 122 119 int amdgpu_fence_driver_sw_init(struct amdgpu_device *adev); 123 120 void amdgpu_fence_driver_sw_fini(struct amdgpu_device *adev); 124 - int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **fence, 121 + int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **fence, struct amdgpu_job *job, 125 122 unsigned flags); 126 123 int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s, 127 124 uint32_t timeout);
-1
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
··· 105 105 adev->sdma.ras_if->block = AMDGPU_RAS_BLOCK__SDMA; 106 106 adev->sdma.ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE; 107 107 adev->sdma.ras_if->sub_block_index = 0; 108 - strcpy(adev->sdma.ras_if->name, "sdma"); 109 108 } 110 109 fs_info.head = ih_info->head = *adev->sdma.ras_if; 111 110
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c
··· 80 80 void psp_prep_securedisplay_cmd_buf(struct psp_context *psp, struct securedisplay_cmd **cmd, 81 81 enum ta_securedisplay_command command_id) 82 82 { 83 - *cmd = (struct securedisplay_cmd *)psp->securedisplay_context.securedisplay_shared_buf; 83 + *cmd = (struct securedisplay_cmd *)psp->securedisplay_context.context.mem_context.shared_buf; 84 84 memset(*cmd, 0, sizeof(struct securedisplay_cmd)); 85 85 (*cmd)->status = TA_SECUREDISPLAY_STATUS__GENERIC_FAILURE; 86 86 (*cmd)->cmd_id = command_id; ··· 170 170 { 171 171 #if defined(CONFIG_DEBUG_FS) 172 172 173 - if (!adev->psp.securedisplay_context.securedisplay_initialized) 173 + if (!adev->psp.securedisplay_context.context.initialized) 174 174 return; 175 175 176 176 debugfs_create_file("securedisplay_test", S_IWUSR, adev_to_drm(adev)->primary->debugfs_root,
+3 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
··· 525 525 FW_VERSION_ATTR(mec_fw_version, 0444, gfx.mec_fw_version); 526 526 FW_VERSION_ATTR(mec2_fw_version, 0444, gfx.mec2_fw_version); 527 527 FW_VERSION_ATTR(sos_fw_version, 0444, psp.sos.fw_version); 528 - FW_VERSION_ATTR(asd_fw_version, 0444, psp.asd_fw_version); 529 - FW_VERSION_ATTR(ta_ras_fw_version, 0444, psp.ta_ras_ucode_version); 530 - FW_VERSION_ATTR(ta_xgmi_fw_version, 0444, psp.ta_xgmi_ucode_version); 528 + FW_VERSION_ATTR(asd_fw_version, 0444, psp.asd.fw_version); 529 + FW_VERSION_ATTR(ta_ras_fw_version, 0444, psp.ras.feature_version); 530 + FW_VERSION_ATTR(ta_xgmi_fw_version, 0444, psp.xgmi.feature_version); 531 531 FW_VERSION_ATTR(smc_fw_version, 0444, pm.fw_version); 532 532 FW_VERSION_ATTR(sdma_fw_version, 0444, sdma.instance[0].fw_version); 533 533 FW_VERSION_ATTR(sdma2_fw_version, 0444, sdma.instance[1].fw_version);
+5 -15
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
··· 136 136 /* version_major=1, version_minor=0 */ 137 137 struct ta_firmware_header_v1_0 { 138 138 struct common_firmware_header header; 139 - uint32_t ta_xgmi_ucode_version; 140 - uint32_t ta_xgmi_offset_bytes; 141 - uint32_t ta_xgmi_size_bytes; 142 - uint32_t ta_ras_ucode_version; 143 - uint32_t ta_ras_offset_bytes; 144 - uint32_t ta_ras_size_bytes; 145 - uint32_t ta_hdcp_ucode_version; 146 - uint32_t ta_hdcp_offset_bytes; 147 - uint32_t ta_hdcp_size_bytes; 148 - uint32_t ta_dtm_ucode_version; 149 - uint32_t ta_dtm_offset_bytes; 150 - uint32_t ta_dtm_size_bytes; 151 - uint32_t ta_securedisplay_ucode_version; 152 - uint32_t ta_securedisplay_offset_bytes; 153 - uint32_t ta_securedisplay_size_bytes; 139 + struct psp_fw_legacy_bin_desc xgmi; 140 + struct psp_fw_legacy_bin_desc ras; 141 + struct psp_fw_legacy_bin_desc hdcp; 142 + struct psp_fw_legacy_bin_desc dtm; 143 + struct psp_fw_legacy_bin_desc securedisplay; 154 144 }; 155 145 156 146 enum ta_fw_type {
-1
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c
··· 41 41 adev->umc.ras_if->block = AMDGPU_RAS_BLOCK__UMC; 42 42 adev->umc.ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE; 43 43 adev->umc.ras_if->sub_block_index = 0; 44 - strcpy(adev->umc.ras_if->name, "umc"); 45 44 } 46 45 ih_info.head = fs_info.head = *adev->umc.ras_if; 47 46
+3 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
··· 532 532 POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_MEC, adev->gfx.mec_fw_version); 533 533 POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_MEC2, adev->gfx.mec2_fw_version); 534 534 POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_SOS, adev->psp.sos.fw_version); 535 - POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_ASD, adev->psp.asd_fw_version); 536 - POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_TA_RAS, adev->psp.ta_ras_ucode_version); 537 - POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_TA_XGMI, adev->psp.ta_xgmi_ucode_version); 535 + POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_ASD, adev->psp.asd.fw_version); 536 + POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_TA_RAS, adev->psp.ras.feature_version); 537 + POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_TA_XGMI, adev->psp.xgmi.feature_version); 538 538 POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_SMC, adev->pm.fw_version); 539 539 POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_SDMA, adev->sdma.instance[0].fw_version); 540 540 POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_SDMA2, adev->sdma.instance[1].fw_version);
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 1218 1218 amdgpu_gmc_emit_pasid_mapping(ring, job->vmid, job->pasid); 1219 1219 1220 1220 if (vm_flush_needed || pasid_mapping_needed) { 1221 - r = amdgpu_fence_emit(ring, &fence, 0); 1221 + r = amdgpu_fence_emit(ring, &fence, NULL, 0); 1222 1222 if (r) 1223 1223 return r; 1224 1224 }
+56 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
··· 498 498 return -EINVAL; 499 499 } 500 500 501 + /* 502 + * Devices that support extended data require the entire hive to initialize with 503 + * the shared memory buffer flag set. 504 + * 505 + * Hive locks and conditions apply - see amdgpu_xgmi_add_device 506 + */ 507 + static int amdgpu_xgmi_initialize_hive_get_data_partition(struct amdgpu_hive_info *hive, 508 + bool set_extended_data) 509 + { 510 + struct amdgpu_device *tmp_adev; 511 + int ret; 512 + 513 + list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { 514 + ret = psp_xgmi_initialize(&tmp_adev->psp, set_extended_data, false); 515 + if (ret) { 516 + dev_err(tmp_adev->dev, 517 + "XGMI: Failed to initialize xgmi session for data partition %i\n", 518 + set_extended_data); 519 + return ret; 520 + } 521 + 522 + } 523 + 524 + return 0; 525 + } 526 + 501 527 int amdgpu_xgmi_add_device(struct amdgpu_device *adev) 502 528 { 503 529 struct psp_xgmi_topology_info *top_info; ··· 538 512 539 513 if (!adev->gmc.xgmi.pending_reset && 540 514 amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_PSP)) { 541 - ret = psp_xgmi_initialize(&adev->psp); 515 + ret = psp_xgmi_initialize(&adev->psp, false, true); 542 516 if (ret) { 543 517 dev_err(adev->dev, 544 518 "XGMI: Failed to initialize xgmi session\n"); ··· 601 575 /* get latest topology info for each device from psp */ 602 576 list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { 603 577 ret = psp_xgmi_get_topology_info(&tmp_adev->psp, count, 604 - &tmp_adev->psp.xgmi_context.top_info); 578 + &tmp_adev->psp.xgmi_context.top_info, false); 605 579 if (ret) { 606 580 dev_err(tmp_adev->dev, 607 581 "XGMI: Get topology failure on device %llx, hive %llx, ret %d", ··· 610 584 /* To do : continue with some node failed or disable the whole hive */ 611 585 goto exit_unlock; 612 586 } 587 + } 588 + 589 + /* get topology again for hives that support extended data */ 590 + if (adev->psp.xgmi_context.supports_extended_data) { 591 + 592 + /* initialize the hive to get extended data. */ 593 + ret = amdgpu_xgmi_initialize_hive_get_data_partition(hive, true); 594 + if (ret) 595 + goto exit_unlock; 596 + 597 + /* get the extended data. */ 598 + list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { 599 + ret = psp_xgmi_get_topology_info(&tmp_adev->psp, count, 600 + &tmp_adev->psp.xgmi_context.top_info, true); 601 + if (ret) { 602 + dev_err(tmp_adev->dev, 603 + "XGMI: Get topology for extended data failure on device %llx, hive %llx, ret %d", 604 + tmp_adev->gmc.xgmi.node_id, 605 + tmp_adev->gmc.xgmi.hive_id, ret); 606 + goto exit_unlock; 607 + } 608 + } 609 + 610 + /* initialize the hive to get non-extended data for the next round. */ 611 + ret = amdgpu_xgmi_initialize_hive_get_data_partition(hive, false); 612 + if (ret) 613 + goto exit_unlock; 614 + 613 615 } 614 616 } 615 617 ··· 717 663 adev->gmc.xgmi.ras_if->block = AMDGPU_RAS_BLOCK__XGMI_WAFL; 718 664 adev->gmc.xgmi.ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE; 719 665 adev->gmc.xgmi.ras_if->sub_block_index = 0; 720 - strcpy(adev->gmc.xgmi.ras_if->name, "xgmi_wafl"); 721 666 } 722 667 ih_info.head = fs_info.head = *adev->gmc.xgmi.ras_if; 723 668 r = amdgpu_ras_late_init(adev, adev->gmc.xgmi.ras_if,
+3 -3
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c
··· 85 85 SOC15_REG_GOLDEN_VALUE(GC, 0, regTCI_CNTL_3, 0xff, 0x20), 86 86 }; 87 87 88 - /** 88 + /* 89 89 * This shader is used to clear VGPRS and LDS, and also write the input 90 90 * pattern into the write back buffer, which will be used by driver to 91 91 * check whether all SIMDs have been covered. ··· 206 206 { SOC15_REG_ENTRY(GC, 0, regCOMPUTE_STATIC_THREAD_MGMT_SE7), 0xffffffff }, 207 207 }; 208 208 209 - /** 209 + /* 210 210 * The below shaders are used to clear SGPRS, and also write the input 211 211 * pattern into the write back buffer. The first two dispatch should be 212 212 * scheduled simultaneously which make sure that all SGPRS could be ··· 302 302 { SOC15_REG_ENTRY(GC, 0, regCOMPUTE_STATIC_THREAD_MGMT_SE7), 0xffffffff }, 303 303 }; 304 304 305 - /** 305 + /* 306 306 * This shader is used to clear the uninitiated sgprs after the above 307 307 * two dispatches, because of hardware feature, dispath 0 couldn't clear 308 308 * top hole sgprs. Therefore need 4 waves per SIMD to cover these sgprs
+2 -3
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c
··· 75 75 max_physical_node_id = 7; 76 76 break; 77 77 case CHIP_ALDEBARAN: 78 - /* just using duplicates for Aldebaran support, revisit later */ 79 - max_num_physical_nodes = 8; 80 - max_physical_node_id = 7; 78 + max_num_physical_nodes = 16; 79 + max_physical_node_id = 15; 81 80 break; 82 81 default: 83 82 return -EINVAL;
+1 -3
drivers/gpu/drm/amd/amdgpu/mmsch_v1_0.h
··· 24 24 #ifndef __MMSCH_V1_0_H__ 25 25 #define __MMSCH_V1_0_H__ 26 26 27 - #define MMSCH_VERSION_MAJOR 1 28 - #define MMSCH_VERSION_MINOR 0 29 - #define MMSCH_VERSION (MMSCH_VERSION_MAJOR << 16 | MMSCH_VERSION_MINOR) 27 + #define MMSCH_VERSION 0x1 30 28 31 29 enum mmsch_v1_0_command_type { 32 30 MMSCH_COMMAND__DIRECT_REG_WRITE = 0,
+14 -4
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
··· 96 96 97 97 static int xgpu_nv_poll_msg(struct amdgpu_device *adev, enum idh_event event) 98 98 { 99 - int r, timeout = NV_MAILBOX_POLL_MSG_TIMEDOUT; 99 + int r; 100 + uint64_t timeout, now; 101 + 102 + now = (uint64_t)ktime_to_ms(ktime_get()); 103 + timeout = now + NV_MAILBOX_POLL_MSG_TIMEDOUT; 100 104 101 105 do { 102 106 r = xgpu_nv_mailbox_rcv_msg(adev, event); ··· 108 104 return 0; 109 105 110 106 msleep(10); 111 - timeout -= 10; 112 - } while (timeout > 1); 107 + now = (uint64_t)ktime_to_ms(ktime_get()); 108 + } while (timeout > now); 113 109 114 110 115 111 return -ETIME; ··· 153 149 static int xgpu_nv_send_access_requests(struct amdgpu_device *adev, 154 150 enum idh_request req) 155 151 { 156 - int r; 152 + int r, retry = 1; 157 153 enum idh_event event = -1; 158 154 155 + send_request: 159 156 xgpu_nv_mailbox_trans_msg(adev, req, 0, 0, 0); 160 157 161 158 switch (req) { ··· 175 170 if (event != -1) { 176 171 r = xgpu_nv_poll_msg(adev, event); 177 172 if (r) { 173 + if (retry++ < 2) 174 + goto send_request; 175 + 178 176 if (req != IDH_REQ_GPU_INIT_DATA) { 179 177 pr_err("Doesn't get msg:%d from pf, error=%d\n", event, r); 180 178 return r; ··· 286 278 287 279 amdgpu_virt_fini_data_exchange(adev); 288 280 atomic_set(&adev->in_gpu_reset, 1); 281 + 282 + xgpu_nv_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0); 289 283 290 284 do { 291 285 if (xgpu_nv_mailbox_peek_msg(adev) == IDH_FLR_NOTIFICATION_CMPL)
+2 -1
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.h
··· 37 37 IDH_REQ_GPU_RESET_ACCESS, 38 38 IDH_REQ_GPU_INIT_DATA, 39 39 40 - IDH_LOG_VF_ERROR = 200, 40 + IDH_LOG_VF_ERROR = 200, 41 + IDH_READY_TO_RESET = 201, 41 42 }; 42 43 43 44 enum idh_event {
+2 -2
drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c
··· 372 372 "errors detected in %s block, " 373 373 "no user action is needed.\n", 374 374 obj->err_data.ce_count, 375 - adev->nbio.ras_if->name); 375 + ras_block_str(adev->nbio.ras_if->block)); 376 376 377 377 if (err_data.ue_count) 378 378 dev_info(adev->dev, "%ld uncorrectable hardware " 379 379 "errors detected in %s block\n", 380 380 obj->err_data.ue_count, 381 - adev->nbio.ras_if->name); 381 + ras_block_str(adev->nbio.ras_if->block)); 382 382 } 383 383 384 384 dev_info(adev->dev, "RAS controller interrupt triggered "
+19 -19
drivers/gpu/drm/amd/amdgpu/psp_v10_0.c
··· 84 84 85 85 ta_hdr = (const struct ta_firmware_header_v1_0 *) 86 86 adev->psp.ta_fw->data; 87 - adev->psp.ta_hdcp_ucode_version = 88 - le32_to_cpu(ta_hdr->ta_hdcp_ucode_version); 89 - adev->psp.ta_hdcp_ucode_size = 90 - le32_to_cpu(ta_hdr->ta_hdcp_size_bytes); 91 - adev->psp.ta_hdcp_start_addr = 87 + adev->psp.hdcp.feature_version = 88 + le32_to_cpu(ta_hdr->hdcp.fw_version); 89 + adev->psp.hdcp.size_bytes = 90 + le32_to_cpu(ta_hdr->hdcp.size_bytes); 91 + adev->psp.hdcp.start_addr = 92 92 (uint8_t *)ta_hdr + 93 93 le32_to_cpu(ta_hdr->header.ucode_array_offset_bytes); 94 94 95 - adev->psp.ta_dtm_ucode_version = 96 - le32_to_cpu(ta_hdr->ta_dtm_ucode_version); 97 - adev->psp.ta_dtm_ucode_size = 98 - le32_to_cpu(ta_hdr->ta_dtm_size_bytes); 99 - adev->psp.ta_dtm_start_addr = 100 - (uint8_t *)adev->psp.ta_hdcp_start_addr + 101 - le32_to_cpu(ta_hdr->ta_dtm_offset_bytes); 95 + adev->psp.dtm.feature_version = 96 + le32_to_cpu(ta_hdr->dtm.fw_version); 97 + adev->psp.dtm.size_bytes = 98 + le32_to_cpu(ta_hdr->dtm.size_bytes); 99 + adev->psp.dtm.start_addr = 100 + (uint8_t *)adev->psp.hdcp.start_addr + 101 + le32_to_cpu(ta_hdr->dtm.offset_bytes); 102 102 103 - adev->psp.ta_securedisplay_ucode_version = 104 - le32_to_cpu(ta_hdr->ta_securedisplay_ucode_version); 105 - adev->psp.ta_securedisplay_ucode_size = 106 - le32_to_cpu(ta_hdr->ta_securedisplay_size_bytes); 107 - adev->psp.ta_securedisplay_start_addr = 108 - (uint8_t *)adev->psp.ta_hdcp_start_addr + 109 - le32_to_cpu(ta_hdr->ta_securedisplay_offset_bytes); 103 + adev->psp.securedisplay.feature_version = 104 + le32_to_cpu(ta_hdr->securedisplay.fw_version); 105 + adev->psp.securedisplay.size_bytes = 106 + le32_to_cpu(ta_hdr->securedisplay.size_bytes); 107 + adev->psp.securedisplay.start_addr = 108 + (uint8_t *)adev->psp.hdcp.start_addr + 109 + le32_to_cpu(ta_hdr->securedisplay.offset_bytes); 110 110 111 111 adev->psp.ta_fw_version = le32_to_cpu(ta_hdr->header.ucode_version); 112 112 }
+14 -14
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
··· 151 151 goto out2; 152 152 153 153 ta_hdr = (const struct ta_firmware_header_v1_0 *)adev->psp.ta_fw->data; 154 - adev->psp.ta_xgmi_ucode_version = le32_to_cpu(ta_hdr->ta_xgmi_ucode_version); 155 - adev->psp.ta_xgmi_ucode_size = le32_to_cpu(ta_hdr->ta_xgmi_size_bytes); 156 - adev->psp.ta_xgmi_start_addr = (uint8_t *)ta_hdr + 154 + adev->psp.xgmi.feature_version = le32_to_cpu(ta_hdr->xgmi.fw_version); 155 + adev->psp.xgmi.size_bytes = le32_to_cpu(ta_hdr->xgmi.size_bytes); 156 + adev->psp.xgmi.start_addr = (uint8_t *)ta_hdr + 157 157 le32_to_cpu(ta_hdr->header.ucode_array_offset_bytes); 158 158 adev->psp.ta_fw_version = le32_to_cpu(ta_hdr->header.ucode_version); 159 - adev->psp.ta_ras_ucode_version = le32_to_cpu(ta_hdr->ta_ras_ucode_version); 160 - adev->psp.ta_ras_ucode_size = le32_to_cpu(ta_hdr->ta_ras_size_bytes); 161 - adev->psp.ta_ras_start_addr = (uint8_t *)adev->psp.ta_xgmi_start_addr + 162 - le32_to_cpu(ta_hdr->ta_ras_offset_bytes); 159 + adev->psp.ras.feature_version = le32_to_cpu(ta_hdr->ras.fw_version); 160 + adev->psp.ras.size_bytes = le32_to_cpu(ta_hdr->ras.size_bytes); 161 + adev->psp.ras.start_addr = (uint8_t *)adev->psp.xgmi.start_addr + 162 + le32_to_cpu(ta_hdr->ras.offset_bytes); 163 163 } 164 164 break; 165 165 case CHIP_NAVI10: ··· 186 186 goto out2; 187 187 188 188 ta_hdr = (const struct ta_firmware_header_v1_0 *)adev->psp.ta_fw->data; 189 - adev->psp.ta_hdcp_ucode_version = le32_to_cpu(ta_hdr->ta_hdcp_ucode_version); 190 - adev->psp.ta_hdcp_ucode_size = le32_to_cpu(ta_hdr->ta_hdcp_size_bytes); 191 - adev->psp.ta_hdcp_start_addr = (uint8_t *)ta_hdr + 189 + adev->psp.hdcp.feature_version = le32_to_cpu(ta_hdr->hdcp.fw_version); 190 + adev->psp.hdcp.size_bytes = le32_to_cpu(ta_hdr->hdcp.size_bytes); 191 + adev->psp.hdcp.start_addr = (uint8_t *)ta_hdr + 192 192 le32_to_cpu(ta_hdr->header.ucode_array_offset_bytes); 193 193 194 194 adev->psp.ta_fw_version = le32_to_cpu(ta_hdr->header.ucode_version); 195 195 196 - adev->psp.ta_dtm_ucode_version = le32_to_cpu(ta_hdr->ta_dtm_ucode_version); 197 - adev->psp.ta_dtm_ucode_size = le32_to_cpu(ta_hdr->ta_dtm_size_bytes); 198 - adev->psp.ta_dtm_start_addr = (uint8_t *)adev->psp.ta_hdcp_start_addr + 199 - le32_to_cpu(ta_hdr->ta_dtm_offset_bytes); 196 + adev->psp.dtm.feature_version = le32_to_cpu(ta_hdr->dtm.fw_version); 197 + adev->psp.dtm.size_bytes = le32_to_cpu(ta_hdr->dtm.size_bytes); 198 + adev->psp.dtm.start_addr = (uint8_t *)adev->psp.hdcp.start_addr + 199 + le32_to_cpu(ta_hdr->dtm.offset_bytes); 200 200 } 201 201 break; 202 202 case CHIP_SIENNA_CICHLID:
+12 -12
drivers/gpu/drm/amd/amdgpu/psp_v12_0.c
··· 84 84 85 85 ta_hdr = (const struct ta_firmware_header_v1_0 *) 86 86 adev->psp.ta_fw->data; 87 - adev->psp.ta_hdcp_ucode_version = 88 - le32_to_cpu(ta_hdr->ta_hdcp_ucode_version); 89 - adev->psp.ta_hdcp_ucode_size = 90 - le32_to_cpu(ta_hdr->ta_hdcp_size_bytes); 91 - adev->psp.ta_hdcp_start_addr = 87 + adev->psp.hdcp.feature_version = 88 + le32_to_cpu(ta_hdr->hdcp.fw_version); 89 + adev->psp.hdcp.size_bytes = 90 + le32_to_cpu(ta_hdr->hdcp.size_bytes); 91 + adev->psp.hdcp.start_addr = 92 92 (uint8_t *)ta_hdr + 93 93 le32_to_cpu(ta_hdr->header.ucode_array_offset_bytes); 94 94 95 95 adev->psp.ta_fw_version = le32_to_cpu(ta_hdr->header.ucode_version); 96 96 97 - adev->psp.ta_dtm_ucode_version = 98 - le32_to_cpu(ta_hdr->ta_dtm_ucode_version); 99 - adev->psp.ta_dtm_ucode_size = 100 - le32_to_cpu(ta_hdr->ta_dtm_size_bytes); 101 - adev->psp.ta_dtm_start_addr = 102 - (uint8_t *)adev->psp.ta_hdcp_start_addr + 103 - le32_to_cpu(ta_hdr->ta_dtm_offset_bytes); 97 + adev->psp.dtm.feature_version = 98 + le32_to_cpu(ta_hdr->dtm.fw_version); 99 + adev->psp.dtm.size_bytes = 100 + le32_to_cpu(ta_hdr->dtm.size_bytes); 101 + adev->psp.dtm.start_addr = 102 + (uint8_t *)adev->psp.hdcp.start_addr + 103 + le32_to_cpu(ta_hdr->dtm.offset_bytes); 104 104 } 105 105 106 106 return 0;
+2 -1
drivers/gpu/drm/amd/amdgpu/ta_xgmi_if.h
··· 134 134 uint32_t cmd_id; 135 135 uint32_t resp_id; 136 136 enum ta_xgmi_status xgmi_status; 137 - uint32_t reserved; 137 + uint8_t flag_extend_link_record; 138 + uint8_t reserved0[3]; 138 139 union ta_xgmi_cmd_input xgmi_in_message; 139 140 union ta_xgmi_cmd_output xgmi_out_message; 140 141 };
+8 -1
drivers/gpu/drm/amd/amdgpu/vi.c
··· 904 904 case CHIP_POLARIS11: 905 905 case CHIP_POLARIS12: 906 906 case CHIP_TOPAZ: 907 - return amdgpu_dpm_is_baco_supported(adev); 907 + /* Disable BACO support for the specific polaris12 SKU temporarily */ 908 + if ((adev->pdev->device == 0x699F) && 909 + (adev->pdev->revision == 0xC7) && 910 + (adev->pdev->subsystem_vendor == 0x1028) && 911 + (adev->pdev->subsystem_device == 0x0039)) 912 + return false; 913 + else 914 + return amdgpu_dpm_is_baco_supported(adev); 908 915 default: 909 916 return false; 910 917 }
+19 -2
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
··· 211 211 WARN_ON(!old); 212 212 } 213 213 214 + static void program_trap_handler_settings(struct device_queue_manager *dqm, 215 + struct qcm_process_device *qpd) 216 + { 217 + if (dqm->dev->kfd2kgd->program_trap_handler_settings) 218 + dqm->dev->kfd2kgd->program_trap_handler_settings( 219 + dqm->dev->kgd, qpd->vmid, 220 + qpd->tba_addr, qpd->tma_addr); 221 + } 222 + 214 223 static int allocate_vmid(struct device_queue_manager *dqm, 215 224 struct qcm_process_device *qpd, 216 225 struct queue *q) ··· 249 240 q->properties.vmid = allocated_vmid; 250 241 251 242 program_sh_mem_settings(dqm, qpd); 243 + 244 + if (dqm->dev->device_info->asic_family >= CHIP_VEGA10 && 245 + dqm->dev->cwsr_enabled) 246 + program_trap_handler_settings(dqm, qpd); 252 247 253 248 /* qpd->page_table_base is set earlier when register_process() 254 249 * is called, i.e. when the first queue is created. ··· 595 582 } 596 583 597 584 retval = mqd_mgr->destroy_mqd(mqd_mgr, q->mqd, 598 - KFD_PREEMPT_TYPE_WAVEFRONT_DRAIN, 585 + (dqm->dev->cwsr_enabled? 586 + KFD_PREEMPT_TYPE_WAVEFRONT_SAVE: 587 + KFD_PREEMPT_TYPE_WAVEFRONT_DRAIN), 599 588 KFD_UNMAP_LATENCY_MS, q->pipe, q->queue); 600 589 if (retval) { 601 590 pr_err("destroy mqd failed\n"); ··· 690 675 continue; 691 676 692 677 retval = mqd_mgr->destroy_mqd(mqd_mgr, q->mqd, 693 - KFD_PREEMPT_TYPE_WAVEFRONT_DRAIN, 678 + (dqm->dev->cwsr_enabled? 679 + KFD_PREEMPT_TYPE_WAVEFRONT_SAVE: 680 + KFD_PREEMPT_TYPE_WAVEFRONT_DRAIN), 694 681 KFD_UNMAP_LATENCY_MS, q->pipe, q->queue); 695 682 if (retval && !ret) 696 683 /* Return the first error, but keep going to
+27 -16
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
··· 2675 2675 return 0; 2676 2676 } 2677 2677 2678 - /* svm_range_best_prefetch_location - decide the best prefetch location 2678 + /** 2679 + * svm_range_best_prefetch_location - decide the best prefetch location 2679 2680 * @prange: svm range structure 2680 2681 * 2681 2682 * For xnack off: 2682 - * If range map to single GPU, the best acutal location is prefetch loc, which 2683 + * If range map to single GPU, the best prefetch location is prefetch_loc, which 2683 2684 * can be CPU or GPU. 2684 2685 * 2685 - * If range map to multiple GPUs, only if mGPU connection on xgmi same hive, 2686 - * the best actual location could be prefetch_loc GPU. If mGPU connection on 2687 - * PCIe, the best actual location is always CPU, because GPU cannot access vram 2688 - * of other GPUs, assuming PCIe small bar (large bar support is not upstream). 2686 + * If range is ACCESS or ACCESS_IN_PLACE by mGPUs, only if mGPU connection on 2687 + * XGMI same hive, the best prefetch location is prefetch_loc GPU, othervise 2688 + * the best prefetch location is always CPU, because GPU can not have coherent 2689 + * mapping VRAM of other GPUs even with large-BAR PCIe connection. 2689 2690 * 2690 2691 * For xnack on: 2691 - * The best actual location is prefetch location. If mGPU connection on xgmi 2692 - * same hive, range map to multiple GPUs. Otherwise, the range only map to 2693 - * actual location GPU. Other GPU access vm fault will trigger migration. 2692 + * If range is not ACCESS_IN_PLACE by mGPUs, the best prefetch location is 2693 + * prefetch_loc, other GPU access will generate vm fault and trigger migration. 2694 + * 2695 + * If range is ACCESS_IN_PLACE by mGPUs, only if mGPU connection on XGMI same 2696 + * hive, the best prefetch location is prefetch_loc GPU, otherwise the best 2697 + * prefetch location is always CPU. 2694 2698 * 2695 2699 * Context: Process context 2696 2700 * ··· 2714 2710 2715 2711 p = container_of(prange->svms, struct kfd_process, svms); 2716 2712 2717 - /* xnack on */ 2718 - if (p->xnack_enabled) 2719 - goto out; 2720 - 2721 - /* xnack off */ 2722 2713 if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED) 2723 2714 goto out; 2724 2715 ··· 2723 2724 best_loc = 0; 2724 2725 goto out; 2725 2726 } 2726 - bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip, 2727 - MAX_GPU_INSTANCE); 2727 + 2728 + if (p->xnack_enabled) 2729 + bitmap_copy(bitmap, prange->bitmap_aip, MAX_GPU_INSTANCE); 2730 + else 2731 + bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip, 2732 + MAX_GPU_INSTANCE); 2728 2733 2729 2734 for_each_set_bit(gpuidx, bitmap, MAX_GPU_INSTANCE) { 2730 2735 pdd = kfd_process_device_from_gpuidx(p, gpuidx); ··· 3029 3026 3030 3027 pr_debug("svms 0x%p [0x%llx 0x%llx] nattr 0x%x\n", &p->svms, start, 3031 3028 start + size - 1, nattr); 3029 + 3030 + /* Flush pending deferred work to avoid racing with deferred actions from 3031 + * previous memory map changes (e.g. munmap). Concurrent memory map changes 3032 + * can still race with get_attr because we don't hold the mmap lock. But that 3033 + * would be a race condition in the application anyway, and undefined 3034 + * behaviour is acceptable in that case. 3035 + */ 3036 + flush_work(&p->svms.deferred_list_work); 3032 3037 3033 3038 mmap_read_lock(mm); 3034 3039 if (!svm_range_is_valid(mm, start, size)) {
+68 -44
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 1044 1044 } 1045 1045 #endif 1046 1046 #if defined(CONFIG_DRM_AMD_DC_DCN) 1047 - static void event_mall_stutter(struct work_struct *work) 1047 + static void vblank_control_worker(struct work_struct *work) 1048 1048 { 1049 - 1050 - struct vblank_workqueue *vblank_work = container_of(work, struct vblank_workqueue, mall_work); 1049 + struct vblank_control_work *vblank_work = 1050 + container_of(work, struct vblank_control_work, work); 1051 1051 struct amdgpu_display_manager *dm = vblank_work->dm; 1052 1052 1053 1053 mutex_lock(&dm->dc_lock); ··· 1061 1061 1062 1062 DRM_DEBUG_KMS("Allow idle optimizations (MALL): %d\n", dm->active_vblank_irq_count == 0); 1063 1063 1064 - mutex_unlock(&dm->dc_lock); 1065 - } 1066 - 1067 - static struct vblank_workqueue *vblank_create_workqueue(struct amdgpu_device *adev, struct dc *dc) 1068 - { 1069 - struct vblank_workqueue *vblank_work; 1070 - 1071 - vblank_work = kzalloc(sizeof(*vblank_work), GFP_KERNEL); 1072 - if (ZERO_OR_NULL_PTR(vblank_work)) { 1073 - kfree(vblank_work); 1074 - return NULL; 1064 + /* Control PSR based on vblank requirements from OS */ 1065 + if (vblank_work->stream && vblank_work->stream->link) { 1066 + if (vblank_work->enable) { 1067 + if (vblank_work->stream->link->psr_settings.psr_allow_active) 1068 + amdgpu_dm_psr_disable(vblank_work->stream); 1069 + } else if (vblank_work->stream->link->psr_settings.psr_feature_enabled && 1070 + !vblank_work->stream->link->psr_settings.psr_allow_active && 1071 + vblank_work->acrtc->dm_irq_params.allow_psr_entry) { 1072 + amdgpu_dm_psr_enable(vblank_work->stream); 1073 + } 1075 1074 } 1076 1075 1077 - INIT_WORK(&vblank_work->mall_work, event_mall_stutter); 1076 + mutex_unlock(&dm->dc_lock); 1078 1077 1079 - return vblank_work; 1078 + dc_stream_release(vblank_work->stream); 1079 + 1080 + kfree(vblank_work); 1080 1081 } 1082 + 1081 1083 #endif 1082 1084 static int amdgpu_dm_init(struct amdgpu_device *adev) 1083 1085 { ··· 1222 1220 1223 1221 #if defined(CONFIG_DRM_AMD_DC_DCN) 1224 1222 if (adev->dm.dc->caps.max_links > 0) { 1225 - adev->dm.vblank_workqueue = vblank_create_workqueue(adev, adev->dm.dc); 1226 - 1227 - if (!adev->dm.vblank_workqueue) 1223 + adev->dm.vblank_control_workqueue = 1224 + create_singlethread_workqueue("dm_vblank_control_workqueue"); 1225 + if (!adev->dm.vblank_control_workqueue) 1228 1226 DRM_ERROR("amdgpu: failed to initialize vblank_workqueue.\n"); 1229 - else 1230 - DRM_DEBUG_DRIVER("amdgpu: vblank_workqueue init done %p.\n", adev->dm.vblank_workqueue); 1231 1227 } 1232 1228 #endif 1233 1229 ··· 1298 1298 { 1299 1299 int i; 1300 1300 1301 + #if defined(CONFIG_DRM_AMD_DC_DCN) 1302 + if (adev->dm.vblank_control_workqueue) { 1303 + destroy_workqueue(adev->dm.vblank_control_workqueue); 1304 + adev->dm.vblank_control_workqueue = NULL; 1305 + } 1306 + #endif 1307 + 1301 1308 for (i = 0; i < adev->dm.display_indexes_num; i++) { 1302 1309 drm_encoder_cleanup(&adev->dm.mst_encoders[i].base); 1303 1310 } ··· 1326 1319 1327 1320 if (adev->dm.dc) 1328 1321 dc_deinit_callbacks(adev->dm.dc); 1329 - #endif 1330 - 1331 - #if defined(CONFIG_DRM_AMD_DC_DCN) 1332 - if (adev->dm.vblank_workqueue) { 1333 - adev->dm.vblank_workqueue->dm = NULL; 1334 - kfree(adev->dm.vblank_workqueue); 1335 - adev->dm.vblank_workqueue = NULL; 1336 - } 1337 1322 #endif 1338 1323 1339 1324 dc_dmub_srv_destroy(&adev->dm.dc->ctx->dmub_srv); ··· 5999 6000 struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state); 6000 6001 #if defined(CONFIG_DRM_AMD_DC_DCN) 6001 6002 struct amdgpu_display_manager *dm = &adev->dm; 6002 - unsigned long flags; 6003 + struct vblank_control_work *work; 6003 6004 #endif 6004 6005 int rc = 0; 6005 6006 ··· 6024 6025 return 0; 6025 6026 6026 6027 #if defined(CONFIG_DRM_AMD_DC_DCN) 6027 - spin_lock_irqsave(&dm->vblank_lock, flags); 6028 - dm->vblank_workqueue->dm = dm; 6029 - dm->vblank_workqueue->otg_inst = acrtc->otg_inst; 6030 - dm->vblank_workqueue->enable = enable; 6031 - spin_unlock_irqrestore(&dm->vblank_lock, flags); 6032 - schedule_work(&dm->vblank_workqueue->mall_work); 6028 + work = kzalloc(sizeof(*work), GFP_ATOMIC); 6029 + if (!work) 6030 + return -ENOMEM; 6031 + 6032 + INIT_WORK(&work->work, vblank_control_worker); 6033 + work->dm = dm; 6034 + work->acrtc = acrtc; 6035 + work->enable = enable; 6036 + 6037 + if (acrtc_state->stream) { 6038 + dc_stream_retain(acrtc_state->stream); 6039 + work->stream = acrtc_state->stream; 6040 + } 6041 + 6042 + queue_work(dm->vblank_control_workqueue, &work->work); 6033 6043 #endif 6034 6044 6035 6045 return 0; ··· 8643 8635 /* Update the planes if changed or disable if we don't have any. */ 8644 8636 if ((planes_count || acrtc_state->active_planes == 0) && 8645 8637 acrtc_state->stream) { 8638 + #if defined(CONFIG_DRM_AMD_DC_DCN) 8639 + /* 8640 + * If PSR or idle optimizations are enabled then flush out 8641 + * any pending work before hardware programming. 8642 + */ 8643 + flush_workqueue(dm->vblank_control_workqueue); 8644 + #endif 8645 + 8646 8646 bundle->stream_update.stream = acrtc_state->stream; 8647 8647 if (new_pcrtc_state->mode_changed) { 8648 8648 bundle->stream_update.src = acrtc_state->stream->src; ··· 8719 8703 acrtc_state->stream->link->psr_settings.psr_version != DC_PSR_VERSION_UNSUPPORTED && 8720 8704 !acrtc_state->stream->link->psr_settings.psr_feature_enabled) 8721 8705 amdgpu_dm_link_setup_psr(acrtc_state->stream); 8722 - else if ((acrtc_state->update_type == UPDATE_TYPE_FAST) && 8723 - acrtc_state->stream->link->psr_settings.psr_feature_enabled && 8724 - !acrtc_state->stream->link->psr_settings.psr_allow_active) { 8725 - struct amdgpu_dm_connector *aconn = (struct amdgpu_dm_connector *) 8726 - acrtc_state->stream->dm_stream_context; 8706 + 8707 + /* Decrement skip count when PSR is enabled and we're doing fast updates. */ 8708 + if (acrtc_state->update_type == UPDATE_TYPE_FAST && 8709 + acrtc_state->stream->link->psr_settings.psr_feature_enabled) { 8710 + struct amdgpu_dm_connector *aconn = 8711 + (struct amdgpu_dm_connector *)acrtc_state->stream->dm_stream_context; 8727 8712 8728 8713 if (aconn->psr_skip_count > 0) 8729 8714 aconn->psr_skip_count--; 8730 - else 8731 - amdgpu_dm_psr_enable(acrtc_state->stream); 8715 + 8716 + /* Allow PSR when skip count is 0. */ 8717 + acrtc_attach->dm_irq_params.allow_psr_entry = !aconn->psr_skip_count; 8718 + } else { 8719 + acrtc_attach->dm_irq_params.allow_psr_entry = false; 8732 8720 } 8733 8721 8734 8722 mutex_unlock(&dm->dc_lock); ··· 8981 8961 8982 8962 if (dc_state) { 8983 8963 /* if there mode set or reset, disable eDP PSR */ 8984 - if (mode_set_reset_required) 8964 + if (mode_set_reset_required) { 8965 + #if defined(CONFIG_DRM_AMD_DC_DCN) 8966 + flush_workqueue(dm->vblank_control_workqueue); 8967 + #endif 8985 8968 amdgpu_dm_psr_disable_all(dm); 8969 + } 8986 8970 8987 8971 dm_enable_per_frame_crtc_master_sync(dc_state); 8988 8972 mutex_lock(&dm->dc_lock);
+13 -10
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
··· 60 60 61 61 /* Forward declarations */ 62 62 struct amdgpu_device; 63 + struct amdgpu_crtc; 63 64 struct drm_device; 64 65 struct dc; 65 66 struct amdgpu_bo; ··· 87 86 }; 88 87 89 88 /** 90 - * struct vblank_workqueue - Works to be executed in a separate thread during vblank 91 - * @mall_work: work for mall stutter 89 + * struct vblank_control_work - Work data for vblank control 90 + * @work: Kernel work data for the work event 92 91 * @dm: amdgpu display manager device 93 - * @otg_inst: otg instance of which vblank is being set 94 - * @enable: true if enable vblank 92 + * @acrtc: amdgpu CRTC instance for which the event has occurred 93 + * @stream: DC stream for which the event has occurred 94 + * @enable: true if enabling vblank 95 95 */ 96 - struct vblank_workqueue { 97 - struct work_struct mall_work; 96 + struct vblank_control_work { 97 + struct work_struct work; 98 98 struct amdgpu_display_manager *dm; 99 - int otg_inst; 99 + struct amdgpu_crtc *acrtc; 100 + struct dc_stream_state *stream; 100 101 bool enable; 101 102 }; 102 103 ··· 383 380 384 381 #if defined(CONFIG_DRM_AMD_DC_DCN) 385 382 /** 386 - * @vblank_workqueue: 383 + * @vblank_control_workqueue: 387 384 * 388 - * amdgpu workqueue during vblank 385 + * Deferred work for vblank control events. 389 386 */ 390 - struct vblank_workqueue *vblank_workqueue; 387 + struct workqueue_struct *vblank_control_workqueue; 391 388 #endif 392 389 393 390 struct drm_atomic_state *cached_state;
+6 -6
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
··· 79 79 80 80 struct ta_hdcp_shared_memory *hdcp_cmd; 81 81 82 - if (!psp->hdcp_context.hdcp_initialized) { 82 + if (!psp->hdcp_context.context.initialized) { 83 83 DRM_WARN("Failed to get hdcp srm. HDCP TA is not initialized."); 84 84 return NULL; 85 85 } 86 86 87 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 87 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 88 88 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 89 89 90 90 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP_GET_SRM; ··· 105 105 106 106 struct ta_hdcp_shared_memory *hdcp_cmd; 107 107 108 - if (!psp->hdcp_context.hdcp_initialized) { 108 + if (!psp->hdcp_context.context.initialized) { 109 109 DRM_WARN("Failed to get hdcp srm. HDCP TA is not initialized."); 110 110 return -EINVAL; 111 111 } 112 112 113 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 113 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 114 114 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 115 115 116 116 memcpy(hdcp_cmd->in_msg.hdcp_set_srm.srm_buf, srm, srm_size); ··· 414 414 struct ta_dtm_shared_memory *dtm_cmd; 415 415 bool res = true; 416 416 417 - if (!psp->dtm_context.dtm_initialized) { 417 + if (!psp->dtm_context.context.initialized) { 418 418 DRM_INFO("Failed to enable ASSR, DTM TA is not initialized."); 419 419 return false; 420 420 } 421 421 422 - dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 422 + dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.context.mem_context.shared_buf; 423 423 424 424 mutex_lock(&psp->dtm_context.mutex); 425 425 memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory));
+1 -1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
··· 584 584 handler_data = container_of(handler_list->next, struct amdgpu_dm_irq_handler_data, list); 585 585 586 586 /*allocate a new amdgpu_dm_irq_handler_data*/ 587 - handler_data_add = kzalloc(sizeof(*handler_data), GFP_KERNEL); 587 + handler_data_add = kzalloc(sizeof(*handler_data), GFP_ATOMIC); 588 588 if (!handler_data_add) { 589 589 DRM_ERROR("DM_IRQ: failed to allocate irq handler!\n"); 590 590 return;
+1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h
··· 33 33 struct mod_vrr_params vrr_params; 34 34 struct dc_stream_state *stream; 35 35 int active_planes; 36 + bool allow_psr_entry; 36 37 struct mod_freesync_config freesync_config; 37 38 38 39 #ifdef CONFIG_DEBUG_FS
+23
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
··· 213 213 drm_connector_update_edid_property( 214 214 &aconnector->base, 215 215 NULL); 216 + 217 + DRM_DEBUG_KMS("Can't get EDID of %s. Add default remote sink.", connector->name); 218 + if (!aconnector->dc_sink) { 219 + struct dc_sink *dc_sink; 220 + struct dc_sink_init_data init_params = { 221 + .link = aconnector->dc_link, 222 + .sink_signal = SIGNAL_TYPE_DISPLAY_PORT_MST }; 223 + 224 + dc_sink = dc_link_add_remote_sink( 225 + aconnector->dc_link, 226 + NULL, 227 + 0, 228 + &init_params); 229 + 230 + if (!dc_sink) { 231 + DRM_ERROR("Unable to add a remote sink\n"); 232 + return 0; 233 + } 234 + 235 + dc_sink->priv = aconnector; 236 + aconnector->dc_sink = dc_sink; 237 + } 238 + 216 239 return ret; 217 240 } 218 241
+47 -21
drivers/gpu/drm/amd/display/dc/core/dc.c
··· 1481 1481 return true; 1482 1482 } 1483 1483 1484 + static inline bool should_update_pipe_for_stream( 1485 + struct dc_state *context, 1486 + struct pipe_ctx *pipe_ctx, 1487 + struct dc_stream_state *stream) 1488 + { 1489 + return (pipe_ctx->stream && pipe_ctx->stream == stream); 1490 + } 1491 + 1492 + static inline bool should_update_pipe_for_plane( 1493 + struct dc_state *context, 1494 + struct pipe_ctx *pipe_ctx, 1495 + struct dc_plane_state *plane_state) 1496 + { 1497 + return (pipe_ctx->plane_state == plane_state); 1498 + } 1499 + 1484 1500 void dc_enable_stereo( 1485 1501 struct dc *dc, 1486 1502 struct dc_state *context, ··· 1507 1491 struct pipe_ctx *pipe; 1508 1492 1509 1493 for (i = 0; i < MAX_PIPES; i++) { 1510 - if (context != NULL) 1494 + if (context != NULL) { 1511 1495 pipe = &context->res_ctx.pipe_ctx[i]; 1512 - else 1496 + } else { 1497 + context = dc->current_state; 1513 1498 pipe = &dc->current_state->res_ctx.pipe_ctx[i]; 1514 - for (j = 0 ; pipe && j < stream_count; j++) { 1515 - if (streams[j] && streams[j] == pipe->stream && 1499 + } 1500 + 1501 + for (j = 0; pipe && j < stream_count; j++) { 1502 + if (should_update_pipe_for_stream(context, pipe, streams[j]) && 1516 1503 dc->hwss.setup_stereo) 1517 1504 dc->hwss.setup_stereo(pipe, dc); 1518 1505 } ··· 1548 1529 { 1549 1530 if (dc->hwss.z10_restore) 1550 1531 dc->hwss.z10_restore(dc); 1532 + } 1533 + 1534 + void dc_z10_save_init(struct dc *dc) 1535 + { 1536 + if (dc->hwss.z10_save_init) 1537 + dc->hwss.z10_save_init(dc); 1551 1538 } 1552 1539 #endif 1553 1540 /* ··· 2648 2623 { 2649 2624 int i, j; 2650 2625 struct pipe_ctx *top_pipe_to_program = NULL; 2626 + bool should_lock_all_pipes = (update_type != UPDATE_TYPE_FAST); 2651 2627 2652 2628 #if defined(CONFIG_DRM_AMD_DC_DCN) 2653 2629 dc_z10_restore(dc); ··· 2720 2694 top_pipe_to_program->stream_res.tg); 2721 2695 } 2722 2696 2723 - if ((update_type != UPDATE_TYPE_FAST) && dc->hwss.interdependent_update_lock) 2697 + if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) 2724 2698 dc->hwss.interdependent_update_lock(dc, context, true); 2725 2699 else 2726 2700 /* Lock the top pipe while updating plane addrs, since freesync requires ··· 2743 2717 if (dc->hwss.program_front_end_for_ctx) 2744 2718 dc->hwss.program_front_end_for_ctx(dc, context); 2745 2719 2746 - if ((update_type != UPDATE_TYPE_FAST) && dc->hwss.interdependent_update_lock) 2720 + if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) 2747 2721 dc->hwss.interdependent_update_lock(dc, context, false); 2748 2722 else 2749 2723 dc->hwss.pipe_control_lock(dc, top_pipe_to_program, false); ··· 2759 2733 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; 2760 2734 if (!pipe_ctx->plane_state) 2761 2735 continue; 2762 - if (pipe_ctx->plane_state != plane_state) 2736 + if (should_update_pipe_for_plane(context, pipe_ctx, plane_state)) 2763 2737 continue; 2764 - plane_state->triplebuffer_flips = false; 2738 + pipe_ctx->plane_state->triplebuffer_flips = false; 2765 2739 if (update_type == UPDATE_TYPE_FAST && 2766 2740 dc->hwss.program_triplebuffer != NULL && 2767 - !plane_state->flip_immediate && dc->debug.enable_tri_buf) { 2741 + !pipe_ctx->plane_state->flip_immediate && dc->debug.enable_tri_buf) { 2768 2742 /*triple buffer for VUpdate only*/ 2769 - plane_state->triplebuffer_flips = true; 2743 + pipe_ctx->plane_state->triplebuffer_flips = true; 2770 2744 } 2771 2745 } 2772 2746 if (update_type == UPDATE_TYPE_FULL) { ··· 2782 2756 2783 2757 if (!pipe_ctx->top_pipe && 2784 2758 !pipe_ctx->prev_odm_pipe && 2785 - pipe_ctx->stream && 2786 - pipe_ctx->stream == stream) { 2759 + should_update_pipe_for_stream(context, pipe_ctx, stream)) { 2787 2760 struct dc_stream_status *stream_status = NULL; 2788 2761 2789 2762 if (!pipe_ctx->plane_state) ··· 2835 2810 for (j = 0; j < dc->res_pool->pipe_count; j++) { 2836 2811 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; 2837 2812 2838 - if (pipe_ctx->stream != stream) 2813 + if (!should_update_pipe_for_stream(context, pipe_ctx, stream)) 2839 2814 continue; 2840 2815 2841 - if (pipe_ctx->plane_state != plane_state) 2816 + if (!should_update_pipe_for_plane(context, pipe_ctx, plane_state)) 2842 2817 continue; 2843 2818 2844 2819 // GSL has to be used for flip immediate 2845 2820 dc->hwss.set_flip_control_gsl(pipe_ctx, 2846 - plane_state->flip_immediate); 2821 + pipe_ctx->plane_state->flip_immediate); 2847 2822 } 2848 2823 } 2849 2824 ··· 2854 2829 for (j = 0; j < dc->res_pool->pipe_count; j++) { 2855 2830 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; 2856 2831 2857 - if (pipe_ctx->stream != stream) 2832 + if (!should_update_pipe_for_stream(context, pipe_ctx, stream)) 2858 2833 continue; 2859 2834 2860 - if (pipe_ctx->plane_state != plane_state) 2835 + if (!should_update_pipe_for_plane(context, pipe_ctx, plane_state)) 2861 2836 continue; 2837 + 2862 2838 /*program triple buffer after lock based on flip type*/ 2863 2839 if (dc->hwss.program_triplebuffer != NULL && dc->debug.enable_tri_buf) { 2864 2840 /*only enable triplebuffer for fast_update*/ 2865 2841 dc->hwss.program_triplebuffer( 2866 - dc, pipe_ctx, plane_state->triplebuffer_flips); 2842 + dc, pipe_ctx, pipe_ctx->plane_state->triplebuffer_flips); 2867 2843 } 2868 - if (srf_updates[i].flip_addr) 2844 + if (pipe_ctx->plane_state->update_flags.bits.addr_update) 2869 2845 dc->hwss.update_plane_addr(dc, pipe_ctx); 2870 2846 } 2871 2847 } 2872 2848 2873 2849 } 2874 2850 2875 - if ((update_type != UPDATE_TYPE_FAST) && dc->hwss.interdependent_update_lock) 2851 + if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) 2876 2852 dc->hwss.interdependent_update_lock(dc, context, false); 2877 2853 else 2878 2854 dc->hwss.pipe_control_lock(dc, top_pipe_to_program, false); ··· 2917 2891 continue; 2918 2892 2919 2893 if (pipe_ctx->bottom_pipe || pipe_ctx->next_odm_pipe || 2920 - !pipe_ctx->stream || pipe_ctx->stream != stream || 2894 + !pipe_ctx->stream || !should_update_pipe_for_stream(context, pipe_ctx, stream) || 2921 2895 !pipe_ctx->plane_state->update_flags.bits.addr_update || 2922 2896 pipe_ctx->plane_state->skip_manual_trigger) 2923 2897 continue;
+73 -49
drivers/gpu/drm/amd/display/dc/core/dc_stream.c
··· 246 246 return dc_stream_get_status_from_state(dc->current_state, stream); 247 247 } 248 248 249 + static void program_cursor_attributes( 250 + struct dc *dc, 251 + struct dc_stream_state *stream, 252 + const struct dc_cursor_attributes *attributes) 253 + { 254 + int i; 255 + struct resource_context *res_ctx; 256 + struct pipe_ctx *pipe_to_program = NULL; 257 + 258 + if (!stream) 259 + return; 260 + 261 + res_ctx = &dc->current_state->res_ctx; 262 + 263 + for (i = 0; i < MAX_PIPES; i++) { 264 + struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i]; 265 + 266 + if (pipe_ctx->stream != stream) 267 + continue; 268 + 269 + if (!pipe_to_program) { 270 + pipe_to_program = pipe_ctx; 271 + dc->hwss.cursor_lock(dc, pipe_to_program, true); 272 + } 273 + 274 + dc->hwss.set_cursor_attribute(pipe_ctx); 275 + if (dc->hwss.set_cursor_sdr_white_level) 276 + dc->hwss.set_cursor_sdr_white_level(pipe_ctx); 277 + } 278 + 279 + if (pipe_to_program) 280 + dc->hwss.cursor_lock(dc, pipe_to_program, false); 281 + } 282 + 249 283 #ifndef TRIM_FSFT 250 284 /* 251 285 * dc_optimize_timing_for_fsft() - dc to optimize timing ··· 304 270 struct dc_stream_state *stream, 305 271 const struct dc_cursor_attributes *attributes) 306 272 { 307 - int i; 308 273 struct dc *dc; 309 - struct resource_context *res_ctx; 310 - struct pipe_ctx *pipe_to_program = NULL; 311 274 #if defined(CONFIG_DRM_AMD_DC_DCN) 312 275 bool reset_idle_optimizations = false; 313 276 #endif ··· 324 293 } 325 294 326 295 dc = stream->ctx->dc; 327 - res_ctx = &dc->current_state->res_ctx; 328 296 stream->cursor_attributes = *attributes; 329 297 330 298 #if defined(CONFIG_DRM_AMD_DC_DCN) ··· 335 305 } 336 306 337 307 #endif 338 - 339 - for (i = 0; i < MAX_PIPES; i++) { 340 - struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i]; 341 - 342 - if (pipe_ctx->stream != stream) 343 - continue; 344 - 345 - if (!pipe_to_program) { 346 - pipe_to_program = pipe_ctx; 347 - dc->hwss.cursor_lock(dc, pipe_to_program, true); 348 - } 349 - 350 - dc->hwss.set_cursor_attribute(pipe_ctx); 351 - if (dc->hwss.set_cursor_sdr_white_level) 352 - dc->hwss.set_cursor_sdr_white_level(pipe_ctx); 353 - } 354 - 355 - if (pipe_to_program) 356 - dc->hwss.cursor_lock(dc, pipe_to_program, false); 308 + program_cursor_attributes(dc, stream, attributes); 357 309 358 310 #if defined(CONFIG_DRM_AMD_DC_DCN) 359 311 /* re-enable idle optimizations if necessary */ ··· 346 334 return true; 347 335 } 348 336 349 - bool dc_stream_set_cursor_position( 337 + static void program_cursor_position( 338 + struct dc *dc, 350 339 struct dc_stream_state *stream, 351 340 const struct dc_cursor_position *position) 352 341 { 353 342 int i; 354 - struct dc *dc; 355 343 struct resource_context *res_ctx; 356 344 struct pipe_ctx *pipe_to_program = NULL; 357 - #if defined(CONFIG_DRM_AMD_DC_DCN) 358 - bool reset_idle_optimizations = false; 359 - #endif 360 345 361 - if (NULL == stream) { 362 - dm_error("DC: dc_stream is NULL!\n"); 363 - return false; 364 - } 346 + if (!stream) 347 + return; 365 348 366 - if (NULL == position) { 367 - dm_error("DC: cursor position is NULL!\n"); 368 - return false; 369 - } 370 - 371 - dc = stream->ctx->dc; 372 349 res_ctx = &dc->current_state->res_ctx; 373 - #if defined(CONFIG_DRM_AMD_DC_DCN) 374 - dc_z10_restore(dc); 375 - 376 - /* disable idle optimizations if enabling cursor */ 377 - if (dc->idle_optimizations_allowed && !stream->cursor_position.enable && position->enable) { 378 - dc_allow_idle_optimizations(dc, false); 379 - reset_idle_optimizations = true; 380 - } 381 - 382 - #endif 383 - stream->cursor_position = *position; 384 350 385 351 for (i = 0; i < MAX_PIPES; i++) { 386 352 struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i]; ··· 380 390 381 391 if (pipe_to_program) 382 392 dc->hwss.cursor_lock(dc, pipe_to_program, false); 393 + } 383 394 395 + bool dc_stream_set_cursor_position( 396 + struct dc_stream_state *stream, 397 + const struct dc_cursor_position *position) 398 + { 399 + struct dc *dc; 400 + #if defined(CONFIG_DRM_AMD_DC_DCN) 401 + bool reset_idle_optimizations = false; 402 + #endif 403 + 404 + if (NULL == stream) { 405 + dm_error("DC: dc_stream is NULL!\n"); 406 + return false; 407 + } 408 + 409 + if (NULL == position) { 410 + dm_error("DC: cursor position is NULL!\n"); 411 + return false; 412 + } 413 + 414 + dc = stream->ctx->dc; 415 + #if defined(CONFIG_DRM_AMD_DC_DCN) 416 + dc_z10_restore(dc); 417 + 418 + /* disable idle optimizations if enabling cursor */ 419 + if (dc->idle_optimizations_allowed && !stream->cursor_position.enable && position->enable) { 420 + dc_allow_idle_optimizations(dc, false); 421 + reset_idle_optimizations = true; 422 + } 423 + 424 + #endif 425 + stream->cursor_position = *position; 426 + 427 + program_cursor_position(dc, stream, position); 384 428 #if defined(CONFIG_DRM_AMD_DC_DCN) 385 429 /* re-enable idle optimizations if necessary */ 386 430 if (reset_idle_optimizations)
+3
drivers/gpu/drm/amd/display/dc/core/dc_vm_helper.c
··· 47 47 */ 48 48 memcpy(&dc->vm_pa_config, pa_config, sizeof(struct dc_phy_addr_space_config)); 49 49 dc->vm_pa_config.valid = true; 50 + #if defined(CONFIG_DRM_AMD_DC_DCN) 51 + dc_z10_save_init(dc); 52 + #endif 50 53 } 51 54 52 55 return num_vmids;
+2 -1
drivers/gpu/drm/amd/display/dc/dc.h
··· 45 45 /* forward declaration */ 46 46 struct aux_payload; 47 47 48 - #define DC_VER "3.2.147" 48 + #define DC_VER "3.2.149" 49 49 50 50 #define MAX_SURFACES 3 51 51 #define MAX_PLANES 6 ··· 1338 1338 bool dc_set_psr_allow_active(struct dc *dc, bool enable); 1339 1339 #if defined(CONFIG_DRM_AMD_DC_DCN) 1340 1340 void dc_z10_restore(struct dc *dc); 1341 + void dc_z10_save_init(struct dc *dc); 1341 1342 #endif 1342 1343 1343 1344 bool dc_enable_dmub_notifications(struct dc *dc);
+183 -9
drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
··· 42 42 #define DC_LOGGER \ 43 43 engine->ctx->logger 44 44 45 + #define DC_TRACE_LEVEL_MESSAGE(...) /* do nothing */ 46 + #define IS_DC_I2CAUX_LOGGING_ENABLED() (false) 47 + #define LOG_FLAG_Error_I2cAux LOG_ERROR 48 + #define LOG_FLAG_I2cAux_DceAux LOG_I2C_AUX 49 + 45 50 #include "reg_helper.h" 46 51 47 52 #undef FN ··· 628 623 #define AUX_MAX_INVALID_REPLY_RETRIES 2 629 624 #define AUX_MAX_TIMEOUT_RETRIES 3 630 625 626 + static void dce_aux_log_payload(const char *payload_name, 627 + unsigned char *payload, uint32_t length, uint32_t max_length_to_log) 628 + { 629 + if (!IS_DC_I2CAUX_LOGGING_ENABLED()) 630 + return; 631 + 632 + if (payload && length) { 633 + char hex_str[128] = {0}; 634 + char *hex_str_ptr = &hex_str[0]; 635 + uint32_t hex_str_remaining = sizeof(hex_str); 636 + unsigned char *payload_ptr = payload; 637 + unsigned char *payload_max_to_log_ptr = payload_ptr + min(max_length_to_log, length); 638 + unsigned int count; 639 + char *padding = ""; 640 + 641 + while (payload_ptr < payload_max_to_log_ptr) { 642 + count = snprintf_count(hex_str_ptr, hex_str_remaining, "%s%02X", padding, *payload_ptr); 643 + padding = " "; 644 + hex_str_remaining -= count; 645 + hex_str_ptr += count; 646 + payload_ptr++; 647 + } 648 + 649 + count = snprintf_count(hex_str_ptr, hex_str_remaining, " "); 650 + hex_str_remaining -= count; 651 + hex_str_ptr += count; 652 + 653 + payload_ptr = payload; 654 + while (payload_ptr < payload_max_to_log_ptr) { 655 + count = snprintf_count(hex_str_ptr, hex_str_remaining, "%c", 656 + *payload_ptr >= ' ' ? *payload_ptr : '.'); 657 + hex_str_remaining -= count; 658 + hex_str_ptr += count; 659 + payload_ptr++; 660 + } 661 + 662 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_VERBOSE, 663 + LOG_FLAG_I2cAux_DceAux, 664 + "dce_aux_log_payload: %s: length=%u: data: %s%s", 665 + payload_name, 666 + length, 667 + hex_str, 668 + (length > max_length_to_log ? " (...)" : " ")); 669 + } else { 670 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_VERBOSE, 671 + LOG_FLAG_I2cAux_DceAux, 672 + "dce_aux_log_payload: %s: length=%u: data: <empty payload>", 673 + payload_name, 674 + length); 675 + } 676 + } 677 + 631 678 bool dce_aux_transfer_with_retries(struct ddc_service *ddc, 632 679 struct aux_payload *payload) 633 680 { ··· 705 648 } 706 649 707 650 for (i = 0; i < AUX_MAX_RETRIES; i++) { 651 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 652 + LOG_FLAG_I2cAux_DceAux, 653 + "dce_aux_transfer_with_retries: link_index=%u: START: retry %d of %d: address=0x%04x length=%u write=%d mot=%d", 654 + ddc && ddc->link ? ddc->link->link_index : UINT_MAX, 655 + i + 1, 656 + (int)AUX_MAX_RETRIES, 657 + payload->address, 658 + payload->length, 659 + (unsigned int) payload->write, 660 + (unsigned int) payload->mot); 661 + if (payload->write) 662 + dce_aux_log_payload(" write", payload->data, payload->length, 16); 708 663 ret = dce_aux_transfer_raw(ddc, payload, &operation_result); 664 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 665 + LOG_FLAG_I2cAux_DceAux, 666 + "dce_aux_transfer_with_retries: link_index=%u: END: retry %d of %d: address=0x%04x length=%u write=%d mot=%d: ret=%d operation_result=%d payload->reply=%u", 667 + ddc && ddc->link ? ddc->link->link_index : UINT_MAX, 668 + i + 1, 669 + (int)AUX_MAX_RETRIES, 670 + payload->address, 671 + payload->length, 672 + (unsigned int) payload->write, 673 + (unsigned int) payload->mot, 674 + ret, 675 + (int)operation_result, 676 + (unsigned int) *payload->reply); 677 + if (!payload->write) 678 + dce_aux_log_payload(" read", payload->data, ret > 0 ? ret : 0, 16); 709 679 710 680 switch (operation_result) { 711 681 case AUX_RET_SUCCESS: ··· 741 657 742 658 switch (*payload->reply) { 743 659 case AUX_TRANSACTION_REPLY_AUX_ACK: 660 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 661 + LOG_FLAG_I2cAux_DceAux, 662 + "dce_aux_transfer_with_retries: AUX_RET_SUCCESS: AUX_TRANSACTION_REPLY_AUX_ACK"); 744 663 if (!payload->write && payload->length != ret) { 745 - if (++aux_ack_retries >= AUX_MAX_RETRIES) 664 + if (++aux_ack_retries >= AUX_MAX_RETRIES) { 665 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR, 666 + LOG_FLAG_Error_I2cAux, 667 + "dce_aux_transfer_with_retries: FAILURE: aux_ack_retries=%d >= AUX_MAX_RETRIES=%d", 668 + aux_defer_retries, 669 + AUX_MAX_RETRIES); 746 670 goto fail; 747 - else 671 + } else { 748 672 udelay(300); 673 + } 749 674 } else 750 675 return true; 751 676 break; 752 677 753 678 case AUX_TRANSACTION_REPLY_AUX_DEFER: 679 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 680 + LOG_FLAG_I2cAux_DceAux, 681 + "dce_aux_transfer_with_retries: AUX_RET_SUCCESS: AUX_TRANSACTION_REPLY_AUX_DEFER"); 682 + 754 683 /* polling_timeout_period is in us */ 755 684 defer_time_in_ms += aux110->polling_timeout_period / 1000; 756 685 ++aux_defer_retries; 757 686 fallthrough; 758 687 case AUX_TRANSACTION_REPLY_I2C_OVER_AUX_DEFER: 688 + if (*payload->reply == AUX_TRANSACTION_REPLY_I2C_OVER_AUX_DEFER) 689 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 690 + LOG_FLAG_I2cAux_DceAux, 691 + "dce_aux_transfer_with_retries: AUX_RET_SUCCESS: AUX_TRANSACTION_REPLY_I2C_OVER_AUX_DEFER"); 692 + 759 693 retry_on_defer = true; 760 694 fallthrough; 761 695 case AUX_TRANSACTION_REPLY_I2C_OVER_AUX_NACK: 696 + if (*payload->reply == AUX_TRANSACTION_REPLY_I2C_OVER_AUX_NACK) 697 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 698 + LOG_FLAG_I2cAux_DceAux, 699 + "dce_aux_transfer_with_retries: AUX_RET_SUCCESS: AUX_TRANSACTION_REPLY_I2C_OVER_AUX_NACK"); 700 + 762 701 if (aux_defer_retries >= AUX_MIN_DEFER_RETRIES 763 702 && defer_time_in_ms >= AUX_MAX_DEFER_TIMEOUT_MS) { 703 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR, 704 + LOG_FLAG_Error_I2cAux, 705 + "dce_aux_transfer_with_retries: FAILURE: aux_defer_retries=%d >= AUX_MIN_DEFER_RETRIES=%d && defer_time_in_ms=%d >= AUX_MAX_DEFER_TIMEOUT_MS=%d", 706 + aux_defer_retries, 707 + AUX_MIN_DEFER_RETRIES, 708 + defer_time_in_ms, 709 + AUX_MAX_DEFER_TIMEOUT_MS); 764 710 goto fail; 765 711 } else { 766 712 if ((*payload->reply == AUX_TRANSACTION_REPLY_AUX_DEFER) || 767 713 (*payload->reply == AUX_TRANSACTION_REPLY_I2C_OVER_AUX_DEFER)) { 714 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 715 + LOG_FLAG_I2cAux_DceAux, 716 + "dce_aux_transfer_with_retries: payload->defer_delay=%u", 717 + payload->defer_delay); 768 718 if (payload->defer_delay > 1) { 769 719 msleep(payload->defer_delay); 770 720 defer_time_in_ms += payload->defer_delay; ··· 811 693 break; 812 694 813 695 case AUX_TRANSACTION_REPLY_I2C_DEFER: 696 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 697 + LOG_FLAG_I2cAux_DceAux, 698 + "dce_aux_transfer_with_retries: AUX_RET_SUCCESS: AUX_TRANSACTION_REPLY_I2C_DEFER"); 699 + 814 700 aux_defer_retries = 0; 815 - if (++aux_i2c_defer_retries >= AUX_MAX_I2C_DEFER_RETRIES) 701 + if (++aux_i2c_defer_retries >= AUX_MAX_I2C_DEFER_RETRIES) { 702 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR, 703 + LOG_FLAG_Error_I2cAux, 704 + "dce_aux_transfer_with_retries: FAILURE: aux_i2c_defer_retries=%d >= AUX_MAX_I2C_DEFER_RETRIES=%d", 705 + aux_i2c_defer_retries, 706 + AUX_MAX_I2C_DEFER_RETRIES); 816 707 goto fail; 708 + } 817 709 break; 818 710 819 711 case AUX_TRANSACTION_REPLY_AUX_NACK: 712 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 713 + LOG_FLAG_I2cAux_DceAux, 714 + "dce_aux_transfer_with_retries: AUX_RET_SUCCESS: AUX_TRANSACTION_REPLY_AUX_NACK"); 715 + goto fail; 716 + 820 717 case AUX_TRANSACTION_REPLY_HPD_DISCON: 718 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 719 + LOG_FLAG_I2cAux_DceAux, 720 + "dce_aux_transfer_with_retries: AUX_RET_SUCCESS: AUX_TRANSACTION_REPLY_HPD_DISCON"); 721 + goto fail; 722 + 821 723 default: 724 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR, 725 + LOG_FLAG_Error_I2cAux, 726 + "dce_aux_transfer_with_retries: AUX_RET_SUCCESS: FAILURE: AUX_TRANSACTION_REPLY_* unknown, default case."); 822 727 goto fail; 823 728 } 824 729 break; 825 730 826 731 case AUX_RET_ERROR_INVALID_REPLY: 827 - if (++aux_invalid_reply_retries >= AUX_MAX_INVALID_REPLY_RETRIES) 732 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 733 + LOG_FLAG_I2cAux_DceAux, 734 + "dce_aux_transfer_with_retries: AUX_RET_ERROR_INVALID_REPLY"); 735 + if (++aux_invalid_reply_retries >= AUX_MAX_INVALID_REPLY_RETRIES) { 736 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR, 737 + LOG_FLAG_Error_I2cAux, 738 + "dce_aux_transfer_with_retries: FAILURE: aux_invalid_reply_retries=%d >= AUX_MAX_INVALID_REPLY_RETRIES=%d", 739 + aux_invalid_reply_retries, 740 + AUX_MAX_INVALID_REPLY_RETRIES); 828 741 goto fail; 829 - else 742 + } else 830 743 udelay(400); 831 744 break; 832 745 833 746 case AUX_RET_ERROR_TIMEOUT: 747 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 748 + LOG_FLAG_I2cAux_DceAux, 749 + "dce_aux_transfer_with_retries: AUX_RET_ERROR_TIMEOUT"); 834 750 // Check whether a DEFER had occurred before the timeout. 835 751 // If so, treat timeout as a DEFER. 836 752 if (retry_on_defer) { 837 - if (++aux_defer_retries >= AUX_MIN_DEFER_RETRIES) 753 + if (++aux_defer_retries >= AUX_MIN_DEFER_RETRIES) { 754 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR, 755 + LOG_FLAG_Error_I2cAux, 756 + "dce_aux_transfer_with_retries: FAILURE: aux_defer_retries=%d >= AUX_MIN_DEFER_RETRIES=%d", 757 + aux_defer_retries, 758 + AUX_MIN_DEFER_RETRIES); 838 759 goto fail; 839 - else if (payload->defer_delay > 0) 760 + } else if (payload->defer_delay > 0) { 761 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 762 + LOG_FLAG_I2cAux_DceAux, 763 + "dce_aux_transfer_with_retries: payload->defer_delay=%u", 764 + payload->defer_delay); 840 765 msleep(payload->defer_delay); 766 + } 841 767 } else { 842 - if (++aux_timeout_retries >= AUX_MAX_TIMEOUT_RETRIES) 768 + if (++aux_timeout_retries >= AUX_MAX_TIMEOUT_RETRIES) { 769 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR, 770 + LOG_FLAG_Error_I2cAux, 771 + "dce_aux_transfer_with_retries: FAILURE: aux_timeout_retries=%d >= AUX_MAX_TIMEOUT_RETRIES=%d", 772 + aux_timeout_retries, 773 + AUX_MAX_TIMEOUT_RETRIES); 843 774 goto fail; 844 - else { 775 + } else { 845 776 /* 846 777 * DP 1.4, 2.8.2: AUX Transaction Response/Reply Timeouts 847 778 * According to the DP spec there should be 3 retries total ··· 905 738 case AUX_RET_ERROR_ENGINE_ACQUIRE: 906 739 case AUX_RET_ERROR_UNKNOWN: 907 740 default: 741 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION, 742 + LOG_FLAG_I2cAux_DceAux, 743 + "dce_aux_transfer_with_retries: Failure: operation_result=%d", 744 + (int)operation_result); 908 745 goto fail; 909 746 } 910 747 } 911 748 912 749 fail: 750 + DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR, 751 + LOG_FLAG_Error_I2cAux, 752 + "dce_aux_transfer_with_retries: FAILURE"); 913 753 if (!payload_reply) 914 754 payload->reply = NULL; 915 755
+1 -1
drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
··· 29 29 #include "dmub/dmub_srv.h" 30 30 #include "core_types.h" 31 31 32 - #define DC_TRACE_LEVEL_MESSAGE(...) /* do nothing */ 32 + #define DC_TRACE_LEVEL_MESSAGE(...) do {} while (0) /* do nothing */ 33 33 34 34 #define MAX_PIPES 6 35 35
+5 -6
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
··· 3641 3641 struct dc_clock_config clock_cfg = {0}; 3642 3642 struct dc_clocks *current_clocks = &context->bw_ctx.bw.dcn.clk; 3643 3643 3644 - if (dc->clk_mgr && dc->clk_mgr->funcs->get_clock) 3645 - dc->clk_mgr->funcs->get_clock(dc->clk_mgr, 3646 - context, clock_type, &clock_cfg); 3647 - 3648 - if (!dc->clk_mgr->funcs->get_clock) 3644 + if (!dc->clk_mgr || !dc->clk_mgr->funcs->get_clock) 3649 3645 return DC_FAIL_UNSUPPORTED_1; 3646 + 3647 + dc->clk_mgr->funcs->get_clock(dc->clk_mgr, 3648 + context, clock_type, &clock_cfg); 3650 3649 3651 3650 if (clk_khz > clock_cfg.max_clock_khz) 3652 3651 return DC_FAIL_CLK_EXCEED_MAX; ··· 3664 3665 else 3665 3666 return DC_ERROR_UNEXPECTED; 3666 3667 3667 - if (dc->clk_mgr && dc->clk_mgr->funcs->update_clocks) 3668 + if (dc->clk_mgr->funcs->update_clocks) 3668 3669 dc->clk_mgr->funcs->update_clocks(dc->clk_mgr, 3669 3670 context, true); 3670 3671 return DC_OK;
+8 -6
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
··· 1723 1723 1724 1724 pipe = pipe->bottom_pipe; 1725 1725 } 1726 - /* Program secondary blending tree and writeback pipes */ 1727 - pipe = &context->res_ctx.pipe_ctx[i]; 1728 - if (!pipe->prev_odm_pipe && pipe->stream->num_wb_info > 0 1729 - && (pipe->update_flags.raw || pipe->plane_state->update_flags.raw || pipe->stream->update_flags.raw) 1730 - && hws->funcs.program_all_writeback_pipes_in_tree) 1731 - hws->funcs.program_all_writeback_pipes_in_tree(dc, pipe->stream, context); 1732 1726 } 1727 + /* Program secondary blending tree and writeback pipes */ 1728 + pipe = &context->res_ctx.pipe_ctx[i]; 1729 + if (!pipe->top_pipe && !pipe->prev_odm_pipe 1730 + && pipe->stream && pipe->stream->num_wb_info > 0 1731 + && (pipe->update_flags.raw || (pipe->plane_state && pipe->plane_state->update_flags.raw) 1732 + || pipe->stream->update_flags.raw) 1733 + && hws->funcs.program_all_writeback_pipes_in_tree) 1734 + hws->funcs.program_all_writeback_pipes_in_tree(dc, pipe->stream, context); 1733 1735 } 1734 1736 } 1735 1737
+64 -26
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c
··· 49 49 static void dwb3_get_reg_field_ogam(struct dcn30_dwbc *dwbc30, 50 50 struct dcn3_xfer_func_reg *reg) 51 51 { 52 + reg->shifts.field_region_start_base = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_BASE_B; 53 + reg->masks.field_region_start_base = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_BASE_B; 54 + reg->shifts.field_offset = dwbc30->dwbc_shift->DWB_OGAM_RAMA_OFFSET_B; 55 + reg->masks.field_offset = dwbc30->dwbc_mask->DWB_OGAM_RAMA_OFFSET_B; 56 + 52 57 reg->shifts.exp_region0_lut_offset = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION0_LUT_OFFSET; 53 58 reg->masks.exp_region0_lut_offset = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION0_LUT_OFFSET; 54 59 reg->shifts.exp_region0_num_segments = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION0_NUM_SEGMENTS; ··· 71 66 reg->masks.field_region_end_base = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_END_BASE_B; 72 67 reg->shifts.field_region_linear_slope = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_SLOPE_B; 73 68 reg->masks.field_region_linear_slope = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_SLOPE_B; 74 - reg->masks.field_offset = dwbc30->dwbc_mask->DWB_OGAM_RAMA_OFFSET_B; 75 - reg->shifts.field_offset = dwbc30->dwbc_shift->DWB_OGAM_RAMA_OFFSET_B; 76 69 reg->shifts.exp_region_start = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_B; 77 70 reg->masks.exp_region_start = dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_B; 78 71 reg->shifts.exp_resion_start_segment = dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_SEGMENT_B; ··· 150 147 uint32_t state_mode; 151 148 uint32_t ram_select; 152 149 153 - REG_GET(DWB_OGAM_CONTROL, 154 - DWB_OGAM_MODE, &state_mode); 155 - REG_GET(DWB_OGAM_CONTROL, 156 - DWB_OGAM_SELECT, &ram_select); 150 + REG_GET_2(DWB_OGAM_CONTROL, 151 + DWB_OGAM_MODE_CURRENT, &state_mode, 152 + DWB_OGAM_SELECT_CURRENT, &ram_select); 157 153 158 154 if (state_mode == 0) { 159 155 mode = LUT_BYPASS; 160 156 } else if (state_mode == 2) { 161 157 if (ram_select == 0) 162 158 mode = LUT_RAM_A; 163 - else 159 + else if (ram_select == 1) 164 160 mode = LUT_RAM_B; 161 + else 162 + mode = LUT_BYPASS; 165 163 } else { 166 164 // Reserved value 167 165 mode = LUT_BYPASS; ··· 176 172 struct dcn30_dwbc *dwbc30, 177 173 bool is_ram_a) 178 174 { 179 - REG_UPDATE(DWB_OGAM_LUT_CONTROL, 180 - DWB_OGAM_LUT_READ_COLOR_SEL, 7); 181 - REG_UPDATE(DWB_OGAM_CONTROL, 182 - DWB_OGAM_SELECT, is_ram_a == true ? 0 : 1); 175 + REG_UPDATE_2(DWB_OGAM_LUT_CONTROL, 176 + DWB_OGAM_LUT_WRITE_COLOR_MASK, 7, 177 + DWB_OGAM_LUT_HOST_SEL, (is_ram_a == true) ? 0 : 1); 178 + 183 179 REG_SET(DWB_OGAM_LUT_INDEX, 0, DWB_OGAM_LUT_INDEX, 0); 184 180 } 185 181 ··· 189 185 { 190 186 uint32_t i; 191 187 192 - // triple base implementation 193 - for (i = 0; i < num/2; i++) { 194 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+0].red_reg); 195 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+0].green_reg); 196 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+0].blue_reg); 197 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+1].red_reg); 198 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+1].green_reg); 199 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+1].blue_reg); 200 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+2].red_reg); 201 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+2].green_reg); 202 - REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[2*i+2].blue_reg); 188 + uint32_t last_base_value_red = rgb[num-1].red_reg + rgb[num-1].delta_red_reg; 189 + uint32_t last_base_value_green = rgb[num-1].green_reg + rgb[num-1].delta_green_reg; 190 + uint32_t last_base_value_blue = rgb[num-1].blue_reg + rgb[num-1].delta_blue_reg; 191 + 192 + if (is_rgb_equal(rgb, num)) { 193 + for (i = 0 ; i < num; i++) 194 + REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[i].red_reg); 195 + 196 + REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, last_base_value_red); 197 + 198 + } else { 199 + 200 + REG_UPDATE(DWB_OGAM_LUT_CONTROL, 201 + DWB_OGAM_LUT_WRITE_COLOR_MASK, 4); 202 + 203 + for (i = 0 ; i < num; i++) 204 + REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[i].red_reg); 205 + 206 + REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, last_base_value_red); 207 + 208 + REG_SET(DWB_OGAM_LUT_INDEX, 0, DWB_OGAM_LUT_INDEX, 0); 209 + 210 + REG_UPDATE(DWB_OGAM_LUT_CONTROL, 211 + DWB_OGAM_LUT_WRITE_COLOR_MASK, 2); 212 + 213 + for (i = 0 ; i < num; i++) 214 + REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[i].green_reg); 215 + 216 + REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, last_base_value_green); 217 + 218 + REG_SET(DWB_OGAM_LUT_INDEX, 0, DWB_OGAM_LUT_INDEX, 0); 219 + 220 + REG_UPDATE(DWB_OGAM_LUT_CONTROL, 221 + DWB_OGAM_LUT_WRITE_COLOR_MASK, 1); 222 + 223 + for (i = 0 ; i < num; i++) 224 + REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, rgb[i].blue_reg); 225 + 226 + REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, last_base_value_blue); 203 227 } 204 228 } 205 229 ··· 242 210 REG_SET(DWB_OGAM_CONTROL, 0, DWB_OGAM_MODE, 0); 243 211 return false; 244 212 } 213 + 214 + REG_SET(DWB_OGAM_CONTROL, 0, DWB_OGAM_MODE, 2); 245 215 246 216 current_mode = dwb3_get_ogam_current(dwbc30); 247 217 if (current_mode == LUT_BYPASS || current_mode == LUT_RAM_A) ··· 261 227 dwb3_program_ogam_pwl( 262 228 dwbc30, params->rgb_resulted, params->hw_points_num); 263 229 264 - REG_SET(DWB_OGAM_CONTROL, 0, DWB_OGAM_MODE, 2); 265 - REG_SET(DWB_OGAM_CONTROL, 0, DWB_OGAM_SELECT, next_mode == LUT_RAM_A ? 0 : 1); 230 + REG_UPDATE(DWB_OGAM_CONTROL, DWB_OGAM_SELECT, next_mode == LUT_RAM_A ? 0 : 1); 266 231 267 232 return true; 268 233 } ··· 304 271 305 272 struct color_matrices_reg gam_regs; 306 273 307 - REG_UPDATE(DWB_GAMUT_REMAP_COEF_FORMAT, DWB_GAMUT_REMAP_COEF_FORMAT, coef_format); 308 - 309 274 if (regval == NULL || select == CM_GAMUT_REMAP_MODE_BYPASS) { 310 275 REG_SET(DWB_GAMUT_REMAP_MODE, 0, 311 276 DWB_GAMUT_REMAP_MODE, 0); 312 277 return; 313 278 } 279 + 280 + REG_UPDATE(DWB_GAMUT_REMAP_COEF_FORMAT, DWB_GAMUT_REMAP_COEF_FORMAT, coef_format); 281 + 282 + gam_regs.shifts.csc_c11 = dwbc30->dwbc_shift->DWB_GAMUT_REMAPA_C11; 283 + gam_regs.masks.csc_c11 = dwbc30->dwbc_mask->DWB_GAMUT_REMAPA_C11; 284 + gam_regs.shifts.csc_c12 = dwbc30->dwbc_shift->DWB_GAMUT_REMAPA_C12; 285 + gam_regs.masks.csc_c12 = dwbc30->dwbc_mask->DWB_GAMUT_REMAPA_C12; 314 286 315 287 switch (select) { 316 288 case CM_GAMUT_REMAP_MODE_RAMA_COEFF:
+11 -1
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
··· 398 398 for (i_pipe = 0; i_pipe < dc->res_pool->pipe_count; i_pipe++) { 399 399 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i_pipe]; 400 400 401 + if (!pipe_ctx->plane_state) 402 + continue; 403 + 401 404 if (pipe_ctx->plane_state == wb_info.writeback_source_plane) { 402 405 wb_info.mpcc_inst = pipe_ctx->plane_res.mpcc_inst; 403 406 break; 404 407 } 405 408 } 406 - ASSERT(wb_info.mpcc_inst != -1); 409 + 410 + if (wb_info.mpcc_inst == -1) { 411 + /* Disable writeback pipe and disconnect from MPCC 412 + * if source plane has been removed 413 + */ 414 + dc->hwss.disable_writeback(dc, wb_info.dwb_pipe_inst); 415 + continue; 416 + } 407 417 408 418 ASSERT(wb_info.dwb_pipe_inst < dc->res_pool->res_cap->num_dwb); 409 419 dwb = dc->res_pool->dwbc[wb_info.dwb_pipe_inst];
-1
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
··· 1788 1788 } 1789 1789 pri_pipe->next_odm_pipe = sec_pipe; 1790 1790 sec_pipe->prev_odm_pipe = pri_pipe; 1791 - ASSERT(sec_pipe->top_pipe == NULL); 1792 1791 1793 1792 if (!sec_pipe->top_pipe) 1794 1793 sec_pipe->stream_res.opp = pool->opps[pipe_idx];
+1 -95
drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
··· 1622 1622 dml_init_instance(&dc->dml, &dcn3_01_soc, &dcn3_01_ip, DML_PROJECT_DCN30); 1623 1623 } 1624 1624 1625 - static void calculate_wm_set_for_vlevel( 1626 - int vlevel, 1627 - struct wm_range_table_entry *table_entry, 1628 - struct dcn_watermarks *wm_set, 1629 - struct display_mode_lib *dml, 1630 - display_e2e_pipe_params_st *pipes, 1631 - int pipe_cnt) 1632 - { 1633 - double dram_clock_change_latency_cached = dml->soc.dram_clock_change_latency_us; 1634 - 1635 - ASSERT(vlevel < dml->soc.num_states); 1636 - /* only pipe 0 is read for voltage and dcf/soc clocks */ 1637 - pipes[0].clks_cfg.voltage = vlevel; 1638 - pipes[0].clks_cfg.dcfclk_mhz = dml->soc.clock_limits[vlevel].dcfclk_mhz; 1639 - pipes[0].clks_cfg.socclk_mhz = dml->soc.clock_limits[vlevel].socclk_mhz; 1640 - 1641 - dml->soc.dram_clock_change_latency_us = table_entry->pstate_latency_us; 1642 - dml->soc.sr_exit_time_us = table_entry->sr_exit_time_us; 1643 - dml->soc.sr_enter_plus_exit_time_us = table_entry->sr_enter_plus_exit_time_us; 1644 - 1645 - wm_set->urgent_ns = get_wm_urgent(dml, pipes, pipe_cnt) * 1000; 1646 - wm_set->cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(dml, pipes, pipe_cnt) * 1000; 1647 - wm_set->cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(dml, pipes, pipe_cnt) * 1000; 1648 - wm_set->cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(dml, pipes, pipe_cnt) * 1000; 1649 - wm_set->pte_meta_urgent_ns = get_wm_memory_trip(dml, pipes, pipe_cnt) * 1000; 1650 - wm_set->frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(dml, pipes, pipe_cnt) * 1000; 1651 - wm_set->frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(dml, pipes, pipe_cnt) * 1000; 1652 - wm_set->urgent_latency_ns = get_urgent_latency(dml, pipes, pipe_cnt) * 1000; 1653 - dml->soc.dram_clock_change_latency_us = dram_clock_change_latency_cached; 1654 - 1655 - } 1656 - 1657 - static void dcn301_calculate_wm_and_dlg( 1658 - struct dc *dc, struct dc_state *context, 1659 - display_e2e_pipe_params_st *pipes, 1660 - int pipe_cnt, 1661 - int vlevel_req) 1662 - { 1663 - int i, pipe_idx; 1664 - int vlevel, vlevel_max; 1665 - struct wm_range_table_entry *table_entry; 1666 - struct clk_bw_params *bw_params = dc->clk_mgr->bw_params; 1667 - 1668 - ASSERT(bw_params); 1669 - 1670 - vlevel_max = bw_params->clk_table.num_entries - 1; 1671 - 1672 - /* WM Set D */ 1673 - table_entry = &bw_params->wm_table.entries[WM_D]; 1674 - if (table_entry->wm_type == WM_TYPE_RETRAINING) 1675 - vlevel = 0; 1676 - else 1677 - vlevel = vlevel_max; 1678 - calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.d, 1679 - &context->bw_ctx.dml, pipes, pipe_cnt); 1680 - /* WM Set C */ 1681 - table_entry = &bw_params->wm_table.entries[WM_C]; 1682 - vlevel = min(max(vlevel_req, 2), vlevel_max); 1683 - calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.c, 1684 - &context->bw_ctx.dml, pipes, pipe_cnt); 1685 - /* WM Set B */ 1686 - table_entry = &bw_params->wm_table.entries[WM_B]; 1687 - vlevel = min(max(vlevel_req, 1), vlevel_max); 1688 - calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.b, 1689 - &context->bw_ctx.dml, pipes, pipe_cnt); 1690 - 1691 - /* WM Set A */ 1692 - table_entry = &bw_params->wm_table.entries[WM_A]; 1693 - vlevel = min(vlevel_req, vlevel_max); 1694 - calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.a, 1695 - &context->bw_ctx.dml, pipes, pipe_cnt); 1696 - 1697 - for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) { 1698 - if (!context->res_ctx.pipe_ctx[i].stream) 1699 - continue; 1700 - 1701 - pipes[pipe_idx].clks_cfg.dispclk_mhz = get_dispclk_calculated(&context->bw_ctx.dml, pipes, pipe_cnt); 1702 - pipes[pipe_idx].clks_cfg.dppclk_mhz = get_dppclk_calculated(&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx); 1703 - 1704 - if (dc->config.forced_clocks) { 1705 - pipes[pipe_idx].clks_cfg.dispclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dispclk_mhz; 1706 - pipes[pipe_idx].clks_cfg.dppclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dppclk_mhz; 1707 - } 1708 - if (dc->debug.min_disp_clk_khz > pipes[pipe_idx].clks_cfg.dispclk_mhz * 1000) 1709 - pipes[pipe_idx].clks_cfg.dispclk_mhz = dc->debug.min_disp_clk_khz / 1000.0; 1710 - if (dc->debug.min_dpp_clk_khz > pipes[pipe_idx].clks_cfg.dppclk_mhz * 1000) 1711 - pipes[pipe_idx].clks_cfg.dppclk_mhz = dc->debug.min_dpp_clk_khz / 1000.0; 1712 - 1713 - pipe_idx++; 1714 - } 1715 - 1716 - dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel); 1717 - } 1718 - 1719 1625 static struct resource_funcs dcn301_res_pool_funcs = { 1720 1626 .destroy = dcn301_destroy_resource_pool, 1721 1627 .link_enc_create = dcn301_link_encoder_create, 1722 1628 .panel_cntl_create = dcn301_panel_cntl_create, 1723 1629 .validate_bandwidth = dcn30_validate_bandwidth, 1724 - .calculate_wm_and_dlg = dcn301_calculate_wm_and_dlg, 1630 + .calculate_wm_and_dlg = dcn30_calculate_wm_and_dlg, 1725 1631 .update_soc_for_wm_a = dcn30_update_soc_for_wm_a, 1726 1632 .populate_dml_pipes = dcn30_populate_dml_pipes_from_context, 1727 1633 .acquire_idle_pipe_for_layer = dcn20_acquire_idle_pipe_for_layer,
+12
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c
··· 407 407 &pipe_ctx->stream_res.encoder_info_frame); 408 408 } 409 409 } 410 + void dcn31_z10_save_init(struct dc *dc) 411 + { 412 + union dmub_rb_cmd cmd; 413 + 414 + memset(&cmd, 0, sizeof(cmd)); 415 + cmd.dcn_restore.header.type = DMUB_CMD__IDLE_OPT; 416 + cmd.dcn_restore.header.sub_type = DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT; 417 + 418 + dc_dmub_srv_cmd_queue(dc->ctx->dmub_srv, &cmd); 419 + dc_dmub_srv_cmd_execute(dc->ctx->dmub_srv); 420 + dc_dmub_srv_wait_idle(dc->ctx->dmub_srv); 421 + } 410 422 411 423 void dcn31_z10_restore(struct dc *dc) 412 424 {
+1
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.h
··· 44 44 void dcn31_update_info_frame(struct pipe_ctx *pipe_ctx); 45 45 46 46 void dcn31_z10_restore(struct dc *dc); 47 + void dcn31_z10_save_init(struct dc *dc); 47 48 48 49 void dcn31_hubp_pg_control(struct dce_hwseq *hws, unsigned int hubp_inst, bool power_on); 49 50 int dcn31_init_sys_ctx(struct dce_hwseq *hws, struct dc *dc, struct dc_phy_addr_space_config *pa_config);
+1
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c
··· 97 97 .set_abm_immediate_disable = dcn21_set_abm_immediate_disable, 98 98 .set_pipe = dcn21_set_pipe, 99 99 .z10_restore = dcn31_z10_restore, 100 + .z10_save_init = dcn31_z10_save_init, 100 101 .is_abm_supported = dcn31_is_abm_supported, 101 102 .set_disp_pattern_generator = dcn30_set_disp_pattern_generator, 102 103 .update_visual_confirm_color = dcn20_update_visual_confirm_color,
+1
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
··· 237 237 int width, int height, int offset); 238 238 239 239 void (*z10_restore)(struct dc *dc); 240 + void (*z10_save_init)(struct dc *dc); 240 241 241 242 void (*update_visual_confirm_color)(struct dc *dc, 242 243 struct pipe_ctx *pipe_ctx,
+18 -3
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
··· 47 47 48 48 /* Firmware versioning. */ 49 49 #ifdef DMUB_EXPOSE_VERSION 50 - #define DMUB_FW_VERSION_GIT_HASH 0x6d13d5e2c 50 + #define DMUB_FW_VERSION_GIT_HASH 0x7383caadc 51 51 #define DMUB_FW_VERSION_MAJOR 0 52 52 #define DMUB_FW_VERSION_MINOR 0 53 - #define DMUB_FW_VERSION_REVISION 77 53 + #define DMUB_FW_VERSION_REVISION 79 54 54 #define DMUB_FW_VERSION_TEST 0 55 55 #define DMUB_FW_VERSION_VBIOS 0 56 56 #define DMUB_FW_VERSION_HOTFIX 0 ··· 322 322 uint32_t mailbox_rdy : 1; /**< 1 if mailbox ready */ 323 323 uint32_t optimized_init_done : 1; /**< 1 if optimized init done */ 324 324 uint32_t restore_required : 1; /**< 1 if driver should call restore */ 325 + uint32_t defer_load : 1; /**< 1 if VBIOS data is deferred programmed */ 326 + uint32_t reserved : 1; 327 + uint32_t detection_required: 1; /**< if detection need to be triggered by driver */ 328 + 325 329 } bits; /**< status bits */ 326 330 uint32_t all; /**< 32-bit access to status bits */ 327 331 }; ··· 339 335 DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if init done */ 340 336 DMUB_FW_BOOT_STATUS_BIT_RESTORE_REQUIRED = (1 << 3), /**< 1 if driver should call restore */ 341 337 DMUB_FW_BOOT_STATUS_BIT_DEFERRED_LOADED = (1 << 4), /**< 1 if VBIOS data is deferred programmed */ 338 + DMUB_FW_BOOT_STATUS_BIT_DETECTION_REQUIRED = (1 << 6), /**< 1 if detection need to be triggered by driver*/ 342 339 }; 343 340 344 341 /* Register bit definition for SCRATCH5 */ ··· 494 489 * RETURN: PSR residency in milli-percent. 495 490 */ 496 491 DMUB_GPINT__PSR_RESIDENCY = 9, 492 + 493 + /** 494 + * DESC: Notifies DMCUB detection is done so detection required can be cleared. 495 + */ 496 + DMUB_GPINT__NOTIFY_DETECTION_DONE = 12, 497 497 }; 498 498 499 499 /** ··· 870 860 * DCN hardware restore. 871 861 */ 872 862 DMUB_CMD__IDLE_OPT_DCN_RESTORE = 0, 863 + 864 + /** 865 + * DCN hardware save. 866 + */ 867 + DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT = 1 873 868 }; 874 869 875 870 /** ··· 1453 1438 * 16-bit value dicated by driver that will enable/disable different functionality. 1454 1439 */ 1455 1440 uint16_t psr_level; 1456 - /** 1441 + /** 1457 1442 * PSR control version. 1458 1443 */ 1459 1444 uint8_t cmd_version;
+9 -9
drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
··· 83 83 void dmub_dcn31_reset(struct dmub_srv *dmub) 84 84 { 85 85 union dmub_gpint_data_register cmd; 86 - const uint32_t timeout = 30; 86 + const uint32_t timeout = 100; 87 87 uint32_t in_reset, scratch, i; 88 88 89 89 REG_GET(DMCUB_CNTL2, DMCUB_SOFT_RESET, &in_reset); ··· 98 98 /** 99 99 * Timeout covers both the ACK and the wait 100 100 * for remaining work to finish. 101 - * 102 - * This is mostly bound by the PHY disable sequence. 103 - * Each register check will be greater than 1us, so 104 - * don't bother using udelay. 105 101 */ 106 102 107 103 for (i = 0; i < timeout; ++i) { 108 104 if (dmub->hw_funcs.is_gpint_acked(dmub, cmd)) 109 105 break; 106 + 107 + udelay(1); 110 108 } 111 109 112 110 for (i = 0; i < timeout; ++i) { 113 111 scratch = dmub->hw_funcs.get_gpint_response(dmub); 114 112 if (scratch == DMUB_GPINT__STOP_FW_RESPONSE) 115 113 break; 116 - } 117 114 118 - /* Clear the GPINT command manually so we don't reset again. */ 119 - cmd.all = 0; 120 - dmub->hw_funcs.set_gpint(dmub, cmd); 115 + udelay(1); 116 + } 121 117 122 118 /* Force reset in case we timed out, DMCUB is likely hung. */ 123 119 } ··· 126 130 REG_WRITE(DMCUB_OUTBOX1_RPTR, 0); 127 131 REG_WRITE(DMCUB_OUTBOX1_WPTR, 0); 128 132 REG_WRITE(DMCUB_SCRATCH0, 0); 133 + 134 + /* Clear the GPINT command manually so we don't send anything during boot. */ 135 + cmd.all = 0; 136 + dmub->hw_funcs.set_gpint(dmub, cmd); 129 137 } 130 138 131 139 void dmub_dcn31_reset_release(struct dmub_srv *dmub)
+4 -1
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
··· 145 145 } else { 146 146 callback_in_ms(0, output); 147 147 set_state_id(hdcp, output, HDCP_CP_NOT_DESIRED); 148 + set_auth_complete(hdcp, output); 148 149 } 149 150 else if (is_hdmi_dvi_sl_hdcp(hdcp)) 150 151 if (is_cp_desired_hdcp2(hdcp)) { ··· 157 156 } else { 158 157 callback_in_ms(0, output); 159 158 set_state_id(hdcp, output, HDCP_CP_NOT_DESIRED); 159 + set_auth_complete(hdcp, output); 160 160 } 161 161 else { 162 162 callback_in_ms(0, output); 163 163 set_state_id(hdcp, output, HDCP_CP_NOT_DESIRED); 164 + set_auth_complete(hdcp, output); 164 165 } 165 166 } else if (is_in_cp_not_desired_state(hdcp)) { 166 167 increment_stay_counter(hdcp); ··· 523 520 524 521 /* reset authentication if needed */ 525 522 if (trans_status == MOD_HDCP_STATUS_RESET_NEEDED) { 526 - HDCP_FULL_DDC_TRACE(hdcp); 523 + mod_hdcp_log_ddc_trace(hdcp); 527 524 reset_status = reset_authentication(hdcp, output); 528 525 if (reset_status != MOD_HDCP_STATUS_SUCCESS) 529 526 push_error_status(hdcp, reset_status);
+8
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
··· 324 324 /* log functions */ 325 325 void mod_hdcp_dump_binary_message(uint8_t *msg, uint32_t msg_size, 326 326 uint8_t *buf, uint32_t buf_size); 327 + void mod_hdcp_log_ddc_trace(struct mod_hdcp *hdcp); 327 328 /* TODO: add adjustment log */ 328 329 329 330 /* psp functions */ ··· 493 492 { 494 493 output->watchdog_timer_needed = 1; 495 494 output->watchdog_timer_delay = time; 495 + } 496 + 497 + static inline void set_auth_complete(struct mod_hdcp *hdcp, 498 + struct mod_hdcp_output *output) 499 + { 500 + output->auth_complete = 1; 501 + mod_hdcp_log_ddc_trace(hdcp); 496 502 } 497 503 498 504 /* connection topology helpers */
+4 -4
drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_transition.c
··· 89 89 } else { 90 90 callback_in_ms(0, output); 91 91 set_state_id(hdcp, output, H1_A45_AUTHENTICATED); 92 - HDCP_FULL_DDC_TRACE(hdcp); 92 + set_auth_complete(hdcp, output); 93 93 } 94 94 break; 95 95 case H1_A45_AUTHENTICATED: ··· 137 137 } 138 138 callback_in_ms(0, output); 139 139 set_state_id(hdcp, output, H1_A45_AUTHENTICATED); 140 - HDCP_FULL_DDC_TRACE(hdcp); 140 + set_auth_complete(hdcp, output); 141 141 break; 142 142 default: 143 143 status = MOD_HDCP_STATUS_INVALID_STATE; ··· 239 239 set_state_id(hdcp, output, D1_A6_WAIT_FOR_READY); 240 240 } else { 241 241 set_state_id(hdcp, output, D1_A4_AUTHENTICATED); 242 - HDCP_FULL_DDC_TRACE(hdcp); 242 + set_auth_complete(hdcp, output); 243 243 } 244 244 break; 245 245 case D1_A4_AUTHENTICATED: ··· 311 311 break; 312 312 } 313 313 set_state_id(hdcp, output, D1_A4_AUTHENTICATED); 314 - HDCP_FULL_DDC_TRACE(hdcp); 314 + set_auth_complete(hdcp, output); 315 315 break; 316 316 default: 317 317 fail_and_restart_in_ms(0, &status, output);
+2 -2
drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_transition.c
··· 242 242 } 243 243 callback_in_ms(0, output); 244 244 set_state_id(hdcp, output, H2_A5_AUTHENTICATED); 245 - HDCP_FULL_DDC_TRACE(hdcp); 245 + set_auth_complete(hdcp, output); 246 246 break; 247 247 case H2_A5_AUTHENTICATED: 248 248 if (input->rxstatus_read == FAIL || ··· 559 559 break; 560 560 } 561 561 set_state_id(hdcp, output, D2_A5_AUTHENTICATED); 562 - HDCP_FULL_DDC_TRACE(hdcp); 562 + set_auth_complete(hdcp, output); 563 563 break; 564 564 case D2_A5_AUTHENTICATED: 565 565 if (input->rxstatus_read == FAIL ||
+74
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.c
··· 51 51 } 52 52 } 53 53 54 + void mod_hdcp_log_ddc_trace(struct mod_hdcp *hdcp) 55 + { 56 + if (is_hdcp1(hdcp)) { 57 + HDCP_DDC_READ_TRACE(hdcp, "BKSV", hdcp->auth.msg.hdcp1.bksv, 58 + sizeof(hdcp->auth.msg.hdcp1.bksv)); 59 + HDCP_DDC_READ_TRACE(hdcp, "BCAPS", &hdcp->auth.msg.hdcp1.bcaps, 60 + sizeof(hdcp->auth.msg.hdcp1.bcaps)); 61 + HDCP_DDC_READ_TRACE(hdcp, "BSTATUS", 62 + (uint8_t *)&hdcp->auth.msg.hdcp1.bstatus, 63 + sizeof(hdcp->auth.msg.hdcp1.bstatus)); 64 + HDCP_DDC_WRITE_TRACE(hdcp, "AN", hdcp->auth.msg.hdcp1.an, 65 + sizeof(hdcp->auth.msg.hdcp1.an)); 66 + HDCP_DDC_WRITE_TRACE(hdcp, "AKSV", hdcp->auth.msg.hdcp1.aksv, 67 + sizeof(hdcp->auth.msg.hdcp1.aksv)); 68 + HDCP_DDC_WRITE_TRACE(hdcp, "AINFO", &hdcp->auth.msg.hdcp1.ainfo, 69 + sizeof(hdcp->auth.msg.hdcp1.ainfo)); 70 + HDCP_DDC_READ_TRACE(hdcp, "RI' / R0'", 71 + (uint8_t *)&hdcp->auth.msg.hdcp1.r0p, 72 + sizeof(hdcp->auth.msg.hdcp1.r0p)); 73 + HDCP_DDC_READ_TRACE(hdcp, "BINFO", 74 + (uint8_t *)&hdcp->auth.msg.hdcp1.binfo_dp, 75 + sizeof(hdcp->auth.msg.hdcp1.binfo_dp)); 76 + HDCP_DDC_READ_TRACE(hdcp, "KSVLIST", hdcp->auth.msg.hdcp1.ksvlist, 77 + hdcp->auth.msg.hdcp1.ksvlist_size); 78 + HDCP_DDC_READ_TRACE(hdcp, "V'", hdcp->auth.msg.hdcp1.vp, 79 + sizeof(hdcp->auth.msg.hdcp1.vp)); 80 + } else if (is_hdcp2(hdcp)) { 81 + HDCP_DDC_READ_TRACE(hdcp, "HDCP2Version", 82 + &hdcp->auth.msg.hdcp2.hdcp2version_hdmi, 83 + sizeof(hdcp->auth.msg.hdcp2.hdcp2version_hdmi)); 84 + HDCP_DDC_READ_TRACE(hdcp, "Rx Caps", hdcp->auth.msg.hdcp2.rxcaps_dp, 85 + sizeof(hdcp->auth.msg.hdcp2.rxcaps_dp)); 86 + HDCP_DDC_WRITE_TRACE(hdcp, "AKE Init", hdcp->auth.msg.hdcp2.ake_init, 87 + sizeof(hdcp->auth.msg.hdcp2.ake_init)); 88 + HDCP_DDC_READ_TRACE(hdcp, "AKE Cert", hdcp->auth.msg.hdcp2.ake_cert, 89 + sizeof(hdcp->auth.msg.hdcp2.ake_cert)); 90 + HDCP_DDC_WRITE_TRACE(hdcp, "Stored KM", 91 + hdcp->auth.msg.hdcp2.ake_stored_km, 92 + sizeof(hdcp->auth.msg.hdcp2.ake_stored_km)); 93 + HDCP_DDC_WRITE_TRACE(hdcp, "No Stored KM", 94 + hdcp->auth.msg.hdcp2.ake_no_stored_km, 95 + sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km)); 96 + HDCP_DDC_READ_TRACE(hdcp, "H'", hdcp->auth.msg.hdcp2.ake_h_prime, 97 + sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)); 98 + HDCP_DDC_READ_TRACE(hdcp, "Pairing Info", 99 + hdcp->auth.msg.hdcp2.ake_pairing_info, 100 + sizeof(hdcp->auth.msg.hdcp2.ake_pairing_info)); 101 + HDCP_DDC_WRITE_TRACE(hdcp, "LC Init", hdcp->auth.msg.hdcp2.lc_init, 102 + sizeof(hdcp->auth.msg.hdcp2.lc_init)); 103 + HDCP_DDC_READ_TRACE(hdcp, "L'", hdcp->auth.msg.hdcp2.lc_l_prime, 104 + sizeof(hdcp->auth.msg.hdcp2.lc_l_prime)); 105 + HDCP_DDC_WRITE_TRACE(hdcp, "Exchange KS", hdcp->auth.msg.hdcp2.ske_eks, 106 + sizeof(hdcp->auth.msg.hdcp2.ske_eks)); 107 + HDCP_DDC_READ_TRACE(hdcp, "Rx Status", 108 + (uint8_t *)&hdcp->auth.msg.hdcp2.rxstatus, 109 + sizeof(hdcp->auth.msg.hdcp2.rxstatus)); 110 + HDCP_DDC_READ_TRACE(hdcp, "Rx Id List", 111 + hdcp->auth.msg.hdcp2.rx_id_list, 112 + hdcp->auth.msg.hdcp2.rx_id_list_size); 113 + HDCP_DDC_WRITE_TRACE(hdcp, "Rx Id List Ack", 114 + hdcp->auth.msg.hdcp2.repeater_auth_ack, 115 + sizeof(hdcp->auth.msg.hdcp2.repeater_auth_ack)); 116 + HDCP_DDC_WRITE_TRACE(hdcp, "Content Stream Management", 117 + hdcp->auth.msg.hdcp2.repeater_auth_stream_manage, 118 + hdcp->auth.msg.hdcp2.stream_manage_size); 119 + HDCP_DDC_READ_TRACE(hdcp, "Stream Ready", 120 + hdcp->auth.msg.hdcp2.repeater_auth_stream_ready, 121 + sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready)); 122 + HDCP_DDC_WRITE_TRACE(hdcp, "Content Stream Type", 123 + hdcp->auth.msg.hdcp2.content_stream_type_dp, 124 + sizeof(hdcp->auth.msg.hdcp2.content_stream_type_dp)); 125 + } 126 + } 127 + 54 128 char *mod_hdcp_status_to_str(int32_t status) 55 129 { 56 130 switch (status) {
-72
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.h
··· 106 106 hdcp->config.index, msg_name,\ 107 107 hdcp->buf); \ 108 108 } while (0) 109 - #define HDCP_FULL_DDC_TRACE(hdcp) do { \ 110 - if (is_hdcp1(hdcp)) { \ 111 - HDCP_DDC_READ_TRACE(hdcp, "BKSV", hdcp->auth.msg.hdcp1.bksv, \ 112 - sizeof(hdcp->auth.msg.hdcp1.bksv)); \ 113 - HDCP_DDC_READ_TRACE(hdcp, "BCAPS", &hdcp->auth.msg.hdcp1.bcaps, \ 114 - sizeof(hdcp->auth.msg.hdcp1.bcaps)); \ 115 - HDCP_DDC_READ_TRACE(hdcp, "BSTATUS", \ 116 - (uint8_t *)&hdcp->auth.msg.hdcp1.bstatus, \ 117 - sizeof(hdcp->auth.msg.hdcp1.bstatus)); \ 118 - HDCP_DDC_WRITE_TRACE(hdcp, "AN", hdcp->auth.msg.hdcp1.an, \ 119 - sizeof(hdcp->auth.msg.hdcp1.an)); \ 120 - HDCP_DDC_WRITE_TRACE(hdcp, "AKSV", hdcp->auth.msg.hdcp1.aksv, \ 121 - sizeof(hdcp->auth.msg.hdcp1.aksv)); \ 122 - HDCP_DDC_WRITE_TRACE(hdcp, "AINFO", &hdcp->auth.msg.hdcp1.ainfo, \ 123 - sizeof(hdcp->auth.msg.hdcp1.ainfo)); \ 124 - HDCP_DDC_READ_TRACE(hdcp, "RI' / R0'", \ 125 - (uint8_t *)&hdcp->auth.msg.hdcp1.r0p, \ 126 - sizeof(hdcp->auth.msg.hdcp1.r0p)); \ 127 - HDCP_DDC_READ_TRACE(hdcp, "BINFO", \ 128 - (uint8_t *)&hdcp->auth.msg.hdcp1.binfo_dp, \ 129 - sizeof(hdcp->auth.msg.hdcp1.binfo_dp)); \ 130 - HDCP_DDC_READ_TRACE(hdcp, "KSVLIST", hdcp->auth.msg.hdcp1.ksvlist, \ 131 - hdcp->auth.msg.hdcp1.ksvlist_size); \ 132 - HDCP_DDC_READ_TRACE(hdcp, "V'", hdcp->auth.msg.hdcp1.vp, \ 133 - sizeof(hdcp->auth.msg.hdcp1.vp)); \ 134 - } else { \ 135 - HDCP_DDC_READ_TRACE(hdcp, "HDCP2Version", \ 136 - &hdcp->auth.msg.hdcp2.hdcp2version_hdmi, \ 137 - sizeof(hdcp->auth.msg.hdcp2.hdcp2version_hdmi)); \ 138 - HDCP_DDC_READ_TRACE(hdcp, "Rx Caps", hdcp->auth.msg.hdcp2.rxcaps_dp, \ 139 - sizeof(hdcp->auth.msg.hdcp2.rxcaps_dp)); \ 140 - HDCP_DDC_WRITE_TRACE(hdcp, "AKE Init", hdcp->auth.msg.hdcp2.ake_init, \ 141 - sizeof(hdcp->auth.msg.hdcp2.ake_init)); \ 142 - HDCP_DDC_READ_TRACE(hdcp, "AKE Cert", hdcp->auth.msg.hdcp2.ake_cert, \ 143 - sizeof(hdcp->auth.msg.hdcp2.ake_cert)); \ 144 - HDCP_DDC_WRITE_TRACE(hdcp, "Stored KM", \ 145 - hdcp->auth.msg.hdcp2.ake_stored_km, \ 146 - sizeof(hdcp->auth.msg.hdcp2.ake_stored_km)); \ 147 - HDCP_DDC_WRITE_TRACE(hdcp, "No Stored KM", \ 148 - hdcp->auth.msg.hdcp2.ake_no_stored_km, \ 149 - sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km)); \ 150 - HDCP_DDC_READ_TRACE(hdcp, "H'", hdcp->auth.msg.hdcp2.ake_h_prime, \ 151 - sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)); \ 152 - HDCP_DDC_READ_TRACE(hdcp, "Pairing Info", \ 153 - hdcp->auth.msg.hdcp2.ake_pairing_info, \ 154 - sizeof(hdcp->auth.msg.hdcp2.ake_pairing_info)); \ 155 - HDCP_DDC_WRITE_TRACE(hdcp, "LC Init", hdcp->auth.msg.hdcp2.lc_init, \ 156 - sizeof(hdcp->auth.msg.hdcp2.lc_init)); \ 157 - HDCP_DDC_READ_TRACE(hdcp, "L'", hdcp->auth.msg.hdcp2.lc_l_prime, \ 158 - sizeof(hdcp->auth.msg.hdcp2.lc_l_prime)); \ 159 - HDCP_DDC_WRITE_TRACE(hdcp, "Exchange KS", hdcp->auth.msg.hdcp2.ske_eks, \ 160 - sizeof(hdcp->auth.msg.hdcp2.ske_eks)); \ 161 - HDCP_DDC_READ_TRACE(hdcp, "Rx Status", \ 162 - (uint8_t *)&hdcp->auth.msg.hdcp2.rxstatus, \ 163 - sizeof(hdcp->auth.msg.hdcp2.rxstatus)); \ 164 - HDCP_DDC_READ_TRACE(hdcp, "Rx Id List", \ 165 - hdcp->auth.msg.hdcp2.rx_id_list, \ 166 - hdcp->auth.msg.hdcp2.rx_id_list_size); \ 167 - HDCP_DDC_WRITE_TRACE(hdcp, "Rx Id List Ack", \ 168 - hdcp->auth.msg.hdcp2.repeater_auth_ack, \ 169 - sizeof(hdcp->auth.msg.hdcp2.repeater_auth_ack)); \ 170 - HDCP_DDC_WRITE_TRACE(hdcp, "Content Stream Management", \ 171 - hdcp->auth.msg.hdcp2.repeater_auth_stream_manage, \ 172 - hdcp->auth.msg.hdcp2.stream_manage_size); \ 173 - HDCP_DDC_READ_TRACE(hdcp, "Stream Ready", \ 174 - hdcp->auth.msg.hdcp2.repeater_auth_stream_ready, \ 175 - sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready)); \ 176 - HDCP_DDC_WRITE_TRACE(hdcp, "Content Stream Type", \ 177 - hdcp->auth.msg.hdcp2.content_stream_type_dp, \ 178 - sizeof(hdcp->auth.msg.hdcp2.content_stream_type_dp)); \ 179 - } \ 180 - } while (0) 181 109 #define HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, i) \ 182 110 HDCP_LOG_TOP(hdcp, "[Link %d]\tadd display %d", \ 183 111 hdcp->config.index, i)
+28 -28
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
··· 54 54 get_active_display_at_index(hdcp, index); 55 55 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 56 56 57 - dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 57 + dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.context.mem_context.shared_buf; 58 58 59 59 if (!display || !is_display_active(display)) 60 60 return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; ··· 90 90 get_active_display_at_index(hdcp, index); 91 91 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 92 92 93 - dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 93 + dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.context.mem_context.shared_buf; 94 94 95 95 if (!display || !is_display_active(display)) 96 96 return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; ··· 128 128 struct mod_hdcp_link *link = &hdcp->connection.link; 129 129 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 130 130 131 - if (!psp->dtm_context.dtm_initialized) { 131 + if (!psp->dtm_context.context.initialized) { 132 132 DRM_INFO("Failed to add display topology, DTM TA is not initialized."); 133 133 display->state = MOD_HDCP_DISPLAY_INACTIVE; 134 134 return MOD_HDCP_STATUS_FAILURE; 135 135 } 136 136 137 - dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 137 + dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.context.mem_context.shared_buf; 138 138 139 139 mutex_lock(&psp->dtm_context.mutex); 140 140 memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory)); ··· 175 175 struct mod_hdcp_link *link = &hdcp->connection.link; 176 176 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 177 177 178 - if (!psp->dtm_context.dtm_initialized) { 178 + if (!psp->dtm_context.context.initialized) { 179 179 DRM_INFO("Failed to add display topology, DTM TA is not initialized."); 180 180 display->state = MOD_HDCP_DISPLAY_INACTIVE; 181 181 return MOD_HDCP_STATUS_FAILURE; 182 182 } 183 183 184 - dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 184 + dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.context.mem_context.shared_buf; 185 185 186 186 mutex_lock(&psp->dtm_context.mutex); 187 187 memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory)); ··· 253 253 struct ta_hdcp_shared_memory *hdcp_cmd; 254 254 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 255 255 256 - if (!psp->hdcp_context.hdcp_initialized) { 256 + if (!psp->hdcp_context.context.initialized) { 257 257 DRM_ERROR("Failed to create hdcp session. HDCP TA is not initialized."); 258 258 return MOD_HDCP_STATUS_FAILURE; 259 259 } 260 260 261 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 261 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 262 262 263 263 mutex_lock(&psp->hdcp_context.mutex); 264 264 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); ··· 293 293 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 294 294 295 295 mutex_lock(&psp->hdcp_context.mutex); 296 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 296 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 297 297 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 298 298 299 299 hdcp_cmd->in_msg.hdcp1_destroy_session.session_handle = hdcp->auth.id; ··· 325 325 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 326 326 327 327 mutex_lock(&psp->hdcp_context.mutex); 328 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 328 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 329 329 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 330 330 331 331 hdcp_cmd->in_msg.hdcp1_first_part_authentication.session_handle = hdcp->auth.id; ··· 367 367 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 368 368 369 369 mutex_lock(&psp->hdcp_context.mutex); 370 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 370 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 371 371 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 372 372 373 373 hdcp_cmd->in_msg.hdcp1_enable_encryption.session_handle = hdcp->auth.id; ··· 393 393 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 394 394 395 395 mutex_lock(&psp->hdcp_context.mutex); 396 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 396 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 397 397 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 398 398 399 399 hdcp_cmd->in_msg.hdcp1_second_part_authentication.session_handle = hdcp->auth.id; ··· 436 436 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 437 437 438 438 mutex_lock(&psp->hdcp_context.mutex); 439 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 439 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 440 440 441 441 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { 442 442 ··· 471 471 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 472 472 473 473 mutex_lock(&psp->hdcp_context.mutex); 474 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 474 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 475 475 476 476 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 477 477 ··· 498 498 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 499 499 500 500 501 - if (!psp->hdcp_context.hdcp_initialized) { 501 + if (!psp->hdcp_context.context.initialized) { 502 502 DRM_ERROR("Failed to create hdcp session, HDCP TA is not initialized"); 503 503 return MOD_HDCP_STATUS_FAILURE; 504 504 } ··· 508 508 509 509 mutex_lock(&psp->hdcp_context.mutex); 510 510 511 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 511 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 512 512 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 513 513 514 514 hdcp_cmd->in_msg.hdcp2_create_session_v2.display_handle = display->index; ··· 545 545 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 546 546 547 547 mutex_lock(&psp->hdcp_context.mutex); 548 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 548 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 549 549 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 550 550 551 551 hdcp_cmd->in_msg.hdcp2_destroy_session.session_handle = hdcp->auth.id; ··· 579 579 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 580 580 581 581 mutex_lock(&psp->hdcp_context.mutex); 582 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 582 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 583 583 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 584 584 585 585 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 611 611 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 612 612 613 613 mutex_lock(&psp->hdcp_context.mutex); 614 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 614 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 615 615 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 616 616 617 617 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 671 671 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 672 672 673 673 mutex_lock(&psp->hdcp_context.mutex); 674 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 674 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 675 675 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 676 676 677 677 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 717 717 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 718 718 719 719 mutex_lock(&psp->hdcp_context.mutex); 720 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 720 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 721 721 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 722 722 723 723 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 750 750 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 751 751 752 752 mutex_lock(&psp->hdcp_context.mutex); 753 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 753 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 754 754 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 755 755 756 756 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 785 785 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 786 786 787 787 mutex_lock(&psp->hdcp_context.mutex); 788 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 788 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 789 789 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 790 790 791 791 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 833 833 834 834 mutex_lock(&psp->hdcp_context.mutex); 835 835 836 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 836 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 837 837 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 838 838 839 839 hdcp_cmd->in_msg.hdcp2_set_encryption.session_handle = hdcp->auth.id; ··· 862 862 863 863 mutex_lock(&psp->hdcp_context.mutex); 864 864 865 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 865 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 866 866 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 867 867 868 868 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 914 914 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 915 915 916 916 mutex_lock(&psp->hdcp_context.mutex); 917 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 917 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 918 918 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 919 919 920 920 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 958 958 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 959 959 960 960 mutex_lock(&psp->hdcp_context.mutex); 961 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 961 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 962 962 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 963 963 964 964 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; ··· 994 994 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 995 995 996 996 mutex_lock(&psp->hdcp_context.mutex); 997 - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 997 + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; 998 998 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 999 999 1000 1000 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2;
+1
drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h
··· 225 225 uint8_t watchdog_timer_stop; 226 226 uint16_t callback_delay; 227 227 uint16_t watchdog_timer_delay; 228 + uint8_t auth_complete; 228 229 }; 229 230 230 231 /* used to represent per display info */
+6
drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_offset.h
··· 38 38 #define mmCG_TACH_CTRL 0x006a 39 39 #define mmCG_TACH_CTRL_BASE_IDX 0 40 40 41 + #define mmCG_TACH_STATUS 0x006b 42 + #define mmCG_TACH_STATUS_BASE_IDX 0 43 + 41 44 #define mmTHM_THERMAL_INT_ENA 0x000a 42 45 #define mmTHM_THERMAL_INT_ENA_BASE_IDX 0 43 46 #define mmTHM_THERMAL_INT_CTRL 0x000b ··· 51 48 52 49 #define mmTHM_BACO_CNTL 0x0081 53 50 #define mmTHM_BACO_CNTL_BASE_IDX 0 51 + 52 + #define mmCG_THERMAL_STATUS 0x006C 53 + #define mmCG_THERMAL_STATUS_BASE_IDX 0 54 54 55 55 #endif
+3
drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_sh_mask.h
··· 92 92 #define THM_TCON_THERM_TRIP__RSVD3_MASK 0x7FFFC000L 93 93 #define THM_TCON_THERM_TRIP__SW_THERM_TP_MASK 0x80000000L 94 94 95 + #define CG_THERMAL_STATUS__FDO_PWM_DUTY__SHIFT 0x9 96 + #define CG_THERMAL_STATUS__FDO_PWM_DUTY_MASK 0x0001FE00L 97 + 95 98 #endif 96 99
+3
drivers/gpu/drm/amd/include/kgd_kfd_interface.h
··· 44 44 enum kfd_preempt_type { 45 45 KFD_PREEMPT_TYPE_WAVEFRONT_DRAIN = 0, 46 46 KFD_PREEMPT_TYPE_WAVEFRONT_RESET, 47 + KFD_PREEMPT_TYPE_WAVEFRONT_SAVE 47 48 }; 48 49 49 50 struct kfd_vm_fault_info { ··· 299 298 300 299 void (*get_cu_occupancy)(struct kgd_dev *kgd, int pasid, int *wave_cnt, 301 300 int *max_waves_per_cu); 301 + void (*program_trap_handler_settings)(struct kgd_dev *kgd, 302 + uint32_t vmid, uint64_t tba_addr, uint64_t tma_addr); 302 303 }; 303 304 304 305 #endif /* KGD_KFD_INTERFACE_H_INCLUDED */
+2 -2
drivers/gpu/drm/amd/include/kgd_pp_interface.h
··· 306 306 /* export for sysfs */ 307 307 void (*set_fan_control_mode)(void *handle, u32 mode); 308 308 u32 (*get_fan_control_mode)(void *handle); 309 - int (*set_fan_speed_percent)(void *handle, u32 speed); 310 - int (*get_fan_speed_percent)(void *handle, u32 *speed); 309 + int (*set_fan_speed_pwm)(void *handle, u32 speed); 310 + int (*get_fan_speed_pwm)(void *handle, u32 *speed); 311 311 int (*force_clock_level)(void *handle, enum pp_clock_type type, uint32_t mask); 312 312 int (*print_clock_levels)(void *handle, enum pp_clock_type type, char *buf); 313 313 int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level);
+26 -22
drivers/gpu/drm/amd/pm/amdgpu_pm.c
··· 2094 2094 *states = ATTR_STATE_UNSUPPORTED; 2095 2095 } 2096 2096 2097 - if (asic_type == CHIP_ARCTURUS) { 2098 - /* Arcturus does not support standalone mclk/socclk/fclk level setting */ 2097 + switch (asic_type) { 2098 + case CHIP_ARCTURUS: 2099 + case CHIP_ALDEBARAN: 2100 + /* the Mi series card does not support standalone mclk/socclk/fclk level setting */ 2099 2101 if (DEVICE_ATTR_IS(pp_dpm_mclk) || 2100 2102 DEVICE_ATTR_IS(pp_dpm_socclk) || 2101 2103 DEVICE_ATTR_IS(pp_dpm_fclk)) { 2102 2104 dev_attr->attr.mode &= ~S_IWUGO; 2103 2105 dev_attr->store = NULL; 2104 2106 } 2107 + break; 2108 + default: 2109 + break; 2105 2110 } 2106 2111 2107 2112 if (DEVICE_ATTR_IS(pp_dpm_dcefclk)) { ··· 2384 2379 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); 2385 2380 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); 2386 2381 2387 - return sprintf(buf, "%u\n", pwm_mode); 2382 + return sysfs_emit(buf, "%u\n", pwm_mode); 2388 2383 } 2389 2384 2390 2385 static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev, ··· 2429 2424 struct device_attribute *attr, 2430 2425 char *buf) 2431 2426 { 2432 - return sprintf(buf, "%i\n", 0); 2427 + return sysfs_emit(buf, "%i\n", 0); 2433 2428 } 2434 2429 2435 2430 static ssize_t amdgpu_hwmon_get_pwm1_max(struct device *dev, 2436 2431 struct device_attribute *attr, 2437 2432 char *buf) 2438 2433 { 2439 - return sprintf(buf, "%i\n", 255); 2434 + return sysfs_emit(buf, "%i\n", 255); 2440 2435 } 2441 2436 2442 2437 static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev, ··· 2474 2469 return err; 2475 2470 } 2476 2471 2477 - value = (value * 100) / 255; 2478 - 2479 - if (adev->powerplay.pp_funcs->set_fan_speed_percent) 2480 - err = amdgpu_dpm_set_fan_speed_percent(adev, value); 2472 + if (adev->powerplay.pp_funcs->set_fan_speed_pwm) 2473 + err = amdgpu_dpm_set_fan_speed_pwm(adev, value); 2481 2474 else 2482 2475 err = -EINVAL; 2483 2476 ··· 2507 2504 return err; 2508 2505 } 2509 2506 2510 - if (adev->powerplay.pp_funcs->get_fan_speed_percent) 2511 - err = amdgpu_dpm_get_fan_speed_percent(adev, &speed); 2507 + if (adev->powerplay.pp_funcs->get_fan_speed_pwm) 2508 + err = amdgpu_dpm_get_fan_speed_pwm(adev, &speed); 2512 2509 else 2513 2510 err = -EINVAL; 2514 2511 ··· 2518 2515 if (err) 2519 2516 return err; 2520 2517 2521 - speed = (speed * 255) / 100; 2522 - 2523 - return sprintf(buf, "%i\n", speed); 2518 + return sysfs_emit(buf, "%i\n", speed); 2524 2519 } 2525 2520 2526 2521 static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev, ··· 2551 2550 if (err) 2552 2551 return err; 2553 2552 2554 - return sprintf(buf, "%i\n", speed); 2553 + return sysfs_emit(buf, "%i\n", speed); 2555 2554 } 2556 2555 2557 2556 static ssize_t amdgpu_hwmon_get_fan1_min(struct device *dev, ··· 2648 2647 if (err) 2649 2648 return err; 2650 2649 2651 - return sprintf(buf, "%i\n", rpm); 2650 + return sysfs_emit(buf, "%i\n", rpm); 2652 2651 } 2653 2652 2654 2653 static ssize_t amdgpu_hwmon_set_fan1_target(struct device *dev, ··· 2730 2729 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); 2731 2730 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); 2732 2731 2733 - return sprintf(buf, "%i\n", pwm_mode == AMD_FAN_CTRL_AUTO ? 0 : 1); 2732 + return sysfs_emit(buf, "%i\n", pwm_mode == AMD_FAN_CTRL_AUTO ? 0 : 1); 2734 2733 } 2735 2734 2736 2735 static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev, ··· 2900 2899 struct device_attribute *attr, 2901 2900 char *buf) 2902 2901 { 2903 - return sprintf(buf, "%i\n", 0); 2902 + return sysfs_emit(buf, "%i\n", 0); 2904 2903 } 2905 2904 2906 2905 ··· 3175 3174 * 3176 3175 * - fan[1-\*]_enable: Enable or disable the sensors.1: Enable 0: Disable 3177 3176 * 3177 + * NOTE: DO NOT set the fan speed via "pwm1" and "fan[1-\*]_target" interfaces at the same time. 3178 + * That will get the former one overridden. 3179 + * 3178 3180 * hwmon interfaces for GPU clocks: 3179 3181 * 3180 3182 * - freq1_input: the gfx/compute clock in hertz ··· 3353 3349 3354 3350 if (!is_support_sw_smu(adev)) { 3355 3351 /* mask fan attributes if we have no bindings for this asic to expose */ 3356 - if ((!adev->powerplay.pp_funcs->get_fan_speed_percent && 3352 + if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm && 3357 3353 attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */ 3358 3354 (!adev->powerplay.pp_funcs->get_fan_control_mode && 3359 3355 attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't query state */ 3360 3356 effective_mode &= ~S_IRUGO; 3361 3357 3362 - if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && 3358 + if ((!adev->powerplay.pp_funcs->set_fan_speed_pwm && 3363 3359 attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't manage fan */ 3364 3360 (!adev->powerplay.pp_funcs->set_fan_control_mode && 3365 3361 attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't manage state */ ··· 3383 3379 3384 3380 if (!is_support_sw_smu(adev)) { 3385 3381 /* hide max/min values if we can't both query and manage the fan */ 3386 - if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && 3387 - !adev->powerplay.pp_funcs->get_fan_speed_percent) && 3382 + if ((!adev->powerplay.pp_funcs->set_fan_speed_pwm && 3383 + !adev->powerplay.pp_funcs->get_fan_speed_pwm) && 3388 3384 (!adev->powerplay.pp_funcs->set_fan_speed_rpm && 3389 3385 !adev->powerplay.pp_funcs->get_fan_speed_rpm) && 3390 3386 (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
+4 -4
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h
··· 280 280 #define amdgpu_dpm_get_fan_control_mode(adev) \ 281 281 ((adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle)) 282 282 283 - #define amdgpu_dpm_set_fan_speed_percent(adev, s) \ 284 - ((adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s))) 283 + #define amdgpu_dpm_set_fan_speed_pwm(adev, s) \ 284 + ((adev)->powerplay.pp_funcs->set_fan_speed_pwm((adev)->powerplay.pp_handle, (s))) 285 285 286 - #define amdgpu_dpm_get_fan_speed_percent(adev, s) \ 287 - ((adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s))) 286 + #define amdgpu_dpm_get_fan_speed_pwm(adev, s) \ 287 + ((adev)->powerplay.pp_funcs->get_fan_speed_pwm((adev)->powerplay.pp_handle, (s))) 288 288 289 289 #define amdgpu_dpm_get_fan_speed_rpm(adev, s) \ 290 290 ((adev)->powerplay.pp_funcs->get_fan_speed_rpm)((adev)->powerplay.pp_handle, (s))
+19 -6
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
··· 34 34 #define SMU_FW_NAME_LEN 0x24 35 35 36 36 #define SMU_DPM_USER_PROFILE_RESTORE (1 << 0) 37 + #define SMU_CUSTOM_FAN_SPEED_RPM (1 << 1) 38 + #define SMU_CUSTOM_FAN_SPEED_PWM (1 << 2) 37 39 38 40 // Power Throttlers 39 41 #define SMU_THROTTLER_PPT0_BIT 0 ··· 231 229 struct smu_user_dpm_profile { 232 230 uint32_t fan_mode; 233 231 uint32_t power_limit; 234 - uint32_t fan_speed_percent; 232 + uint32_t fan_speed_pwm; 233 + uint32_t fan_speed_rpm; 235 234 uint32_t flags; 236 235 uint32_t user_od; 237 236 ··· 543 540 struct work_struct interrupt_work; 544 541 545 542 unsigned fan_max_rpm; 546 - unsigned manual_fan_speed_percent; 543 + unsigned manual_fan_speed_pwm; 547 544 548 545 uint32_t gfx_default_hard_min_freq; 549 546 uint32_t gfx_default_soft_max_freq; ··· 725 722 bool (*is_dpm_running)(struct smu_context *smu); 726 723 727 724 /** 728 - * @get_fan_speed_percent: Get the current fan speed in percent. 725 + * @get_fan_speed_pwm: Get the current fan speed in PWM. 729 726 */ 730 - int (*get_fan_speed_percent)(struct smu_context *smu, uint32_t *speed); 727 + int (*get_fan_speed_pwm)(struct smu_context *smu, uint32_t *speed); 728 + 729 + /** 730 + * @get_fan_speed_rpm: Get the current fan speed in rpm. 731 + */ 732 + int (*get_fan_speed_rpm)(struct smu_context *smu, uint32_t *speed); 731 733 732 734 /** 733 735 * @set_watermarks_table: Configure and upload the watermarks tables to ··· 1051 1043 int (*set_fan_control_mode)(struct smu_context *smu, uint32_t mode); 1052 1044 1053 1045 /** 1054 - * @set_fan_speed_percent: Set a static fan speed in percent. 1046 + * @set_fan_speed_pwm: Set a static fan speed in PWM. 1055 1047 */ 1056 - int (*set_fan_speed_percent)(struct smu_context *smu, uint32_t speed); 1048 + int (*set_fan_speed_pwm)(struct smu_context *smu, uint32_t speed); 1049 + 1050 + /** 1051 + * @set_fan_speed_rpm: Set a static fan speed in rpm. 1052 + */ 1053 + int (*set_fan_speed_rpm)(struct smu_context *smu, uint32_t speed); 1057 1054 1058 1055 /** 1059 1056 * @set_xgmi_pstate: Set inter-chip global memory interconnect pstate.
+3 -3
drivers/gpu/drm/amd/pm/inc/hwmgr.h
··· 278 278 int (*get_fan_speed_info)(struct pp_hwmgr *hwmgr, struct phm_fan_speed_info *fan_speed_info); 279 279 void (*set_fan_control_mode)(struct pp_hwmgr *hwmgr, uint32_t mode); 280 280 uint32_t (*get_fan_control_mode)(struct pp_hwmgr *hwmgr); 281 - int (*set_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t percent); 282 - int (*get_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t *speed); 283 - int (*set_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t percent); 281 + int (*set_fan_speed_pwm)(struct pp_hwmgr *hwmgr, uint32_t speed); 282 + int (*get_fan_speed_pwm)(struct pp_hwmgr *hwmgr, uint32_t *speed); 283 + int (*set_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t speed); 284 284 int (*get_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t *speed); 285 285 int (*reset_fan_speed_to_default)(struct pp_hwmgr *hwmgr); 286 286 int (*uninitialize_thermal_controller)(struct pp_hwmgr *hwmgr);
-1
drivers/gpu/drm/amd/pm/inc/smu_types.h
··· 298 298 __SMU_DUMMY_MAP(DS_FCLK), \ 299 299 __SMU_DUMMY_MAP(DS_MP1CLK), \ 300 300 __SMU_DUMMY_MAP(DS_MP0CLK), \ 301 - __SMU_DUMMY_MAP(XGMI), \ 302 301 __SMU_DUMMY_MAP(XGMI_PER_LINK_PWR_DWN), \ 303 302 __SMU_DUMMY_MAP(DPM_GFX_PACE), \ 304 303 __SMU_DUMMY_MAP(MEM_VDDCI_SCALING), \
+10 -1
drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
··· 221 221 smu_v11_0_set_fan_control_mode(struct smu_context *smu, 222 222 uint32_t mode); 223 223 224 - int smu_v11_0_set_fan_speed_percent(struct smu_context *smu, 224 + int smu_v11_0_set_fan_speed_pwm(struct smu_context *smu, 225 225 uint32_t speed); 226 + 227 + int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu, 228 + uint32_t speed); 229 + 230 + int smu_v11_0_get_fan_speed_pwm(struct smu_context *smu, 231 + uint32_t *speed); 232 + 233 + int smu_v11_0_get_fan_speed_rpm(struct smu_context *smu, 234 + uint32_t *speed); 226 235 227 236 int smu_v11_0_set_xgmi_pstate(struct smu_context *smu, 228 237 uint32_t pstate);
+8 -8
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
··· 533 533 return mode; 534 534 } 535 535 536 - static int pp_dpm_set_fan_speed_percent(void *handle, uint32_t percent) 536 + static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed) 537 537 { 538 538 struct pp_hwmgr *hwmgr = handle; 539 539 int ret = 0; ··· 541 541 if (!hwmgr || !hwmgr->pm_en) 542 542 return -EINVAL; 543 543 544 - if (hwmgr->hwmgr_func->set_fan_speed_percent == NULL) { 544 + if (hwmgr->hwmgr_func->set_fan_speed_pwm == NULL) { 545 545 pr_info_ratelimited("%s was not implemented.\n", __func__); 546 546 return 0; 547 547 } 548 548 mutex_lock(&hwmgr->smu_lock); 549 - ret = hwmgr->hwmgr_func->set_fan_speed_percent(hwmgr, percent); 549 + ret = hwmgr->hwmgr_func->set_fan_speed_pwm(hwmgr, speed); 550 550 mutex_unlock(&hwmgr->smu_lock); 551 551 return ret; 552 552 } 553 553 554 - static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) 554 + static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed) 555 555 { 556 556 struct pp_hwmgr *hwmgr = handle; 557 557 int ret = 0; ··· 559 559 if (!hwmgr || !hwmgr->pm_en) 560 560 return -EINVAL; 561 561 562 - if (hwmgr->hwmgr_func->get_fan_speed_percent == NULL) { 562 + if (hwmgr->hwmgr_func->get_fan_speed_pwm == NULL) { 563 563 pr_info_ratelimited("%s was not implemented.\n", __func__); 564 564 return 0; 565 565 } 566 566 567 567 mutex_lock(&hwmgr->smu_lock); 568 - ret = hwmgr->hwmgr_func->get_fan_speed_percent(hwmgr, speed); 568 + ret = hwmgr->hwmgr_func->get_fan_speed_pwm(hwmgr, speed); 569 569 mutex_unlock(&hwmgr->smu_lock); 570 570 return ret; 571 571 } ··· 1691 1691 .dispatch_tasks = pp_dpm_dispatch_tasks, 1692 1692 .set_fan_control_mode = pp_dpm_set_fan_control_mode, 1693 1693 .get_fan_control_mode = pp_dpm_get_fan_control_mode, 1694 - .set_fan_speed_percent = pp_dpm_set_fan_speed_percent, 1695 - .get_fan_speed_percent = pp_dpm_get_fan_speed_percent, 1694 + .set_fan_speed_pwm = pp_dpm_set_fan_speed_pwm, 1695 + .get_fan_speed_pwm = pp_dpm_get_fan_speed_pwm, 1696 1696 .get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm, 1697 1697 .set_fan_speed_rpm = pp_dpm_set_fan_speed_rpm, 1698 1698 .get_pp_num_states = pp_dpm_get_pp_num_states,
+11 -11
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c
··· 1036 1036 else 1037 1037 i = 1; 1038 1038 1039 - size += sprintf(buf + size, "0: %uMhz %s\n", 1039 + size += sysfs_emit_at(buf, size, "0: %uMhz %s\n", 1040 1040 data->gfx_min_freq_limit/100, 1041 1041 i == 0 ? "*" : ""); 1042 - size += sprintf(buf + size, "1: %uMhz %s\n", 1042 + size += sysfs_emit_at(buf, size, "1: %uMhz %s\n", 1043 1043 i == 1 ? now : SMU10_UMD_PSTATE_GFXCLK, 1044 1044 i == 1 ? "*" : ""); 1045 - size += sprintf(buf + size, "2: %uMhz %s\n", 1045 + size += sysfs_emit_at(buf, size, "2: %uMhz %s\n", 1046 1046 data->gfx_max_freq_limit/100, 1047 1047 i == 2 ? "*" : ""); 1048 1048 break; ··· 1050 1050 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &now); 1051 1051 1052 1052 for (i = 0; i < mclk_table->count; i++) 1053 - size += sprintf(buf + size, "%d: %uMhz %s\n", 1053 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 1054 1054 i, 1055 1055 mclk_table->entries[i].clk / 100, 1056 1056 ((mclk_table->entries[i].clk / 100) ··· 1065 1065 if (ret) 1066 1066 return ret; 1067 1067 1068 - size = sprintf(buf, "%s:\n", "OD_SCLK"); 1069 - size += sprintf(buf + size, "0: %10uMhz\n", 1068 + size = sysfs_emit(buf, "%s:\n", "OD_SCLK"); 1069 + size += sysfs_emit_at(buf, size, "0: %10uMhz\n", 1070 1070 (data->gfx_actual_soft_min_freq > 0) ? data->gfx_actual_soft_min_freq : min_freq); 1071 - size += sprintf(buf + size, "1: %10uMhz\n", 1071 + size += sysfs_emit_at(buf, size, "1: %10uMhz\n", 1072 1072 (data->gfx_actual_soft_max_freq > 0) ? data->gfx_actual_soft_max_freq : max_freq); 1073 1073 } 1074 1074 break; ··· 1081 1081 if (ret) 1082 1082 return ret; 1083 1083 1084 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 1085 - size += sprintf(buf + size, "SCLK: %7uMHz %10uMHz\n", 1084 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 1085 + size += sysfs_emit_at(buf, size, "SCLK: %7uMHz %10uMHz\n", 1086 1086 min_freq, max_freq); 1087 1087 } 1088 1088 break; ··· 1456 1456 if (!buf) 1457 1457 return -EINVAL; 1458 1458 1459 - size += sprintf(buf + size, "%s %16s %s %s %s %s\n",title[0], 1459 + size += sysfs_emit_at(buf, size, "%s %16s %s %s %s %s\n",title[0], 1460 1460 title[1], title[2], title[3], title[4], title[5]); 1461 1461 1462 1462 for (i = 0; i <= PP_SMC_POWER_PROFILE_COMPUTE; i++) 1463 - size += sprintf(buf + size, "%3d %14s%s: %14d %3d %10d %14d\n", 1463 + size += sysfs_emit_at(buf, size, "%3d %14s%s: %14d %3d %10d %14d\n", 1464 1464 i, profile_name[i], (i == hwmgr->power_profile_mode) ? "*" : " ", 1465 1465 profile_mode_setting[i][0], profile_mode_setting[i][1], 1466 1466 profile_mode_setting[i][2], profile_mode_setting[i][3]);
+23 -23
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
··· 3212 3212 3213 3213 if (!ret) { 3214 3214 if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK && hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) 3215 - smu7_fan_ctrl_set_fan_speed_percent(hwmgr, 100); 3215 + smu7_fan_ctrl_set_fan_speed_pwm(hwmgr, 255); 3216 3216 else if (level != AMD_DPM_FORCED_LEVEL_PROFILE_PEAK && hwmgr->dpm_level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) 3217 3217 smu7_fan_ctrl_reset_fan_speed_to_default(hwmgr); 3218 3218 } ··· 4896 4896 struct smu7_odn_dpm_table *odn_table = &(data->odn_dpm_table); 4897 4897 struct phm_odn_clock_levels *odn_sclk_table = &(odn_table->odn_core_clock_dpm_levels); 4898 4898 struct phm_odn_clock_levels *odn_mclk_table = &(odn_table->odn_memory_clock_dpm_levels); 4899 - int i, now, size = 0; 4900 - uint32_t clock, pcie_speed; 4899 + int size = 0; 4900 + uint32_t i, now, clock, pcie_speed; 4901 4901 4902 4902 switch (type) { 4903 4903 case PP_SCLK: ··· 4911 4911 now = i; 4912 4912 4913 4913 for (i = 0; i < sclk_table->count; i++) 4914 - size += sprintf(buf + size, "%d: %uMhz %s\n", 4914 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 4915 4915 i, sclk_table->dpm_levels[i].value / 100, 4916 4916 (i == now) ? "*" : ""); 4917 4917 break; ··· 4926 4926 now = i; 4927 4927 4928 4928 for (i = 0; i < mclk_table->count; i++) 4929 - size += sprintf(buf + size, "%d: %uMhz %s\n", 4929 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 4930 4930 i, mclk_table->dpm_levels[i].value / 100, 4931 4931 (i == now) ? "*" : ""); 4932 4932 break; ··· 4940 4940 now = i; 4941 4941 4942 4942 for (i = 0; i < pcie_table->count; i++) 4943 - size += sprintf(buf + size, "%d: %s %s\n", i, 4943 + size += sysfs_emit_at(buf, size, "%d: %s %s\n", i, 4944 4944 (pcie_table->dpm_levels[i].value == 0) ? "2.5GT/s, x8" : 4945 4945 (pcie_table->dpm_levels[i].value == 1) ? "5.0GT/s, x16" : 4946 4946 (pcie_table->dpm_levels[i].value == 2) ? "8.0GT/s, x16" : "", ··· 4948 4948 break; 4949 4949 case OD_SCLK: 4950 4950 if (hwmgr->od_enabled) { 4951 - size = sprintf(buf, "%s:\n", "OD_SCLK"); 4951 + size = sysfs_emit(buf, "%s:\n", "OD_SCLK"); 4952 4952 for (i = 0; i < odn_sclk_table->num_of_pl; i++) 4953 - size += sprintf(buf + size, "%d: %10uMHz %10umV\n", 4953 + size += sysfs_emit_at(buf, size, "%d: %10uMHz %10umV\n", 4954 4954 i, odn_sclk_table->entries[i].clock/100, 4955 4955 odn_sclk_table->entries[i].vddc); 4956 4956 } 4957 4957 break; 4958 4958 case OD_MCLK: 4959 4959 if (hwmgr->od_enabled) { 4960 - size = sprintf(buf, "%s:\n", "OD_MCLK"); 4960 + size = sysfs_emit(buf, "%s:\n", "OD_MCLK"); 4961 4961 for (i = 0; i < odn_mclk_table->num_of_pl; i++) 4962 - size += sprintf(buf + size, "%d: %10uMHz %10umV\n", 4962 + size += sysfs_emit_at(buf, size, "%d: %10uMHz %10umV\n", 4963 4963 i, odn_mclk_table->entries[i].clock/100, 4964 4964 odn_mclk_table->entries[i].vddc); 4965 4965 } 4966 4966 break; 4967 4967 case OD_RANGE: 4968 4968 if (hwmgr->od_enabled) { 4969 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 4970 - size += sprintf(buf + size, "SCLK: %7uMHz %10uMHz\n", 4969 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 4970 + size += sysfs_emit_at(buf, size, "SCLK: %7uMHz %10uMHz\n", 4971 4971 data->golden_dpm_table.sclk_table.dpm_levels[0].value/100, 4972 4972 hwmgr->platform_descriptor.overdriveLimit.engineClock/100); 4973 - size += sprintf(buf + size, "MCLK: %7uMHz %10uMHz\n", 4973 + size += sysfs_emit_at(buf, size, "MCLK: %7uMHz %10uMHz\n", 4974 4974 data->golden_dpm_table.mclk_table.dpm_levels[0].value/100, 4975 4975 hwmgr->platform_descriptor.overdriveLimit.memoryClock/100); 4976 - size += sprintf(buf + size, "VDDC: %7umV %11umV\n", 4976 + size += sysfs_emit_at(buf, size, "VDDC: %7umV %11umV\n", 4977 4977 data->odn_dpm_table.min_vddc, 4978 4978 data->odn_dpm_table.max_vddc); 4979 4979 } ··· 4988 4988 { 4989 4989 switch (mode) { 4990 4990 case AMD_FAN_CTRL_NONE: 4991 - smu7_fan_ctrl_set_fan_speed_percent(hwmgr, 100); 4991 + smu7_fan_ctrl_set_fan_speed_pwm(hwmgr, 255); 4992 4992 break; 4993 4993 case AMD_FAN_CTRL_MANUAL: 4994 4994 if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, ··· 5503 5503 if (!buf) 5504 5504 return -EINVAL; 5505 5505 5506 - size += sprintf(buf + size, "%s %16s %16s %16s %16s %16s %16s %16s\n", 5506 + size += sysfs_emit_at(buf, size, "%s %16s %16s %16s %16s %16s %16s %16s\n", 5507 5507 title[0], title[1], title[2], title[3], 5508 5508 title[4], title[5], title[6], title[7]); 5509 5509 ··· 5511 5511 5512 5512 for (i = 0; i < len; i++) { 5513 5513 if (i == hwmgr->power_profile_mode) { 5514 - size += sprintf(buf + size, "%3d %14s %s: %8d %16d %16d %16d %16d %16d\n", 5514 + size += sysfs_emit_at(buf, size, "%3d %14s %s: %8d %16d %16d %16d %16d %16d\n", 5515 5515 i, profile_name[i], "*", 5516 5516 data->current_profile_setting.sclk_up_hyst, 5517 5517 data->current_profile_setting.sclk_down_hyst, ··· 5522 5522 continue; 5523 5523 } 5524 5524 if (smu7_profiling[i].bupdate_sclk) 5525 - size += sprintf(buf + size, "%3d %16s: %8d %16d %16d ", 5525 + size += sysfs_emit_at(buf, size, "%3d %16s: %8d %16d %16d ", 5526 5526 i, profile_name[i], smu7_profiling[i].sclk_up_hyst, 5527 5527 smu7_profiling[i].sclk_down_hyst, 5528 5528 smu7_profiling[i].sclk_activity); 5529 5529 else 5530 - size += sprintf(buf + size, "%3d %16s: %8s %16s %16s ", 5530 + size += sysfs_emit_at(buf, size, "%3d %16s: %8s %16s %16s ", 5531 5531 i, profile_name[i], "-", "-", "-"); 5532 5532 5533 5533 if (smu7_profiling[i].bupdate_mclk) 5534 - size += sprintf(buf + size, "%16d %16d %16d\n", 5534 + size += sysfs_emit_at(buf, size, "%16d %16d %16d\n", 5535 5535 smu7_profiling[i].mclk_up_hyst, 5536 5536 smu7_profiling[i].mclk_down_hyst, 5537 5537 smu7_profiling[i].mclk_activity); 5538 5538 else 5539 - size += sprintf(buf + size, "%16s %16s %16s\n", 5539 + size += sysfs_emit_at(buf, size, "%16s %16s %16s\n", 5540 5540 "-", "-", "-"); 5541 5541 } 5542 5542 ··· 5692 5692 .set_max_fan_rpm_output = smu7_set_max_fan_rpm_output, 5693 5693 .stop_thermal_controller = smu7_thermal_stop_thermal_controller, 5694 5694 .get_fan_speed_info = smu7_fan_ctrl_get_fan_speed_info, 5695 - .get_fan_speed_percent = smu7_fan_ctrl_get_fan_speed_percent, 5696 - .set_fan_speed_percent = smu7_fan_ctrl_set_fan_speed_percent, 5695 + .get_fan_speed_pwm = smu7_fan_ctrl_get_fan_speed_pwm, 5696 + .set_fan_speed_pwm = smu7_fan_ctrl_set_fan_speed_pwm, 5697 5697 .reset_fan_speed_to_default = smu7_fan_ctrl_reset_fan_speed_to_default, 5698 5698 .get_fan_speed_rpm = smu7_fan_ctrl_get_fan_speed_rpm, 5699 5699 .set_fan_speed_rpm = smu7_fan_ctrl_set_fan_speed_rpm,
+8 -13
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c
··· 51 51 return 0; 52 52 } 53 53 54 - int smu7_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, 54 + int smu7_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr, 55 55 uint32_t *speed) 56 56 { 57 57 uint32_t duty100; ··· 70 70 return -EINVAL; 71 71 72 72 73 - tmp64 = (uint64_t)duty * 100; 73 + tmp64 = (uint64_t)duty * 255; 74 74 do_div(tmp64, duty100); 75 - *speed = (uint32_t)tmp64; 76 - 77 - if (*speed > 100) 78 - *speed = 100; 75 + *speed = MIN((uint32_t)tmp64, 255); 79 76 80 77 return 0; 81 78 } ··· 196 199 } 197 200 198 201 /** 199 - * smu7_fan_ctrl_set_fan_speed_percent - Set Fan Speed in percent. 202 + * smu7_fan_ctrl_set_fan_speed_pwm - Set Fan Speed in PWM. 200 203 * @hwmgr: the address of the powerplay hardware manager. 201 - * @speed: is the percentage value (0% - 100%) to be set. 202 - * Exception: Fails is the 100% setting appears to be 0. 204 + * @speed: is the pwm value (0 - 255) to be set. 203 205 */ 204 - int smu7_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, 206 + int smu7_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr, 205 207 uint32_t speed) 206 208 { 207 209 uint32_t duty100; ··· 210 214 if (hwmgr->thermal_controller.fanInfo.bNoFan) 211 215 return 0; 212 216 213 - if (speed > 100) 214 - speed = 100; 217 + speed = MIN(speed, 255); 215 218 216 219 if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) 217 220 smu7_fan_ctrl_stop_smc_fan_control(hwmgr); ··· 222 227 return -EINVAL; 223 228 224 229 tmp64 = (uint64_t)speed * duty100; 225 - do_div(tmp64, 100); 230 + do_div(tmp64, 255); 226 231 duty = (uint32_t)tmp64; 227 232 228 233 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+2 -2
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.h
··· 41 41 extern int smu7_thermal_get_temperature(struct pp_hwmgr *hwmgr); 42 42 extern int smu7_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); 43 43 extern int smu7_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, struct phm_fan_speed_info *fan_speed_info); 44 - extern int smu7_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t *speed); 44 + extern int smu7_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr, uint32_t *speed); 45 45 extern int smu7_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr); 46 46 extern int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode); 47 - extern int smu7_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed); 47 + extern int smu7_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr, uint32_t speed); 48 48 extern int smu7_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); 49 49 extern int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr); 50 50 extern int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed);
+4 -3
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
··· 1547 1547 struct smu8_hwmgr *data = hwmgr->backend; 1548 1548 struct phm_clock_voltage_dependency_table *sclk_table = 1549 1549 hwmgr->dyn_state.vddc_dependency_on_sclk; 1550 - int i, now, size = 0; 1550 + uint32_t i, now; 1551 + int size = 0; 1551 1552 1552 1553 switch (type) { 1553 1554 case PP_SCLK: ··· 1559 1558 CURR_SCLK_INDEX); 1560 1559 1561 1560 for (i = 0; i < sclk_table->count; i++) 1562 - size += sprintf(buf + size, "%d: %uMhz %s\n", 1561 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 1563 1562 i, sclk_table->entries[i].clk / 100, 1564 1563 (i == now) ? "*" : ""); 1565 1564 break; ··· 1571 1570 CURR_MCLK_INDEX); 1572 1571 1573 1572 for (i = SMU8_NUM_NBPMEMORYCLOCK; i > 0; i--) 1574 - size += sprintf(buf + size, "%d: %uMhz %s\n", 1573 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 1575 1574 SMU8_NUM_NBPMEMORYCLOCK-i, data->sys_info.nbp_memory_clock[i-1] / 100, 1576 1575 (SMU8_NUM_NBPMEMORYCLOCK-i == now) ? "*" : ""); 1577 1576 break;
+36 -23
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
··· 4199 4199 4200 4200 switch (mode) { 4201 4201 case AMD_FAN_CTRL_NONE: 4202 - vega10_fan_ctrl_set_fan_speed_percent(hwmgr, 100); 4202 + vega10_fan_ctrl_set_fan_speed_pwm(hwmgr, 255); 4203 4203 break; 4204 4204 case AMD_FAN_CTRL_MANUAL: 4205 4205 if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) ··· 4553 4553 "[EnableAllSmuFeatures] Failed to get enabled smc features!", 4554 4554 return ret); 4555 4555 4556 - size += sprintf(buf + size, "Current ppfeatures: 0x%016llx\n", features_enabled); 4557 - size += sprintf(buf + size, "%-19s %-22s %s\n", 4556 + size += sysfs_emit_at(buf, size, "Current ppfeatures: 0x%016llx\n", features_enabled); 4557 + size += sysfs_emit_at(buf, size, "%-19s %-22s %s\n", 4558 4558 output_title[0], 4559 4559 output_title[1], 4560 4560 output_title[2]); 4561 4561 for (i = 0; i < GNLD_FEATURES_MAX; i++) { 4562 - size += sprintf(buf + size, "%-19s 0x%016llx %6s\n", 4562 + size += sysfs_emit_at(buf, size, "%-19s 0x%016llx %6s\n", 4563 4563 ppfeature_name[i], 4564 4564 1ULL << i, 4565 4565 (features_enabled & (1ULL << i)) ? "Y" : "N"); ··· 4650 4650 else 4651 4651 count = sclk_table->count; 4652 4652 for (i = 0; i < count; i++) 4653 - size += sprintf(buf + size, "%d: %uMhz %s\n", 4653 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 4654 4654 i, sclk_table->dpm_levels[i].value / 100, 4655 4655 (i == now) ? "*" : ""); 4656 4656 break; ··· 4661 4661 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrentUclkIndex, &now); 4662 4662 4663 4663 for (i = 0; i < mclk_table->count; i++) 4664 - size += sprintf(buf + size, "%d: %uMhz %s\n", 4664 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 4665 4665 i, mclk_table->dpm_levels[i].value / 100, 4666 4666 (i == now) ? "*" : ""); 4667 4667 break; ··· 4672 4672 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrentSocclkIndex, &now); 4673 4673 4674 4674 for (i = 0; i < soc_table->count; i++) 4675 - size += sprintf(buf + size, "%d: %uMhz %s\n", 4675 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 4676 4676 i, soc_table->dpm_levels[i].value / 100, 4677 4677 (i == now) ? "*" : ""); 4678 4678 break; ··· 4684 4684 PPSMC_MSG_GetClockFreqMHz, CLK_DCEFCLK, &now); 4685 4685 4686 4686 for (i = 0; i < dcef_table->count; i++) 4687 - size += sprintf(buf + size, "%d: %uMhz %s\n", 4687 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 4688 4688 i, dcef_table->dpm_levels[i].value / 100, 4689 4689 (dcef_table->dpm_levels[i].value / 100 == now) ? 4690 4690 "*" : ""); ··· 4698 4698 gen_speed = pptable->PcieGenSpeed[i]; 4699 4699 lane_width = pptable->PcieLaneCount[i]; 4700 4700 4701 - size += sprintf(buf + size, "%d: %s %s %s\n", i, 4701 + size += sysfs_emit_at(buf, size, "%d: %s %s %s\n", i, 4702 4702 (gen_speed == 0) ? "2.5GT/s," : 4703 4703 (gen_speed == 1) ? "5.0GT/s," : 4704 4704 (gen_speed == 2) ? "8.0GT/s," : ··· 4717 4717 4718 4718 case OD_SCLK: 4719 4719 if (hwmgr->od_enabled) { 4720 - size = sprintf(buf, "%s:\n", "OD_SCLK"); 4720 + size = sysfs_emit(buf, "%s:\n", "OD_SCLK"); 4721 4721 podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_sclk; 4722 4722 for (i = 0; i < podn_vdd_dep->count; i++) 4723 - size += sprintf(buf + size, "%d: %10uMhz %10umV\n", 4723 + size += sysfs_emit_at(buf, size, "%d: %10uMhz %10umV\n", 4724 4724 i, podn_vdd_dep->entries[i].clk / 100, 4725 4725 podn_vdd_dep->entries[i].vddc); 4726 4726 } 4727 4727 break; 4728 4728 case OD_MCLK: 4729 4729 if (hwmgr->od_enabled) { 4730 - size = sprintf(buf, "%s:\n", "OD_MCLK"); 4730 + size = sysfs_emit(buf, "%s:\n", "OD_MCLK"); 4731 4731 podn_vdd_dep = &data->odn_dpm_table.vdd_dep_on_mclk; 4732 4732 for (i = 0; i < podn_vdd_dep->count; i++) 4733 - size += sprintf(buf + size, "%d: %10uMhz %10umV\n", 4733 + size += sysfs_emit_at(buf, size, "%d: %10uMhz %10umV\n", 4734 4734 i, podn_vdd_dep->entries[i].clk/100, 4735 4735 podn_vdd_dep->entries[i].vddc); 4736 4736 } 4737 4737 break; 4738 4738 case OD_RANGE: 4739 4739 if (hwmgr->od_enabled) { 4740 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 4741 - size += sprintf(buf + size, "SCLK: %7uMHz %10uMHz\n", 4740 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 4741 + size += sysfs_emit_at(buf, size, "SCLK: %7uMHz %10uMHz\n", 4742 4742 data->golden_dpm_table.gfx_table.dpm_levels[0].value/100, 4743 4743 hwmgr->platform_descriptor.overdriveLimit.engineClock/100); 4744 - size += sprintf(buf + size, "MCLK: %7uMHz %10uMHz\n", 4744 + size += sysfs_emit_at(buf, size, "MCLK: %7uMHz %10uMHz\n", 4745 4745 data->golden_dpm_table.mem_table.dpm_levels[0].value/100, 4746 4746 hwmgr->platform_descriptor.overdriveLimit.memoryClock/100); 4747 - size += sprintf(buf + size, "VDDC: %7umV %11umV\n", 4747 + size += sysfs_emit_at(buf, size, "VDDC: %7umV %11umV\n", 4748 4748 data->odn_dpm_table.min_vddc, 4749 4749 data->odn_dpm_table.max_vddc); 4750 4750 } ··· 5112 5112 if (!buf) 5113 5113 return -EINVAL; 5114 5114 5115 - size += sprintf(buf + size, "%s %16s %s %s %s %s\n",title[0], 5115 + size += sysfs_emit_at(buf, size, "%s %16s %s %s %s %s\n",title[0], 5116 5116 title[1], title[2], title[3], title[4], title[5]); 5117 5117 5118 5118 for (i = 0; i < PP_SMC_POWER_PROFILE_CUSTOM; i++) 5119 - size += sprintf(buf + size, "%3d %14s%s: %14d %3d %10d %14d\n", 5119 + size += sysfs_emit_at(buf, size, "%3d %14s%s: %14d %3d %10d %14d\n", 5120 5120 i, profile_name[i], (i == hwmgr->power_profile_mode) ? "*" : " ", 5121 5121 profile_mode_setting[i][0], profile_mode_setting[i][1], 5122 5122 profile_mode_setting[i][2], profile_mode_setting[i][3]); 5123 - size += sprintf(buf + size, "%3d %14s%s: %14d %3d %10d %14d\n", i, 5123 + size += sysfs_emit_at(buf, size, "%3d %14s%s: %14d %3d %10d %14d\n", i, 5124 5124 profile_name[i], (i == hwmgr->power_profile_mode) ? "*" : " ", 5125 5125 data->custom_profile_mode[0], data->custom_profile_mode[1], 5126 5126 data->custom_profile_mode[2], data->custom_profile_mode[3]); 5127 5127 return size; 5128 + } 5129 + 5130 + static bool vega10_get_power_profile_mode_quirks(struct pp_hwmgr *hwmgr) 5131 + { 5132 + struct amdgpu_device *adev = hwmgr->adev; 5133 + 5134 + return (adev->pdev->device == 0x6860); 5128 5135 } 5129 5136 5130 5137 static int vega10_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint32_t size) ··· 5170 5163 } 5171 5164 5172 5165 out: 5173 - smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetWorkloadMask, 5166 + if (vega10_get_power_profile_mode_quirks(hwmgr)) 5167 + smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetWorkloadMask, 5168 + 1 << power_profile_mode, 5169 + NULL); 5170 + else 5171 + smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetWorkloadMask, 5174 5172 (!power_profile_mode) ? 0 : 1 << (power_profile_mode - 1), 5175 5173 NULL); 5174 + 5176 5175 hwmgr->power_profile_mode = power_profile_mode; 5177 5176 5178 5177 return 0; ··· 5536 5523 .force_dpm_level = vega10_dpm_force_dpm_level, 5537 5524 .stop_thermal_controller = vega10_thermal_stop_thermal_controller, 5538 5525 .get_fan_speed_info = vega10_fan_ctrl_get_fan_speed_info, 5539 - .get_fan_speed_percent = vega10_fan_ctrl_get_fan_speed_percent, 5540 - .set_fan_speed_percent = vega10_fan_ctrl_set_fan_speed_percent, 5526 + .get_fan_speed_pwm = vega10_fan_ctrl_get_fan_speed_pwm, 5527 + .set_fan_speed_pwm = vega10_fan_ctrl_set_fan_speed_pwm, 5541 5528 .reset_fan_speed_to_default = 5542 5529 vega10_fan_ctrl_reset_fan_speed_to_default, 5543 5530 .get_fan_speed_rpm = vega10_fan_ctrl_get_fan_speed_rpm,
+8 -10
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c
··· 64 64 return 0; 65 65 } 66 66 67 - int vega10_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, 67 + int vega10_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr, 68 68 uint32_t *speed) 69 69 { 70 70 uint32_t current_rpm; ··· 78 78 79 79 if (hwmgr->thermal_controller. 80 80 advanceFanControlParameters.usMaxFanRPM != 0) 81 - percent = current_rpm * 100 / 81 + percent = current_rpm * 255 / 82 82 hwmgr->thermal_controller. 83 83 advanceFanControlParameters.usMaxFanRPM; 84 84 85 - *speed = percent > 100 ? 100 : percent; 85 + *speed = MIN(percent, 255); 86 86 87 87 return 0; 88 88 } ··· 241 241 } 242 242 243 243 /** 244 - * vega10_fan_ctrl_set_fan_speed_percent - Set Fan Speed in percent. 244 + * vega10_fan_ctrl_set_fan_speed_pwm - Set Fan Speed in PWM. 245 245 * @hwmgr: the address of the powerplay hardware manager. 246 - * @speed: is the percentage value (0% - 100%) to be set. 247 - * Exception: Fails is the 100% setting appears to be 0. 246 + * @speed: is the percentage value (0 - 255) to be set. 248 247 */ 249 - int vega10_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, 248 + int vega10_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr, 250 249 uint32_t speed) 251 250 { 252 251 struct amdgpu_device *adev = hwmgr->adev; ··· 256 257 if (hwmgr->thermal_controller.fanInfo.bNoFan) 257 258 return 0; 258 259 259 - if (speed > 100) 260 - speed = 100; 260 + speed = MIN(speed, 255); 261 261 262 262 if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) 263 263 vega10_fan_ctrl_stop_smc_fan_control(hwmgr); ··· 268 270 return -EINVAL; 269 271 270 272 tmp64 = (uint64_t)speed * duty100; 271 - do_div(tmp64, 100); 273 + do_div(tmp64, 255); 272 274 duty = (uint32_t)tmp64; 273 275 274 276 WREG32_SOC15(THM, 0, mmCG_FDO_CTRL0,
+2 -2
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.h
··· 54 54 extern int vega10_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); 55 55 extern int vega10_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, 56 56 struct phm_fan_speed_info *fan_speed_info); 57 - extern int vega10_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, 57 + extern int vega10_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr, 58 58 uint32_t *speed); 59 59 extern int vega10_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr); 60 60 extern int vega10_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, 61 61 uint32_t mode); 62 - extern int vega10_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, 62 + extern int vega10_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr, 63 63 uint32_t speed); 64 64 extern int vega10_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); 65 65 extern int vega10_thermal_ctrl_uninitialize_thermal_controller(
+7 -7
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c
··· 2146 2146 "[EnableAllSmuFeatures] Failed to get enabled smc features!", 2147 2147 return ret); 2148 2148 2149 - size += sprintf(buf + size, "Current ppfeatures: 0x%016llx\n", features_enabled); 2150 - size += sprintf(buf + size, "%-19s %-22s %s\n", 2149 + size += sysfs_emit_at(buf, size, "Current ppfeatures: 0x%016llx\n", features_enabled); 2150 + size += sysfs_emit_at(buf, size, "%-19s %-22s %s\n", 2151 2151 output_title[0], 2152 2152 output_title[1], 2153 2153 output_title[2]); 2154 2154 for (i = 0; i < GNLD_FEATURES_MAX; i++) { 2155 - size += sprintf(buf + size, "%-19s 0x%016llx %6s\n", 2155 + size += sysfs_emit_at(buf, size, "%-19s 0x%016llx %6s\n", 2156 2156 ppfeature_name[i], 2157 2157 1ULL << i, 2158 2158 (features_enabled & (1ULL << i)) ? "Y" : "N"); ··· 2256 2256 "Attempt to get gfx clk levels Failed!", 2257 2257 return -1); 2258 2258 for (i = 0; i < clocks.num_levels; i++) 2259 - size += sprintf(buf + size, "%d: %uMhz %s\n", 2259 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 2260 2260 i, clocks.data[i].clocks_in_khz / 1000, 2261 2261 (clocks.data[i].clocks_in_khz / 1000 == now / 100) ? "*" : ""); 2262 2262 break; ··· 2272 2272 "Attempt to get memory clk levels Failed!", 2273 2273 return -1); 2274 2274 for (i = 0; i < clocks.num_levels; i++) 2275 - size += sprintf(buf + size, "%d: %uMhz %s\n", 2275 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 2276 2276 i, clocks.data[i].clocks_in_khz / 1000, 2277 2277 (clocks.data[i].clocks_in_khz / 1000 == now / 100) ? "*" : ""); 2278 2278 break; ··· 2290 2290 "Attempt to get soc clk levels Failed!", 2291 2291 return -1); 2292 2292 for (i = 0; i < clocks.num_levels; i++) 2293 - size += sprintf(buf + size, "%d: %uMhz %s\n", 2293 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 2294 2294 i, clocks.data[i].clocks_in_khz / 1000, 2295 2295 (clocks.data[i].clocks_in_khz / 1000 == now) ? "*" : ""); 2296 2296 break; ··· 2308 2308 "Attempt to get dcef clk levels Failed!", 2309 2309 return -1); 2310 2310 for (i = 0; i < clocks.num_levels; i++) 2311 - size += sprintf(buf + size, "%d: %uMhz %s\n", 2311 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 2312 2312 i, clocks.data[i].clocks_in_khz / 1000, 2313 2313 (clocks.data[i].clocks_in_khz / 1000 == now) ? "*" : ""); 2314 2314 break;
+40 -40
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c
··· 2769 2769 { 2770 2770 switch (mode) { 2771 2771 case AMD_FAN_CTRL_NONE: 2772 - vega20_fan_ctrl_set_fan_speed_percent(hwmgr, 100); 2772 + vega20_fan_ctrl_set_fan_speed_pwm(hwmgr, 255); 2773 2773 break; 2774 2774 case AMD_FAN_CTRL_MANUAL: 2775 2775 if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) ··· 3243 3243 "[EnableAllSmuFeatures] Failed to get enabled smc features!", 3244 3244 return ret); 3245 3245 3246 - size += sprintf(buf + size, "Current ppfeatures: 0x%016llx\n", features_enabled); 3247 - size += sprintf(buf + size, "%-19s %-22s %s\n", 3246 + size += sysfs_emit_at(buf, size, "Current ppfeatures: 0x%016llx\n", features_enabled); 3247 + size += sysfs_emit_at(buf, size, "%-19s %-22s %s\n", 3248 3248 output_title[0], 3249 3249 output_title[1], 3250 3250 output_title[2]); 3251 3251 for (i = 0; i < GNLD_FEATURES_MAX; i++) { 3252 - size += sprintf(buf + size, "%-19s 0x%016llx %6s\n", 3252 + size += sysfs_emit_at(buf, size, "%-19s 0x%016llx %6s\n", 3253 3253 ppfeature_name[i], 3254 3254 1ULL << i, 3255 3255 (features_enabled & (1ULL << i)) ? "Y" : "N"); ··· 3372 3372 return ret); 3373 3373 3374 3374 if (vega20_get_sclks(hwmgr, &clocks)) { 3375 - size += sprintf(buf + size, "0: %uMhz * (DPM disabled)\n", 3375 + size += sysfs_emit_at(buf, size, "0: %uMhz * (DPM disabled)\n", 3376 3376 now / 100); 3377 3377 break; 3378 3378 } 3379 3379 3380 3380 for (i = 0; i < clocks.num_levels; i++) 3381 - size += sprintf(buf + size, "%d: %uMhz %s\n", 3381 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 3382 3382 i, clocks.data[i].clocks_in_khz / 1000, 3383 3383 (clocks.data[i].clocks_in_khz == now * 10) ? "*" : ""); 3384 3384 break; ··· 3390 3390 return ret); 3391 3391 3392 3392 if (vega20_get_memclocks(hwmgr, &clocks)) { 3393 - size += sprintf(buf + size, "0: %uMhz * (DPM disabled)\n", 3393 + size += sysfs_emit_at(buf, size, "0: %uMhz * (DPM disabled)\n", 3394 3394 now / 100); 3395 3395 break; 3396 3396 } 3397 3397 3398 3398 for (i = 0; i < clocks.num_levels; i++) 3399 - size += sprintf(buf + size, "%d: %uMhz %s\n", 3399 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 3400 3400 i, clocks.data[i].clocks_in_khz / 1000, 3401 3401 (clocks.data[i].clocks_in_khz == now * 10) ? "*" : ""); 3402 3402 break; ··· 3408 3408 return ret); 3409 3409 3410 3410 if (vega20_get_socclocks(hwmgr, &clocks)) { 3411 - size += sprintf(buf + size, "0: %uMhz * (DPM disabled)\n", 3411 + size += sysfs_emit_at(buf, size, "0: %uMhz * (DPM disabled)\n", 3412 3412 now / 100); 3413 3413 break; 3414 3414 } 3415 3415 3416 3416 for (i = 0; i < clocks.num_levels; i++) 3417 - size += sprintf(buf + size, "%d: %uMhz %s\n", 3417 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 3418 3418 i, clocks.data[i].clocks_in_khz / 1000, 3419 3419 (clocks.data[i].clocks_in_khz == now * 10) ? "*" : ""); 3420 3420 break; ··· 3426 3426 return ret); 3427 3427 3428 3428 for (i = 0; i < fclk_dpm_table->count; i++) 3429 - size += sprintf(buf + size, "%d: %uMhz %s\n", 3429 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 3430 3430 i, fclk_dpm_table->dpm_levels[i].value, 3431 3431 fclk_dpm_table->dpm_levels[i].value == (now / 100) ? "*" : ""); 3432 3432 break; ··· 3438 3438 return ret); 3439 3439 3440 3440 if (vega20_get_dcefclocks(hwmgr, &clocks)) { 3441 - size += sprintf(buf + size, "0: %uMhz * (DPM disabled)\n", 3441 + size += sysfs_emit_at(buf, size, "0: %uMhz * (DPM disabled)\n", 3442 3442 now / 100); 3443 3443 break; 3444 3444 } 3445 3445 3446 3446 for (i = 0; i < clocks.num_levels; i++) 3447 - size += sprintf(buf + size, "%d: %uMhz %s\n", 3447 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 3448 3448 i, clocks.data[i].clocks_in_khz / 1000, 3449 3449 (clocks.data[i].clocks_in_khz == now * 10) ? "*" : ""); 3450 3450 break; ··· 3458 3458 gen_speed = pptable->PcieGenSpeed[i]; 3459 3459 lane_width = pptable->PcieLaneCount[i]; 3460 3460 3461 - size += sprintf(buf + size, "%d: %s %s %dMhz %s\n", i, 3461 + size += sysfs_emit_at(buf, size, "%d: %s %s %dMhz %s\n", i, 3462 3462 (gen_speed == 0) ? "2.5GT/s," : 3463 3463 (gen_speed == 1) ? "5.0GT/s," : 3464 3464 (gen_speed == 2) ? "8.0GT/s," : ··· 3479 3479 case OD_SCLK: 3480 3480 if (od8_settings[OD8_SETTING_GFXCLK_FMIN].feature_id && 3481 3481 od8_settings[OD8_SETTING_GFXCLK_FMAX].feature_id) { 3482 - size = sprintf(buf, "%s:\n", "OD_SCLK"); 3483 - size += sprintf(buf + size, "0: %10uMhz\n", 3482 + size = sysfs_emit(buf, "%s:\n", "OD_SCLK"); 3483 + size += sysfs_emit_at(buf, size, "0: %10uMhz\n", 3484 3484 od_table->GfxclkFmin); 3485 - size += sprintf(buf + size, "1: %10uMhz\n", 3485 + size += sysfs_emit_at(buf, size, "1: %10uMhz\n", 3486 3486 od_table->GfxclkFmax); 3487 3487 } 3488 3488 break; 3489 3489 3490 3490 case OD_MCLK: 3491 3491 if (od8_settings[OD8_SETTING_UCLK_FMAX].feature_id) { 3492 - size = sprintf(buf, "%s:\n", "OD_MCLK"); 3493 - size += sprintf(buf + size, "1: %10uMhz\n", 3492 + size = sysfs_emit(buf, "%s:\n", "OD_MCLK"); 3493 + size += sysfs_emit_at(buf, size, "1: %10uMhz\n", 3494 3494 od_table->UclkFmax); 3495 3495 } 3496 3496 ··· 3503 3503 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].feature_id && 3504 3504 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].feature_id && 3505 3505 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].feature_id) { 3506 - size = sprintf(buf, "%s:\n", "OD_VDDC_CURVE"); 3507 - size += sprintf(buf + size, "0: %10uMhz %10dmV\n", 3506 + size = sysfs_emit(buf, "%s:\n", "OD_VDDC_CURVE"); 3507 + size += sysfs_emit_at(buf, size, "0: %10uMhz %10dmV\n", 3508 3508 od_table->GfxclkFreq1, 3509 3509 od_table->GfxclkVolt1 / VOLTAGE_SCALE); 3510 - size += sprintf(buf + size, "1: %10uMhz %10dmV\n", 3510 + size += sysfs_emit_at(buf, size, "1: %10uMhz %10dmV\n", 3511 3511 od_table->GfxclkFreq2, 3512 3512 od_table->GfxclkVolt2 / VOLTAGE_SCALE); 3513 - size += sprintf(buf + size, "2: %10uMhz %10dmV\n", 3513 + size += sysfs_emit_at(buf, size, "2: %10uMhz %10dmV\n", 3514 3514 od_table->GfxclkFreq3, 3515 3515 od_table->GfxclkVolt3 / VOLTAGE_SCALE); 3516 3516 } ··· 3518 3518 break; 3519 3519 3520 3520 case OD_RANGE: 3521 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 3521 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 3522 3522 3523 3523 if (od8_settings[OD8_SETTING_GFXCLK_FMIN].feature_id && 3524 3524 od8_settings[OD8_SETTING_GFXCLK_FMAX].feature_id) { 3525 - size += sprintf(buf + size, "SCLK: %7uMhz %10uMhz\n", 3525 + size += sysfs_emit_at(buf, size, "SCLK: %7uMhz %10uMhz\n", 3526 3526 od8_settings[OD8_SETTING_GFXCLK_FMIN].min_value, 3527 3527 od8_settings[OD8_SETTING_GFXCLK_FMAX].max_value); 3528 3528 } 3529 3529 3530 3530 if (od8_settings[OD8_SETTING_UCLK_FMAX].feature_id) { 3531 - size += sprintf(buf + size, "MCLK: %7uMhz %10uMhz\n", 3531 + size += sysfs_emit_at(buf, size, "MCLK: %7uMhz %10uMhz\n", 3532 3532 od8_settings[OD8_SETTING_UCLK_FMAX].min_value, 3533 3533 od8_settings[OD8_SETTING_UCLK_FMAX].max_value); 3534 3534 } ··· 3539 3539 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].feature_id && 3540 3540 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].feature_id && 3541 3541 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].feature_id) { 3542 - size += sprintf(buf + size, "VDDC_CURVE_SCLK[0]: %7uMhz %10uMhz\n", 3542 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_SCLK[0]: %7uMhz %10uMhz\n", 3543 3543 od8_settings[OD8_SETTING_GFXCLK_FREQ1].min_value, 3544 3544 od8_settings[OD8_SETTING_GFXCLK_FREQ1].max_value); 3545 - size += sprintf(buf + size, "VDDC_CURVE_VOLT[0]: %7dmV %11dmV\n", 3545 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_VOLT[0]: %7dmV %11dmV\n", 3546 3546 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value, 3547 3547 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value); 3548 - size += sprintf(buf + size, "VDDC_CURVE_SCLK[1]: %7uMhz %10uMhz\n", 3548 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_SCLK[1]: %7uMhz %10uMhz\n", 3549 3549 od8_settings[OD8_SETTING_GFXCLK_FREQ2].min_value, 3550 3550 od8_settings[OD8_SETTING_GFXCLK_FREQ2].max_value); 3551 - size += sprintf(buf + size, "VDDC_CURVE_VOLT[1]: %7dmV %11dmV\n", 3551 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_VOLT[1]: %7dmV %11dmV\n", 3552 3552 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value, 3553 3553 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value); 3554 - size += sprintf(buf + size, "VDDC_CURVE_SCLK[2]: %7uMhz %10uMhz\n", 3554 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_SCLK[2]: %7uMhz %10uMhz\n", 3555 3555 od8_settings[OD8_SETTING_GFXCLK_FREQ3].min_value, 3556 3556 od8_settings[OD8_SETTING_GFXCLK_FREQ3].max_value); 3557 - size += sprintf(buf + size, "VDDC_CURVE_VOLT[2]: %7dmV %11dmV\n", 3557 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_VOLT[2]: %7dmV %11dmV\n", 3558 3558 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value, 3559 3559 od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value); 3560 3560 } ··· 4003 4003 if (!buf) 4004 4004 return -EINVAL; 4005 4005 4006 - size += sprintf(buf + size, "%16s %s %s %s %s %s %s %s %s %s %s\n", 4006 + size += sysfs_emit_at(buf, size, "%16s %s %s %s %s %s %s %s %s %s %s\n", 4007 4007 title[0], title[1], title[2], title[3], title[4], title[5], 4008 4008 title[6], title[7], title[8], title[9], title[10]); 4009 4009 ··· 4016 4016 "[GetPowerProfile] Failed to get activity monitor!", 4017 4017 return result); 4018 4018 4019 - size += sprintf(buf + size, "%2d %14s%s:\n", 4019 + size += sysfs_emit_at(buf, size, "%2d %14s%s:\n", 4020 4020 i, profile_name[i], (i == hwmgr->power_profile_mode) ? "*" : " "); 4021 4021 4022 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 4022 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 4023 4023 " ", 4024 4024 0, 4025 4025 "GFXCLK", ··· 4033 4033 activity_monitor.Gfx_PD_Data_error_coeff, 4034 4034 activity_monitor.Gfx_PD_Data_error_rate_coeff); 4035 4035 4036 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 4036 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 4037 4037 " ", 4038 4038 1, 4039 4039 "SOCCLK", ··· 4047 4047 activity_monitor.Soc_PD_Data_error_coeff, 4048 4048 activity_monitor.Soc_PD_Data_error_rate_coeff); 4049 4049 4050 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 4050 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 4051 4051 " ", 4052 4052 2, 4053 4053 "UCLK", ··· 4061 4061 activity_monitor.Mem_PD_Data_error_coeff, 4062 4062 activity_monitor.Mem_PD_Data_error_rate_coeff); 4063 4063 4064 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 4064 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 4065 4065 " ", 4066 4066 3, 4067 4067 "FCLK", ··· 4409 4409 .register_irq_handlers = smu9_register_irq_handlers, 4410 4410 .disable_smc_firmware_ctf = vega20_thermal_disable_alert, 4411 4411 /* fan control related */ 4412 - .get_fan_speed_percent = vega20_fan_ctrl_get_fan_speed_percent, 4413 - .set_fan_speed_percent = vega20_fan_ctrl_set_fan_speed_percent, 4412 + .get_fan_speed_pwm = vega20_fan_ctrl_get_fan_speed_pwm, 4413 + .set_fan_speed_pwm = vega20_fan_ctrl_set_fan_speed_pwm, 4414 4414 .get_fan_speed_info = vega20_fan_ctrl_get_fan_speed_info, 4415 4415 .get_fan_speed_rpm = vega20_fan_ctrl_get_fan_speed_rpm, 4416 4416 .set_fan_speed_rpm = vega20_fan_ctrl_set_fan_speed_rpm,
+16 -14
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c
··· 114 114 return 0; 115 115 } 116 116 117 - int vega20_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, 117 + int vega20_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr, 118 118 uint32_t *speed) 119 119 { 120 - struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); 121 - PPTable_t *pp_table = &(data->smc_state_table.pp_table); 122 - uint32_t current_rpm, percent = 0; 123 - int ret = 0; 120 + struct amdgpu_device *adev = hwmgr->adev; 121 + uint32_t duty100, duty; 122 + uint64_t tmp64; 124 123 125 - ret = vega20_get_current_rpm(hwmgr, &current_rpm); 126 - if (ret) 127 - return ret; 124 + duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1), 125 + CG_FDO_CTRL1, FMAX_DUTY100); 126 + duty = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_THERMAL_STATUS), 127 + CG_THERMAL_STATUS, FDO_PWM_DUTY); 128 128 129 - percent = current_rpm * 100 / pp_table->FanMaximumRpm; 129 + if (!duty100) 130 + return -EINVAL; 130 131 131 - *speed = percent > 100 ? 100 : percent; 132 + tmp64 = (uint64_t)duty * 255; 133 + do_div(tmp64, duty100); 134 + *speed = MIN((uint32_t)tmp64, 255); 132 135 133 136 return 0; 134 137 } 135 138 136 - int vega20_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, 139 + int vega20_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr, 137 140 uint32_t speed) 138 141 { 139 142 struct amdgpu_device *adev = hwmgr->adev; ··· 144 141 uint32_t duty; 145 142 uint64_t tmp64; 146 143 147 - if (speed > 100) 148 - speed = 100; 144 + speed = MIN(speed, 255); 149 145 150 146 if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) 151 147 vega20_fan_ctrl_stop_smc_fan_control(hwmgr); ··· 156 154 return -EINVAL; 157 155 158 156 tmp64 = (uint64_t)speed * duty100; 159 - do_div(tmp64, 100); 157 + do_div(tmp64, 255); 160 158 duty = (uint32_t)tmp64; 161 159 162 160 WREG32_SOC15(THM, 0, mmCG_FDO_CTRL0,
+2 -2
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.h
··· 56 56 uint32_t *speed); 57 57 extern int vega20_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, 58 58 uint32_t speed); 59 - extern int vega20_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, 59 + extern int vega20_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr, 60 60 uint32_t *speed); 61 - extern int vega20_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, 61 + extern int vega20_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr, 62 62 uint32_t speed); 63 63 extern int vega20_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr); 64 64 extern int vega20_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr);
+8 -11
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
··· 6539 6539 } 6540 6540 } 6541 6541 6542 - static int si_dpm_get_fan_speed_percent(void *handle, 6542 + static int si_dpm_get_fan_speed_pwm(void *handle, 6543 6543 u32 *speed) 6544 6544 { 6545 6545 u32 duty, duty100; ··· 6555 6555 if (duty100 == 0) 6556 6556 return -EINVAL; 6557 6557 6558 - tmp64 = (u64)duty * 100; 6558 + tmp64 = (u64)duty * 255; 6559 6559 do_div(tmp64, duty100); 6560 - *speed = (u32)tmp64; 6561 - 6562 - if (*speed > 100) 6563 - *speed = 100; 6560 + *speed = MIN((u32)tmp64, 255); 6564 6561 6565 6562 return 0; 6566 6563 } 6567 6564 6568 - static int si_dpm_set_fan_speed_percent(void *handle, 6565 + static int si_dpm_set_fan_speed_pwm(void *handle, 6569 6566 u32 speed) 6570 6567 { 6571 6568 struct amdgpu_device *adev = (struct amdgpu_device *)handle; ··· 6577 6580 if (si_pi->fan_is_controlled_by_smc) 6578 6581 return -EINVAL; 6579 6582 6580 - if (speed > 100) 6583 + if (speed > 255) 6581 6584 return -EINVAL; 6582 6585 6583 6586 duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT; ··· 6586 6589 return -EINVAL; 6587 6590 6588 6591 tmp64 = (u64)speed * duty100; 6589 - do_div(tmp64, 100); 6592 + do_div(tmp64, 255); 6590 6593 duty = (u32)tmp64; 6591 6594 6592 6595 tmp = RREG32(CG_FDO_CTRL0) & ~FDO_STATIC_DUTY_MASK; ··· 8056 8059 .vblank_too_short = &si_dpm_vblank_too_short, 8057 8060 .set_fan_control_mode = &si_dpm_set_fan_control_mode, 8058 8061 .get_fan_control_mode = &si_dpm_get_fan_control_mode, 8059 - .set_fan_speed_percent = &si_dpm_set_fan_speed_percent, 8060 - .get_fan_speed_percent = &si_dpm_get_fan_speed_percent, 8062 + .set_fan_speed_pwm = &si_dpm_set_fan_speed_pwm, 8063 + .get_fan_speed_pwm = &si_dpm_get_fan_speed_pwm, 8061 8064 .check_state_equal = &si_check_state_equal, 8062 8065 .get_vce_clock_state = amdgpu_get_vce_clock_state, 8063 8066 .read_sensor = &si_dpm_read_sensor,
+49 -37
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 58 58 enum amd_pp_task task_id, 59 59 bool lock_needed); 60 60 static int smu_reset(struct smu_context *smu); 61 - static int smu_set_fan_speed_percent(void *handle, u32 speed); 61 + static int smu_set_fan_speed_pwm(void *handle, u32 speed); 62 62 static int smu_set_fan_control_mode(struct smu_context *smu, int value); 63 63 static int smu_set_power_limit(void *handle, uint32_t limit); 64 64 static int smu_set_fan_speed_rpm(void *handle, uint32_t speed); ··· 403 403 } 404 404 405 405 /* set the user dpm fan configurations */ 406 - if (smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_MANUAL) { 406 + if (smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_MANUAL || 407 + smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_NONE) { 407 408 ret = smu_set_fan_control_mode(smu, smu->user_dpm_profile.fan_mode); 408 409 if (ret) { 410 + smu->user_dpm_profile.fan_speed_pwm = 0; 411 + smu->user_dpm_profile.fan_speed_rpm = 0; 412 + smu->user_dpm_profile.fan_mode = AMD_FAN_CTRL_AUTO; 409 413 dev_err(smu->adev->dev, "Failed to set manual fan control mode\n"); 410 - return; 411 414 } 412 415 413 - if (!ret && smu->user_dpm_profile.fan_speed_percent) { 414 - ret = smu_set_fan_speed_percent(smu, smu->user_dpm_profile.fan_speed_percent); 416 + if (smu->user_dpm_profile.fan_speed_pwm) { 417 + ret = smu_set_fan_speed_pwm(smu, smu->user_dpm_profile.fan_speed_pwm); 415 418 if (ret) 416 - dev_err(smu->adev->dev, "Failed to set manual fan speed\n"); 419 + dev_err(smu->adev->dev, "Failed to set manual fan speed in pwm\n"); 420 + } 421 + 422 + if (smu->user_dpm_profile.fan_speed_rpm) { 423 + ret = smu_set_fan_speed_rpm(smu, smu->user_dpm_profile.fan_speed_rpm); 424 + if (ret) 425 + dev_err(smu->adev->dev, "Failed to set manual fan speed in rpm\n"); 417 426 } 418 427 } 419 428 ··· 629 620 mutex_init(&smu->smu_baco.mutex); 630 621 smu->smu_baco.state = SMU_BACO_STATE_EXIT; 631 622 smu->smu_baco.platform_support = false; 623 + smu->user_dpm_profile.fan_mode = -1; 632 624 633 625 adev->powerplay.pp_handle = smu; 634 626 adev->powerplay.pp_funcs = &swsmu_pm_funcs; ··· 2189 2179 static int smu_set_fan_speed_rpm(void *handle, uint32_t speed) 2190 2180 { 2191 2181 struct smu_context *smu = handle; 2192 - u32 percent; 2193 2182 int ret = 0; 2194 2183 2195 2184 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) ··· 2196 2187 2197 2188 mutex_lock(&smu->mutex); 2198 2189 2199 - if (smu->ppt_funcs->set_fan_speed_percent) { 2200 - percent = speed * 100 / smu->fan_max_rpm; 2201 - ret = smu->ppt_funcs->set_fan_speed_percent(smu, percent); 2202 - if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) 2203 - smu->user_dpm_profile.fan_speed_percent = percent; 2190 + if (smu->ppt_funcs->set_fan_speed_rpm) { 2191 + ret = smu->ppt_funcs->set_fan_speed_rpm(smu, speed); 2192 + if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) { 2193 + smu->user_dpm_profile.flags |= SMU_CUSTOM_FAN_SPEED_RPM; 2194 + smu->user_dpm_profile.fan_speed_rpm = speed; 2195 + 2196 + /* Override custom PWM setting as they cannot co-exist */ 2197 + smu->user_dpm_profile.flags &= ~SMU_CUSTOM_FAN_SPEED_PWM; 2198 + smu->user_dpm_profile.fan_speed_pwm = 0; 2199 + } 2204 2200 } 2205 2201 2206 2202 mutex_unlock(&smu->mutex); ··· 2565 2551 2566 2552 /* reset user dpm fan speed */ 2567 2553 if (!ret && value != AMD_FAN_CTRL_MANUAL && 2568 - !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) 2569 - smu->user_dpm_profile.fan_speed_percent = 0; 2554 + !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) { 2555 + smu->user_dpm_profile.fan_speed_pwm = 0; 2556 + smu->user_dpm_profile.fan_speed_rpm = 0; 2557 + smu->user_dpm_profile.flags &= ~(SMU_CUSTOM_FAN_SPEED_RPM | SMU_CUSTOM_FAN_SPEED_PWM); 2558 + } 2570 2559 2571 2560 return ret; 2572 2561 } ··· 2582 2565 } 2583 2566 2584 2567 2585 - static int smu_get_fan_speed_percent(void *handle, u32 *speed) 2568 + static int smu_get_fan_speed_pwm(void *handle, u32 *speed) 2586 2569 { 2587 2570 struct smu_context *smu = handle; 2588 2571 int ret = 0; 2589 - uint32_t percent; 2590 2572 2591 2573 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) 2592 2574 return -EOPNOTSUPP; 2593 2575 2594 2576 mutex_lock(&smu->mutex); 2595 2577 2596 - if (smu->ppt_funcs->get_fan_speed_percent) { 2597 - ret = smu->ppt_funcs->get_fan_speed_percent(smu, &percent); 2598 - if (!ret) { 2599 - *speed = percent > 100 ? 100 : percent; 2600 - } 2601 - } 2578 + if (smu->ppt_funcs->get_fan_speed_pwm) 2579 + ret = smu->ppt_funcs->get_fan_speed_pwm(smu, speed); 2602 2580 2603 2581 mutex_unlock(&smu->mutex); 2604 - 2605 2582 2606 2583 return ret; 2607 2584 } 2608 2585 2609 - static int smu_set_fan_speed_percent(void *handle, u32 speed) 2586 + static int smu_set_fan_speed_pwm(void *handle, u32 speed) 2610 2587 { 2611 2588 struct smu_context *smu = handle; 2612 2589 int ret = 0; ··· 2610 2599 2611 2600 mutex_lock(&smu->mutex); 2612 2601 2613 - if (smu->ppt_funcs->set_fan_speed_percent) { 2614 - if (speed > 100) 2615 - speed = 100; 2616 - ret = smu->ppt_funcs->set_fan_speed_percent(smu, speed); 2617 - if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) 2618 - smu->user_dpm_profile.fan_speed_percent = speed; 2602 + if (smu->ppt_funcs->set_fan_speed_pwm) { 2603 + ret = smu->ppt_funcs->set_fan_speed_pwm(smu, speed); 2604 + if (!ret && !(smu->user_dpm_profile.flags & SMU_DPM_USER_PROFILE_RESTORE)) { 2605 + smu->user_dpm_profile.flags |= SMU_CUSTOM_FAN_SPEED_PWM; 2606 + smu->user_dpm_profile.fan_speed_pwm = speed; 2607 + 2608 + /* Override custom RPM setting as they cannot co-exist */ 2609 + smu->user_dpm_profile.flags &= ~SMU_CUSTOM_FAN_SPEED_RPM; 2610 + smu->user_dpm_profile.fan_speed_rpm = 0; 2611 + } 2619 2612 } 2620 2613 2621 2614 mutex_unlock(&smu->mutex); ··· 2631 2616 { 2632 2617 struct smu_context *smu = handle; 2633 2618 int ret = 0; 2634 - u32 percent; 2635 2619 2636 2620 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) 2637 2621 return -EOPNOTSUPP; 2638 2622 2639 2623 mutex_lock(&smu->mutex); 2640 2624 2641 - if (smu->ppt_funcs->get_fan_speed_percent) { 2642 - ret = smu->ppt_funcs->get_fan_speed_percent(smu, &percent); 2643 - *speed = percent * smu->fan_max_rpm / 100; 2644 - } 2625 + if (smu->ppt_funcs->get_fan_speed_rpm) 2626 + ret = smu->ppt_funcs->get_fan_speed_rpm(smu, speed); 2645 2627 2646 2628 mutex_unlock(&smu->mutex); 2647 2629 ··· 3055 3043 /* export for sysfs */ 3056 3044 .set_fan_control_mode = smu_pp_set_fan_control_mode, 3057 3045 .get_fan_control_mode = smu_get_fan_control_mode, 3058 - .set_fan_speed_percent = smu_set_fan_speed_percent, 3059 - .get_fan_speed_percent = smu_get_fan_speed_percent, 3046 + .set_fan_speed_pwm = smu_set_fan_speed_pwm, 3047 + .get_fan_speed_pwm = smu_get_fan_speed_pwm, 3060 3048 .force_clock_level = smu_force_ppclk_levels, 3061 3049 .print_clock_levels = smu_print_ppclk_levels, 3062 3050 .force_performance_level = smu_force_performance_level,
+168 -32
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
··· 81 81 82 82 #define smnPCIE_ESM_CTRL 0x111003D0 83 83 84 + #define mmCG_FDO_CTRL0_ARCT 0x8B 85 + #define mmCG_FDO_CTRL0_ARCT_BASE_IDX 0 86 + 87 + #define mmCG_FDO_CTRL1_ARCT 0x8C 88 + #define mmCG_FDO_CTRL1_ARCT_BASE_IDX 0 89 + 90 + #define mmCG_FDO_CTRL2_ARCT 0x8D 91 + #define mmCG_FDO_CTRL2_ARCT_BASE_IDX 0 92 + 93 + #define mmCG_TACH_CTRL_ARCT 0x8E 94 + #define mmCG_TACH_CTRL_ARCT_BASE_IDX 0 95 + 96 + #define mmCG_TACH_STATUS_ARCT 0x8F 97 + #define mmCG_TACH_STATUS_ARCT_BASE_IDX 0 98 + 99 + #define mmCG_THERMAL_STATUS_ARCT 0x90 100 + #define mmCG_THERMAL_STATUS_ARCT_BASE_IDX 0 101 + 84 102 static const struct cmn2asic_msg_mapping arcturus_message_map[SMU_MSG_MAX_COUNT] = { 85 103 MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 0), 86 104 MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion, 1), ··· 181 163 FEA_MAP(DPM_SOCCLK), 182 164 FEA_MAP(DPM_FCLK), 183 165 FEA_MAP(DPM_MP0CLK), 184 - ARCTURUS_FEA_MAP(SMU_FEATURE_XGMI_BIT, FEATURE_DPM_XGMI_BIT), 166 + FEA_MAP(DPM_XGMI), 185 167 FEA_MAP(DS_GFXCLK), 186 168 FEA_MAP(DS_SOCCLK), 187 169 FEA_MAP(DS_LCLK), 188 170 FEA_MAP(DS_FCLK), 189 171 FEA_MAP(DS_UCLK), 190 172 FEA_MAP(GFX_ULV), 191 - ARCTURUS_FEA_MAP(SMU_FEATURE_VCN_PG_BIT, FEATURE_DPM_VCN_BIT), 173 + ARCTURUS_FEA_MAP(SMU_FEATURE_VCN_DPM_BIT, FEATURE_DPM_VCN_BIT), 192 174 FEA_MAP(RSMU_SMN_CG), 193 175 FEA_MAP(WAFL_CG), 194 176 FEA_MAP(PPT), ··· 739 721 member_type = METRICS_AVERAGE_SOCCLK; 740 722 break; 741 723 case PPCLK_VCLK: 742 - if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) 724 + if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_DPM_BIT)) 743 725 member_type = METRICS_CURR_VCLK; 744 726 else 745 727 member_type = METRICS_AVERAGE_VCLK; 746 728 break; 747 729 case PPCLK_DCLK: 748 - if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) 730 + if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_DPM_BIT)) 749 731 member_type = METRICS_CURR_DCLK; 750 732 else 751 733 member_type = METRICS_AVERAGE_DCLK; ··· 774 756 uint32_t gen_speed, lane_width; 775 757 776 758 if (amdgpu_ras_intr_triggered()) 777 - return snprintf(buf, PAGE_SIZE, "unavailable\n"); 759 + return sysfs_emit(buf, "unavailable\n"); 778 760 779 761 dpm_context = smu_dpm->dpm_context; 780 762 ··· 798 780 * And it's safe to assume that is always the current clock. 799 781 */ 800 782 for (i = 0; i < clocks.num_levels; i++) 801 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, 783 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, 802 784 clocks.data[i].clocks_in_khz / 1000, 803 785 (clocks.num_levels == 1) ? "*" : 804 786 (arcturus_freqs_in_same_level( ··· 821 803 } 822 804 823 805 for (i = 0; i < clocks.num_levels; i++) 824 - size += sprintf(buf + size, "%d: %uMhz %s\n", 806 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 825 807 i, clocks.data[i].clocks_in_khz / 1000, 826 808 (clocks.num_levels == 1) ? "*" : 827 809 (arcturus_freqs_in_same_level( ··· 844 826 } 845 827 846 828 for (i = 0; i < clocks.num_levels; i++) 847 - size += sprintf(buf + size, "%d: %uMhz %s\n", 829 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 848 830 i, clocks.data[i].clocks_in_khz / 1000, 849 831 (clocks.num_levels == 1) ? "*" : 850 832 (arcturus_freqs_in_same_level( ··· 867 849 } 868 850 869 851 for (i = 0; i < single_dpm_table->count; i++) 870 - size += sprintf(buf + size, "%d: %uMhz %s\n", 852 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 871 853 i, single_dpm_table->dpm_levels[i].value, 872 854 (clocks.num_levels == 1) ? "*" : 873 855 (arcturus_freqs_in_same_level( ··· 890 872 } 891 873 892 874 for (i = 0; i < single_dpm_table->count; i++) 893 - size += sprintf(buf + size, "%d: %uMhz %s\n", 875 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 894 876 i, single_dpm_table->dpm_levels[i].value, 895 877 (clocks.num_levels == 1) ? "*" : 896 878 (arcturus_freqs_in_same_level( ··· 913 895 } 914 896 915 897 for (i = 0; i < single_dpm_table->count; i++) 916 - size += sprintf(buf + size, "%d: %uMhz %s\n", 898 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 917 899 i, single_dpm_table->dpm_levels[i].value, 918 900 (clocks.num_levels == 1) ? "*" : 919 901 (arcturus_freqs_in_same_level( ··· 924 906 case SMU_PCIE: 925 907 gen_speed = smu_v11_0_get_current_pcie_link_speed_level(smu); 926 908 lane_width = smu_v11_0_get_current_pcie_link_width_level(smu); 927 - size += sprintf(buf + size, "0: %s %s %dMhz *\n", 909 + size += sysfs_emit_at(buf, size, "0: %s %s %dMhz *\n", 928 910 (gen_speed == 0) ? "2.5GT/s," : 929 911 (gen_speed == 1) ? "5.0GT/s," : 930 912 (gen_speed == 2) ? "8.0GT/s," : ··· 1180 1162 return ret; 1181 1163 } 1182 1164 1183 - static int arcturus_get_fan_speed_percent(struct smu_context *smu, 1184 - uint32_t *speed) 1165 + static int arcturus_set_fan_static_mode(struct smu_context *smu, 1166 + uint32_t mode) 1185 1167 { 1186 - int ret; 1187 - u32 rpm; 1168 + struct amdgpu_device *adev = smu->adev; 1169 + 1170 + WREG32_SOC15(THM, 0, mmCG_FDO_CTRL2_ARCT, 1171 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL2_ARCT), 1172 + CG_FDO_CTRL2, TMIN, 0)); 1173 + WREG32_SOC15(THM, 0, mmCG_FDO_CTRL2_ARCT, 1174 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL2_ARCT), 1175 + CG_FDO_CTRL2, FDO_PWM_MODE, mode)); 1176 + 1177 + return 0; 1178 + } 1179 + 1180 + static int arcturus_get_fan_speed_rpm(struct smu_context *smu, 1181 + uint32_t *speed) 1182 + { 1183 + struct amdgpu_device *adev = smu->adev; 1184 + uint32_t crystal_clock_freq = 2500; 1185 + uint32_t tach_status; 1186 + uint64_t tmp64; 1187 + int ret = 0; 1188 1188 1189 1189 if (!speed) 1190 1190 return -EINVAL; ··· 1211 1175 case AMD_FAN_CTRL_AUTO: 1212 1176 ret = arcturus_get_smu_metrics_data(smu, 1213 1177 METRICS_CURR_FANSPEED, 1214 - &rpm); 1215 - if (!ret && smu->fan_max_rpm) 1216 - *speed = rpm * 100 / smu->fan_max_rpm; 1217 - return ret; 1178 + speed); 1179 + break; 1218 1180 default: 1219 - *speed = smu->user_dpm_profile.fan_speed_percent; 1181 + /* 1182 + * For pre Sienna Cichlid ASICs, the 0 RPM may be not correctly 1183 + * detected via register retrieving. To workaround this, we will 1184 + * report the fan speed as 0 RPM if user just requested such. 1185 + */ 1186 + if ((smu->user_dpm_profile.flags & SMU_CUSTOM_FAN_SPEED_RPM) 1187 + && !smu->user_dpm_profile.fan_speed_rpm) { 1188 + *speed = 0; 1189 + return 0; 1190 + } 1191 + 1192 + tmp64 = (uint64_t)crystal_clock_freq * 60 * 10000; 1193 + tach_status = RREG32_SOC15(THM, 0, mmCG_TACH_STATUS_ARCT); 1194 + if (tach_status) { 1195 + do_div(tmp64, tach_status); 1196 + *speed = (uint32_t)tmp64; 1197 + } else { 1198 + *speed = 0; 1199 + } 1200 + 1201 + break; 1202 + } 1203 + 1204 + return ret; 1205 + } 1206 + 1207 + static int arcturus_set_fan_speed_pwm(struct smu_context *smu, 1208 + uint32_t speed) 1209 + { 1210 + struct amdgpu_device *adev = smu->adev; 1211 + uint32_t duty100, duty; 1212 + uint64_t tmp64; 1213 + 1214 + speed = MIN(speed, 255); 1215 + 1216 + duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1_ARCT), 1217 + CG_FDO_CTRL1, FMAX_DUTY100); 1218 + if (!duty100) 1219 + return -EINVAL; 1220 + 1221 + tmp64 = (uint64_t)speed * duty100; 1222 + do_div(tmp64, 255); 1223 + duty = (uint32_t)tmp64; 1224 + 1225 + WREG32_SOC15(THM, 0, mmCG_FDO_CTRL0_ARCT, 1226 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL0_ARCT), 1227 + CG_FDO_CTRL0, FDO_STATIC_DUTY, duty)); 1228 + 1229 + return arcturus_set_fan_static_mode(smu, FDO_PWM_MODE_STATIC); 1230 + } 1231 + 1232 + static int arcturus_set_fan_speed_rpm(struct smu_context *smu, 1233 + uint32_t speed) 1234 + { 1235 + struct amdgpu_device *adev = smu->adev; 1236 + /* 1237 + * crystal_clock_freq used for fan speed rpm calculation is 1238 + * always 25Mhz. So, hardcode it as 2500(in 10K unit). 1239 + */ 1240 + uint32_t crystal_clock_freq = 2500; 1241 + uint32_t tach_period; 1242 + 1243 + tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); 1244 + WREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT, 1245 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT), 1246 + CG_TACH_CTRL, TARGET_PERIOD, 1247 + tach_period)); 1248 + 1249 + return arcturus_set_fan_static_mode(smu, FDO_PWM_MODE_STATIC_RPM); 1250 + } 1251 + 1252 + static int arcturus_get_fan_speed_pwm(struct smu_context *smu, 1253 + uint32_t *speed) 1254 + { 1255 + struct amdgpu_device *adev = smu->adev; 1256 + uint32_t duty100, duty; 1257 + uint64_t tmp64; 1258 + 1259 + /* 1260 + * For pre Sienna Cichlid ASICs, the 0 RPM may be not correctly 1261 + * detected via register retrieving. To workaround this, we will 1262 + * report the fan speed as 0 PWM if user just requested such. 1263 + */ 1264 + if ((smu->user_dpm_profile.flags & SMU_CUSTOM_FAN_SPEED_PWM) 1265 + && !smu->user_dpm_profile.fan_speed_pwm) { 1266 + *speed = 0; 1220 1267 return 0; 1221 1268 } 1269 + 1270 + duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1_ARCT), 1271 + CG_FDO_CTRL1, FMAX_DUTY100); 1272 + duty = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_THERMAL_STATUS_ARCT), 1273 + CG_THERMAL_STATUS, FDO_PWM_DUTY); 1274 + 1275 + if (duty100) { 1276 + tmp64 = (uint64_t)duty * 255; 1277 + do_div(tmp64, duty100); 1278 + *speed = MIN((uint32_t)tmp64, 255); 1279 + } else { 1280 + *speed = 0; 1281 + } 1282 + 1283 + return 0; 1222 1284 } 1223 1285 1224 1286 static int arcturus_get_fan_parameters(struct smu_context *smu) ··· 1406 1272 return result; 1407 1273 1408 1274 if (smu_version >= 0x360d00) 1409 - size += sprintf(buf + size, "%16s %s %s %s %s %s %s %s %s %s %s\n", 1275 + size += sysfs_emit_at(buf, size, "%16s %s %s %s %s %s %s %s %s %s %s\n", 1410 1276 title[0], title[1], title[2], title[3], title[4], title[5], 1411 1277 title[6], title[7], title[8], title[9], title[10]); 1412 1278 else 1413 - size += sprintf(buf + size, "%16s\n", 1279 + size += sysfs_emit_at(buf, size, "%16s\n", 1414 1280 title[0]); 1415 1281 1416 1282 for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) { ··· 1436 1302 } 1437 1303 } 1438 1304 1439 - size += sprintf(buf + size, "%2d %14s%s\n", 1305 + size += sysfs_emit_at(buf, size, "%2d %14s%s\n", 1440 1306 i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " "); 1441 1307 1442 1308 if (smu_version >= 0x360d00) { 1443 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1309 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1444 1310 " ", 1445 1311 0, 1446 1312 "GFXCLK", ··· 1454 1320 activity_monitor.Gfx_PD_Data_error_coeff, 1455 1321 activity_monitor.Gfx_PD_Data_error_rate_coeff); 1456 1322 1457 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1323 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1458 1324 " ", 1459 1325 1, 1460 1326 "UCLK", ··· 2050 1916 int ret = 0; 2051 1917 2052 1918 if (enable) { 2053 - if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) { 2054 - ret = smu_cmn_feature_set_enabled(smu, SMU_FEATURE_VCN_PG_BIT, 1); 1919 + if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_DPM_BIT)) { 1920 + ret = smu_cmn_feature_set_enabled(smu, SMU_FEATURE_VCN_DPM_BIT, 1); 2055 1921 if (ret) { 2056 1922 dev_err(smu->adev->dev, "[EnableVCNDPM] failed!\n"); 2057 1923 return ret; 2058 1924 } 2059 1925 } 2060 1926 } else { 2061 - if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) { 2062 - ret = smu_cmn_feature_set_enabled(smu, SMU_FEATURE_VCN_PG_BIT, 0); 1927 + if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_DPM_BIT)) { 1928 + ret = smu_cmn_feature_set_enabled(smu, SMU_FEATURE_VCN_DPM_BIT, 0); 2063 1929 if (ret) { 2064 1930 dev_err(smu->adev->dev, "[DisableVCNDPM] failed!\n"); 2065 1931 return ret; ··· 2404 2270 .print_clk_levels = arcturus_print_clk_levels, 2405 2271 .force_clk_levels = arcturus_force_clk_levels, 2406 2272 .read_sensor = arcturus_read_sensor, 2407 - .get_fan_speed_percent = arcturus_get_fan_speed_percent, 2273 + .get_fan_speed_pwm = arcturus_get_fan_speed_pwm, 2274 + .get_fan_speed_rpm = arcturus_get_fan_speed_rpm, 2408 2275 .get_power_profile_mode = arcturus_get_power_profile_mode, 2409 2276 .set_power_profile_mode = arcturus_set_power_profile_mode, 2410 2277 .set_performance_level = arcturus_set_performance_level, ··· 2450 2315 .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request, 2451 2316 .get_fan_control_mode = smu_v11_0_get_fan_control_mode, 2452 2317 .set_fan_control_mode = smu_v11_0_set_fan_control_mode, 2453 - .set_fan_speed_percent = smu_v11_0_set_fan_speed_percent, 2318 + .set_fan_speed_pwm = arcturus_set_fan_speed_pwm, 2319 + .set_fan_speed_rpm = arcturus_set_fan_speed_rpm, 2454 2320 .set_xgmi_pstate = smu_v11_0_set_xgmi_pstate, 2455 2321 .gfx_off_control = smu_v11_0_gfx_off_control, 2456 2322 .register_irq_handler = smu_v11_0_register_irq_handler,
+47 -42
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
··· 1303 1303 if (ret) 1304 1304 return size; 1305 1305 1306 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, value, 1306 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value, 1307 1307 cur_value == value ? "*" : ""); 1308 1308 } 1309 1309 } else { ··· 1321 1321 freq_values[1] = (freq_values[0] + freq_values[2]) / 2; 1322 1322 1323 1323 for (i = 0; i < 3; i++) { 1324 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, freq_values[i], 1324 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, freq_values[i], 1325 1325 i == mark_index ? "*" : ""); 1326 1326 } 1327 1327 ··· 1331 1331 gen_speed = smu_v11_0_get_current_pcie_link_speed_level(smu); 1332 1332 lane_width = smu_v11_0_get_current_pcie_link_width_level(smu); 1333 1333 for (i = 0; i < NUM_LINK_LEVELS; i++) 1334 - size += sprintf(buf + size, "%d: %s %s %dMhz %s\n", i, 1334 + size += sysfs_emit_at(buf, size, "%d: %s %s %dMhz %s\n", i, 1335 1335 (dpm_context->dpm_tables.pcie_table.pcie_gen[i] == 0) ? "2.5GT/s," : 1336 1336 (dpm_context->dpm_tables.pcie_table.pcie_gen[i] == 1) ? "5.0GT/s," : 1337 1337 (dpm_context->dpm_tables.pcie_table.pcie_gen[i] == 2) ? "8.0GT/s," : ··· 1352 1352 break; 1353 1353 if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_LIMITS)) 1354 1354 break; 1355 - size += sprintf(buf + size, "OD_SCLK:\n"); 1356 - size += sprintf(buf + size, "0: %uMhz\n1: %uMhz\n", od_table->GfxclkFmin, od_table->GfxclkFmax); 1355 + size += sysfs_emit_at(buf, size, "OD_SCLK:\n"); 1356 + size += sysfs_emit_at(buf, size, "0: %uMhz\n1: %uMhz\n", 1357 + od_table->GfxclkFmin, od_table->GfxclkFmax); 1357 1358 break; 1358 1359 case SMU_OD_MCLK: 1359 1360 if (!smu->od_enabled || !od_table || !od_settings) 1360 1361 break; 1361 1362 if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_UCLK_MAX)) 1362 1363 break; 1363 - size += sprintf(buf + size, "OD_MCLK:\n"); 1364 - size += sprintf(buf + size, "1: %uMHz\n", od_table->UclkFmax); 1364 + size += sysfs_emit_at(buf, size, "OD_MCLK:\n"); 1365 + size += sysfs_emit_at(buf, size, "1: %uMHz\n", od_table->UclkFmax); 1365 1366 break; 1366 1367 case SMU_OD_VDDC_CURVE: 1367 1368 if (!smu->od_enabled || !od_table || !od_settings) 1368 1369 break; 1369 1370 if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_CURVE)) 1370 1371 break; 1371 - size += sprintf(buf + size, "OD_VDDC_CURVE:\n"); 1372 + size += sysfs_emit_at(buf, size, "OD_VDDC_CURVE:\n"); 1372 1373 for (i = 0; i < 3; i++) { 1373 1374 switch (i) { 1374 1375 case 0: ··· 1384 1383 default: 1385 1384 break; 1386 1385 } 1387 - size += sprintf(buf + size, "%d: %uMHz %umV\n", i, curve_settings[0], curve_settings[1] / NAVI10_VOLTAGE_SCALE); 1386 + size += sysfs_emit_at(buf, size, "%d: %uMHz %umV\n", 1387 + i, curve_settings[0], 1388 + curve_settings[1] / NAVI10_VOLTAGE_SCALE); 1388 1389 } 1389 1390 break; 1390 1391 case SMU_OD_RANGE: 1391 1392 if (!smu->od_enabled || !od_table || !od_settings) 1392 1393 break; 1393 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 1394 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 1394 1395 1395 1396 if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_LIMITS)) { 1396 1397 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_GFXCLKFMIN, 1397 1398 &min_value, NULL); 1398 1399 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_GFXCLKFMAX, 1399 1400 NULL, &max_value); 1400 - size += sprintf(buf + size, "SCLK: %7uMhz %10uMhz\n", 1401 + size += sysfs_emit_at(buf, size, "SCLK: %7uMhz %10uMhz\n", 1401 1402 min_value, max_value); 1402 1403 } 1403 1404 1404 1405 if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_UCLK_MAX)) { 1405 1406 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_UCLKFMAX, 1406 1407 &min_value, &max_value); 1407 - size += sprintf(buf + size, "MCLK: %7uMhz %10uMhz\n", 1408 + size += sysfs_emit_at(buf, size, "MCLK: %7uMhz %10uMhz\n", 1408 1409 min_value, max_value); 1409 1410 } 1410 1411 1411 1412 if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_CURVE)) { 1412 1413 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P1, 1413 1414 &min_value, &max_value); 1414 - size += sprintf(buf + size, "VDDC_CURVE_SCLK[0]: %7uMhz %10uMhz\n", 1415 - min_value, max_value); 1415 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_SCLK[0]: %7uMhz %10uMhz\n", 1416 + min_value, max_value); 1416 1417 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P1, 1417 1418 &min_value, &max_value); 1418 - size += sprintf(buf + size, "VDDC_CURVE_VOLT[0]: %7dmV %11dmV\n", 1419 - min_value, max_value); 1419 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_VOLT[0]: %7dmV %11dmV\n", 1420 + min_value, max_value); 1420 1421 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P2, 1421 1422 &min_value, &max_value); 1422 - size += sprintf(buf + size, "VDDC_CURVE_SCLK[1]: %7uMhz %10uMhz\n", 1423 - min_value, max_value); 1423 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_SCLK[1]: %7uMhz %10uMhz\n", 1424 + min_value, max_value); 1424 1425 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P2, 1425 1426 &min_value, &max_value); 1426 - size += sprintf(buf + size, "VDDC_CURVE_VOLT[1]: %7dmV %11dmV\n", 1427 - min_value, max_value); 1427 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_VOLT[1]: %7dmV %11dmV\n", 1428 + min_value, max_value); 1428 1429 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P3, 1429 1430 &min_value, &max_value); 1430 - size += sprintf(buf + size, "VDDC_CURVE_SCLK[2]: %7uMhz %10uMhz\n", 1431 - min_value, max_value); 1431 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_SCLK[2]: %7uMhz %10uMhz\n", 1432 + min_value, max_value); 1432 1433 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P3, 1433 1434 &min_value, &max_value); 1434 - size += sprintf(buf + size, "VDDC_CURVE_VOLT[2]: %7dmV %11dmV\n", 1435 - min_value, max_value); 1435 + size += sysfs_emit_at(buf, size, "VDDC_CURVE_VOLT[2]: %7dmV %11dmV\n", 1436 + min_value, max_value); 1436 1437 } 1437 1438 1438 1439 break; ··· 1671 1668 return !!(feature_enabled & SMC_DPM_FEATURE); 1672 1669 } 1673 1670 1674 - static int navi10_get_fan_speed_percent(struct smu_context *smu, 1675 - uint32_t *speed) 1671 + static int navi10_get_fan_speed_rpm(struct smu_context *smu, 1672 + uint32_t *speed) 1676 1673 { 1677 - int ret; 1678 - u32 rpm; 1674 + int ret = 0; 1679 1675 1680 1676 if (!speed) 1681 1677 return -EINVAL; 1682 1678 1683 1679 switch (smu_v11_0_get_fan_control_mode(smu)) { 1684 1680 case AMD_FAN_CTRL_AUTO: 1685 - ret = navi1x_get_smu_metrics_data(smu, 1681 + ret = navi10_get_smu_metrics_data(smu, 1686 1682 METRICS_CURR_FANSPEED, 1687 - &rpm); 1688 - if (!ret && smu->fan_max_rpm) 1689 - *speed = rpm * 100 / smu->fan_max_rpm; 1690 - return ret; 1683 + speed); 1684 + break; 1691 1685 default: 1692 - *speed = smu->user_dpm_profile.fan_speed_percent; 1693 - return 0; 1686 + ret = smu_v11_0_get_fan_speed_rpm(smu, 1687 + speed); 1688 + break; 1694 1689 } 1690 + 1691 + return ret; 1695 1692 } 1696 1693 1697 1694 static int navi10_get_fan_parameters(struct smu_context *smu) ··· 1733 1730 if (!buf) 1734 1731 return -EINVAL; 1735 1732 1736 - size += sprintf(buf + size, "%16s %s %s %s %s %s %s %s %s %s %s\n", 1733 + size += sysfs_emit_at(buf, size, "%16s %s %s %s %s %s %s %s %s %s %s\n", 1737 1734 title[0], title[1], title[2], title[3], title[4], title[5], 1738 1735 title[6], title[7], title[8], title[9], title[10]); 1739 1736 ··· 1753 1750 return result; 1754 1751 } 1755 1752 1756 - size += sprintf(buf + size, "%2d %14s%s:\n", 1753 + size += sysfs_emit_at(buf, size, "%2d %14s%s:\n", 1757 1754 i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " "); 1758 1755 1759 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1756 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1760 1757 " ", 1761 1758 0, 1762 1759 "GFXCLK", ··· 1770 1767 activity_monitor.Gfx_PD_Data_error_coeff, 1771 1768 activity_monitor.Gfx_PD_Data_error_rate_coeff); 1772 1769 1773 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1770 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1774 1771 " ", 1775 1772 1, 1776 1773 "SOCCLK", ··· 1784 1781 activity_monitor.Soc_PD_Data_error_coeff, 1785 1782 activity_monitor.Soc_PD_Data_error_rate_coeff); 1786 1783 1787 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1784 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1788 1785 " ", 1789 1786 2, 1790 1787 "MEMLK", ··· 3227 3224 .display_config_changed = navi10_display_config_changed, 3228 3225 .notify_smc_display_config = navi10_notify_smc_display_config, 3229 3226 .is_dpm_running = navi10_is_dpm_running, 3230 - .get_fan_speed_percent = navi10_get_fan_speed_percent, 3227 + .get_fan_speed_pwm = smu_v11_0_get_fan_speed_pwm, 3228 + .get_fan_speed_rpm = navi10_get_fan_speed_rpm, 3231 3229 .get_power_profile_mode = navi10_get_power_profile_mode, 3232 3230 .set_power_profile_mode = navi10_set_power_profile_mode, 3233 3231 .set_watermarks_table = navi10_set_watermarks_table, ··· 3271 3267 .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request, 3272 3268 .get_fan_control_mode = smu_v11_0_get_fan_control_mode, 3273 3269 .set_fan_control_mode = smu_v11_0_set_fan_control_mode, 3274 - .set_fan_speed_percent = smu_v11_0_set_fan_speed_percent, 3270 + .set_fan_speed_pwm = smu_v11_0_set_fan_speed_pwm, 3271 + .set_fan_speed_rpm = smu_v11_0_set_fan_speed_rpm, 3275 3272 .set_xgmi_pstate = smu_v11_0_set_xgmi_pstate, 3276 3273 .gfx_off_control = smu_v11_0_gfx_off_control, 3277 3274 .register_irq_handler = smu_v11_0_register_irq_handler,
+31 -36
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
··· 1088 1088 if (ret) 1089 1089 goto print_clk_out; 1090 1090 1091 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, value, 1091 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value, 1092 1092 cur_value == value ? "*" : ""); 1093 1093 } 1094 1094 } else { ··· 1110 1110 } 1111 1111 1112 1112 for (i = 0; i < count; i++) { 1113 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, freq_values[i], 1113 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, freq_values[i], 1114 1114 cur_value == freq_values[i] ? "*" : ""); 1115 1115 } 1116 1116 ··· 1121 1121 lane_width = smu_v11_0_get_current_pcie_link_width_level(smu); 1122 1122 GET_PPTABLE_MEMBER(LclkFreq, &table_member); 1123 1123 for (i = 0; i < NUM_LINK_LEVELS; i++) 1124 - size += sprintf(buf + size, "%d: %s %s %dMhz %s\n", i, 1124 + size += sysfs_emit_at(buf, size, "%d: %s %s %dMhz %s\n", i, 1125 1125 (dpm_context->dpm_tables.pcie_table.pcie_gen[i] == 0) ? "2.5GT/s," : 1126 1126 (dpm_context->dpm_tables.pcie_table.pcie_gen[i] == 1) ? "5.0GT/s," : 1127 1127 (dpm_context->dpm_tables.pcie_table.pcie_gen[i] == 2) ? "8.0GT/s," : ··· 1144 1144 if (!sienna_cichlid_is_od_feature_supported(od_settings, SMU_11_0_7_ODCAP_GFXCLK_LIMITS)) 1145 1145 break; 1146 1146 1147 - size += sprintf(buf + size, "OD_SCLK:\n"); 1148 - size += sprintf(buf + size, "0: %uMhz\n1: %uMhz\n", od_table->GfxclkFmin, od_table->GfxclkFmax); 1147 + size += sysfs_emit_at(buf, size, "OD_SCLK:\n"); 1148 + size += sysfs_emit_at(buf, size, "0: %uMhz\n1: %uMhz\n", od_table->GfxclkFmin, od_table->GfxclkFmax); 1149 1149 break; 1150 1150 1151 1151 case SMU_OD_MCLK: ··· 1155 1155 if (!sienna_cichlid_is_od_feature_supported(od_settings, SMU_11_0_7_ODCAP_UCLK_LIMITS)) 1156 1156 break; 1157 1157 1158 - size += sprintf(buf + size, "OD_MCLK:\n"); 1159 - size += sprintf(buf + size, "0: %uMhz\n1: %uMHz\n", od_table->UclkFmin, od_table->UclkFmax); 1158 + size += sysfs_emit_at(buf, size, "OD_MCLK:\n"); 1159 + size += sysfs_emit_at(buf, size, "0: %uMhz\n1: %uMHz\n", od_table->UclkFmin, od_table->UclkFmax); 1160 1160 break; 1161 1161 1162 1162 case SMU_OD_VDDGFX_OFFSET: ··· 1172 1172 (smu_version < 0x003a2900)) 1173 1173 break; 1174 1174 1175 - size += sprintf(buf + size, "OD_VDDGFX_OFFSET:\n"); 1176 - size += sprintf(buf + size, "%dmV\n", od_table->VddGfxOffset); 1175 + size += sysfs_emit_at(buf, size, "OD_VDDGFX_OFFSET:\n"); 1176 + size += sysfs_emit_at(buf, size, "%dmV\n", od_table->VddGfxOffset); 1177 1177 break; 1178 1178 1179 1179 case SMU_OD_RANGE: 1180 1180 if (!smu->od_enabled || !od_table || !od_settings) 1181 1181 break; 1182 1182 1183 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 1183 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 1184 1184 1185 1185 if (sienna_cichlid_is_od_feature_supported(od_settings, SMU_11_0_7_ODCAP_GFXCLK_LIMITS)) { 1186 1186 sienna_cichlid_get_od_setting_range(od_settings, SMU_11_0_7_ODSETTING_GFXCLKFMIN, 1187 1187 &min_value, NULL); 1188 1188 sienna_cichlid_get_od_setting_range(od_settings, SMU_11_0_7_ODSETTING_GFXCLKFMAX, 1189 1189 NULL, &max_value); 1190 - size += sprintf(buf + size, "SCLK: %7uMhz %10uMhz\n", 1190 + size += sysfs_emit_at(buf, size, "SCLK: %7uMhz %10uMhz\n", 1191 1191 min_value, max_value); 1192 1192 } 1193 1193 ··· 1196 1196 &min_value, NULL); 1197 1197 sienna_cichlid_get_od_setting_range(od_settings, SMU_11_0_7_ODSETTING_UCLKFMAX, 1198 1198 NULL, &max_value); 1199 - size += sprintf(buf + size, "MCLK: %7uMhz %10uMhz\n", 1199 + size += sysfs_emit_at(buf, size, "MCLK: %7uMhz %10uMhz\n", 1200 1200 min_value, max_value); 1201 1201 } 1202 1202 break; ··· 1354 1354 return !!(feature_enabled & SMC_DPM_FEATURE); 1355 1355 } 1356 1356 1357 - static int sienna_cichlid_get_fan_speed_percent(struct smu_context *smu, 1358 - uint32_t *speed) 1357 + static int sienna_cichlid_get_fan_speed_rpm(struct smu_context *smu, 1358 + uint32_t *speed) 1359 1359 { 1360 - int ret; 1361 - u32 rpm; 1362 - 1363 1360 if (!speed) 1364 1361 return -EINVAL; 1365 1362 1366 - switch (smu_v11_0_get_fan_control_mode(smu)) { 1367 - case AMD_FAN_CTRL_AUTO: 1368 - ret = sienna_cichlid_get_smu_metrics_data(smu, 1369 - METRICS_CURR_FANSPEED, 1370 - &rpm); 1371 - if (!ret && smu->fan_max_rpm) 1372 - *speed = rpm * 100 / smu->fan_max_rpm; 1373 - return ret; 1374 - default: 1375 - *speed = smu->user_dpm_profile.fan_speed_percent; 1376 - return 0; 1377 - } 1363 + /* 1364 + * For Sienna_Cichlid and later, the fan speed(rpm) reported 1365 + * by pmfw is always trustable(even when the fan control feature 1366 + * disabled or 0 RPM kicked in). 1367 + */ 1368 + return sienna_cichlid_get_smu_metrics_data(smu, 1369 + METRICS_CURR_FANSPEED, 1370 + speed); 1378 1371 } 1379 1372 1380 1373 static int sienna_cichlid_get_fan_parameters(struct smu_context *smu) ··· 1412 1419 if (!buf) 1413 1420 return -EINVAL; 1414 1421 1415 - size += sprintf(buf + size, "%16s %s %s %s %s %s %s %s %s %s %s\n", 1422 + size += sysfs_emit_at(buf, size, "%16s %s %s %s %s %s %s %s %s %s %s\n", 1416 1423 title[0], title[1], title[2], title[3], title[4], title[5], 1417 1424 title[6], title[7], title[8], title[9], title[10]); 1418 1425 ··· 1432 1439 return result; 1433 1440 } 1434 1441 1435 - size += sprintf(buf + size, "%2d %14s%s:\n", 1442 + size += sysfs_emit_at(buf, size, "%2d %14s%s:\n", 1436 1443 i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " "); 1437 1444 1438 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1445 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1439 1446 " ", 1440 1447 0, 1441 1448 "GFXCLK", ··· 1449 1456 activity_monitor->Gfx_PD_Data_error_coeff, 1450 1457 activity_monitor->Gfx_PD_Data_error_rate_coeff); 1451 1458 1452 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1459 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1453 1460 " ", 1454 1461 1, 1455 1462 "SOCCLK", ··· 1463 1470 activity_monitor->Fclk_PD_Data_error_coeff, 1464 1471 activity_monitor->Fclk_PD_Data_error_rate_coeff); 1465 1472 1466 - size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1473 + size += sysfs_emit_at(buf, size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", 1467 1474 " ", 1468 1475 2, 1469 1476 "MEMLK", ··· 3852 3859 .display_config_changed = sienna_cichlid_display_config_changed, 3853 3860 .notify_smc_display_config = sienna_cichlid_notify_smc_display_config, 3854 3861 .is_dpm_running = sienna_cichlid_is_dpm_running, 3855 - .get_fan_speed_percent = sienna_cichlid_get_fan_speed_percent, 3862 + .get_fan_speed_pwm = smu_v11_0_get_fan_speed_pwm, 3863 + .get_fan_speed_rpm = sienna_cichlid_get_fan_speed_rpm, 3856 3864 .get_power_profile_mode = sienna_cichlid_get_power_profile_mode, 3857 3865 .set_power_profile_mode = sienna_cichlid_set_power_profile_mode, 3858 3866 .set_watermarks_table = sienna_cichlid_set_watermarks_table, ··· 3896 3902 .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request, 3897 3903 .get_fan_control_mode = smu_v11_0_get_fan_control_mode, 3898 3904 .set_fan_control_mode = smu_v11_0_set_fan_control_mode, 3899 - .set_fan_speed_percent = smu_v11_0_set_fan_speed_percent, 3905 + .set_fan_speed_pwm = smu_v11_0_set_fan_speed_pwm, 3906 + .set_fan_speed_rpm = smu_v11_0_set_fan_speed_rpm, 3900 3907 .set_xgmi_pstate = smu_v11_0_set_xgmi_pstate, 3901 3908 .gfx_off_control = smu_v11_0_gfx_off_control, 3902 3909 .register_irq_handler = smu_v11_0_register_irq_handler,
+99 -8
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
··· 1200 1200 } 1201 1201 1202 1202 int 1203 - smu_v11_0_set_fan_speed_percent(struct smu_context *smu, uint32_t speed) 1203 + smu_v11_0_set_fan_speed_pwm(struct smu_context *smu, uint32_t speed) 1204 1204 { 1205 1205 struct amdgpu_device *adev = smu->adev; 1206 1206 uint32_t duty100, duty; 1207 1207 uint64_t tmp64; 1208 1208 1209 - if (speed > 100) 1210 - speed = 100; 1211 - 1212 - if (smu_v11_0_auto_fan_control(smu, 0)) 1213 - return -EINVAL; 1209 + speed = MIN(speed, 255); 1214 1210 1215 1211 duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1), 1216 1212 CG_FDO_CTRL1, FMAX_DUTY100); ··· 1214 1218 return -EINVAL; 1215 1219 1216 1220 tmp64 = (uint64_t)speed * duty100; 1217 - do_div(tmp64, 100); 1221 + do_div(tmp64, 255); 1218 1222 duty = (uint32_t)tmp64; 1219 1223 1220 1224 WREG32_SOC15(THM, 0, mmCG_FDO_CTRL0, ··· 1222 1226 CG_FDO_CTRL0, FDO_STATIC_DUTY, duty)); 1223 1227 1224 1228 return smu_v11_0_set_fan_static_mode(smu, FDO_PWM_MODE_STATIC); 1229 + } 1230 + 1231 + int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu, 1232 + uint32_t speed) 1233 + { 1234 + struct amdgpu_device *adev = smu->adev; 1235 + /* 1236 + * crystal_clock_freq used for fan speed rpm calculation is 1237 + * always 25Mhz. So, hardcode it as 2500(in 10K unit). 1238 + */ 1239 + uint32_t crystal_clock_freq = 2500; 1240 + uint32_t tach_period; 1241 + 1242 + /* 1243 + * To prevent from possible overheat, some ASICs may have requirement 1244 + * for minimum fan speed: 1245 + * - For some NV10 SKU, the fan speed cannot be set lower than 1246 + * 700 RPM. 1247 + * - For some Sienna Cichlid SKU, the fan speed cannot be set 1248 + * lower than 500 RPM. 1249 + */ 1250 + tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); 1251 + WREG32_SOC15(THM, 0, mmCG_TACH_CTRL, 1252 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL), 1253 + CG_TACH_CTRL, TARGET_PERIOD, 1254 + tach_period)); 1255 + 1256 + return smu_v11_0_set_fan_static_mode(smu, FDO_PWM_MODE_STATIC_RPM); 1257 + } 1258 + 1259 + int smu_v11_0_get_fan_speed_pwm(struct smu_context *smu, 1260 + uint32_t *speed) 1261 + { 1262 + struct amdgpu_device *adev = smu->adev; 1263 + uint32_t duty100, duty; 1264 + uint64_t tmp64; 1265 + 1266 + /* 1267 + * For pre Sienna Cichlid ASICs, the 0 RPM may be not correctly 1268 + * detected via register retrieving. To workaround this, we will 1269 + * report the fan speed as 0 PWM if user just requested such. 1270 + */ 1271 + if ((smu->user_dpm_profile.flags & SMU_CUSTOM_FAN_SPEED_PWM) 1272 + && !smu->user_dpm_profile.fan_speed_pwm) { 1273 + *speed = 0; 1274 + return 0; 1275 + } 1276 + 1277 + duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1), 1278 + CG_FDO_CTRL1, FMAX_DUTY100); 1279 + duty = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_THERMAL_STATUS), 1280 + CG_THERMAL_STATUS, FDO_PWM_DUTY); 1281 + if (!duty100) 1282 + return -EINVAL; 1283 + 1284 + tmp64 = (uint64_t)duty * 255; 1285 + do_div(tmp64, duty100); 1286 + *speed = MIN((uint32_t)tmp64, 255); 1287 + 1288 + return 0; 1289 + } 1290 + 1291 + int smu_v11_0_get_fan_speed_rpm(struct smu_context *smu, 1292 + uint32_t *speed) 1293 + { 1294 + struct amdgpu_device *adev = smu->adev; 1295 + uint32_t crystal_clock_freq = 2500; 1296 + uint32_t tach_status; 1297 + uint64_t tmp64; 1298 + 1299 + /* 1300 + * For pre Sienna Cichlid ASICs, the 0 RPM may be not correctly 1301 + * detected via register retrieving. To workaround this, we will 1302 + * report the fan speed as 0 RPM if user just requested such. 1303 + */ 1304 + if ((smu->user_dpm_profile.flags & SMU_CUSTOM_FAN_SPEED_RPM) 1305 + && !smu->user_dpm_profile.fan_speed_rpm) { 1306 + *speed = 0; 1307 + return 0; 1308 + } 1309 + 1310 + tmp64 = (uint64_t)crystal_clock_freq * 60 * 10000; 1311 + 1312 + tach_status = RREG32_SOC15(THM, 0, mmCG_TACH_STATUS); 1313 + if (tach_status) { 1314 + do_div(tmp64, tach_status); 1315 + *speed = (uint32_t)tmp64; 1316 + } else { 1317 + dev_warn_once(adev->dev, "Got zero output on CG_TACH_STATUS reading!\n"); 1318 + *speed = 0; 1319 + } 1320 + 1321 + return 0; 1225 1322 } 1226 1323 1227 1324 int ··· 1325 1236 1326 1237 switch (mode) { 1327 1238 case AMD_FAN_CTRL_NONE: 1328 - ret = smu_v11_0_set_fan_speed_percent(smu, 100); 1239 + ret = smu_v11_0_auto_fan_control(smu, 0); 1240 + if (!ret) 1241 + ret = smu_v11_0_set_fan_speed_pwm(smu, 255); 1329 1242 break; 1330 1243 case AMD_FAN_CTRL_MANUAL: 1331 1244 ret = smu_v11_0_auto_fan_control(smu, 0);
+23 -23
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
··· 592 592 switch (clk_type) { 593 593 case SMU_OD_SCLK: 594 594 if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) { 595 - size = sprintf(buf, "%s:\n", "OD_SCLK"); 596 - size += sprintf(buf + size, "0: %10uMhz\n", 595 + size = sysfs_emit(buf, "%s:\n", "OD_SCLK"); 596 + size += sysfs_emit_at(buf, size, "0: %10uMhz\n", 597 597 (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq); 598 - size += sprintf(buf + size, "1: %10uMhz\n", 598 + size += sysfs_emit_at(buf, size, "1: %10uMhz\n", 599 599 (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq); 600 600 } 601 601 break; 602 602 case SMU_OD_CCLK: 603 603 if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) { 604 - size = sprintf(buf, "CCLK_RANGE in Core%d:\n", smu->cpu_core_id_select); 605 - size += sprintf(buf + size, "0: %10uMhz\n", 604 + size = sysfs_emit(buf, "CCLK_RANGE in Core%d:\n", smu->cpu_core_id_select); 605 + size += sysfs_emit_at(buf, size, "0: %10uMhz\n", 606 606 (smu->cpu_actual_soft_min_freq > 0) ? smu->cpu_actual_soft_min_freq : smu->cpu_default_soft_min_freq); 607 - size += sprintf(buf + size, "1: %10uMhz\n", 607 + size += sysfs_emit_at(buf, size, "1: %10uMhz\n", 608 608 (smu->cpu_actual_soft_max_freq > 0) ? smu->cpu_actual_soft_max_freq : smu->cpu_default_soft_max_freq); 609 609 } 610 610 break; 611 611 case SMU_OD_RANGE: 612 612 if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) { 613 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 614 - size += sprintf(buf + size, "SCLK: %7uMhz %10uMhz\n", 613 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 614 + size += sysfs_emit_at(buf, size, "SCLK: %7uMhz %10uMhz\n", 615 615 smu->gfx_default_hard_min_freq, smu->gfx_default_soft_max_freq); 616 - size += sprintf(buf + size, "CCLK: %7uMhz %10uMhz\n", 616 + size += sysfs_emit_at(buf, size, "CCLK: %7uMhz %10uMhz\n", 617 617 smu->cpu_default_soft_min_freq, smu->cpu_default_soft_max_freq); 618 618 } 619 619 break; ··· 656 656 return ret; 657 657 if (!value) 658 658 continue; 659 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, value, 659 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value, 660 660 cur_value == value ? "*" : ""); 661 661 if (cur_value == value) 662 662 cur_value_match_level = true; 663 663 } 664 664 665 665 if (!cur_value_match_level) 666 - size += sprintf(buf + size, " %uMhz *\n", cur_value); 666 + size += sysfs_emit_at(buf, size, " %uMhz *\n", cur_value); 667 667 break; 668 668 default: 669 669 break; ··· 691 691 switch (clk_type) { 692 692 case SMU_OD_SCLK: 693 693 if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) { 694 - size = sprintf(buf, "%s:\n", "OD_SCLK"); 695 - size += sprintf(buf + size, "0: %10uMhz\n", 694 + size = sysfs_emit(buf, "%s:\n", "OD_SCLK"); 695 + size += sysfs_emit_at(buf, size, "0: %10uMhz\n", 696 696 (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq); 697 - size += sprintf(buf + size, "1: %10uMhz\n", 697 + size += sysfs_emit_at(buf, size, "1: %10uMhz\n", 698 698 (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq); 699 699 } 700 700 break; 701 701 case SMU_OD_CCLK: 702 702 if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) { 703 - size = sprintf(buf, "CCLK_RANGE in Core%d:\n", smu->cpu_core_id_select); 704 - size += sprintf(buf + size, "0: %10uMhz\n", 703 + size = sysfs_emit(buf, "CCLK_RANGE in Core%d:\n", smu->cpu_core_id_select); 704 + size += sysfs_emit_at(buf, size, "0: %10uMhz\n", 705 705 (smu->cpu_actual_soft_min_freq > 0) ? smu->cpu_actual_soft_min_freq : smu->cpu_default_soft_min_freq); 706 - size += sprintf(buf + size, "1: %10uMhz\n", 706 + size += sysfs_emit_at(buf, size, "1: %10uMhz\n", 707 707 (smu->cpu_actual_soft_max_freq > 0) ? smu->cpu_actual_soft_max_freq : smu->cpu_default_soft_max_freq); 708 708 } 709 709 break; 710 710 case SMU_OD_RANGE: 711 711 if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) { 712 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 713 - size += sprintf(buf + size, "SCLK: %7uMhz %10uMhz\n", 712 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 713 + size += sysfs_emit_at(buf, size, "SCLK: %7uMhz %10uMhz\n", 714 714 smu->gfx_default_hard_min_freq, smu->gfx_default_soft_max_freq); 715 - size += sprintf(buf + size, "CCLK: %7uMhz %10uMhz\n", 715 + size += sysfs_emit_at(buf, size, "CCLK: %7uMhz %10uMhz\n", 716 716 smu->cpu_default_soft_min_freq, smu->cpu_default_soft_max_freq); 717 717 } 718 718 break; ··· 755 755 return ret; 756 756 if (!value) 757 757 continue; 758 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, value, 758 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value, 759 759 cur_value == value ? "*" : ""); 760 760 if (cur_value == value) 761 761 cur_value_match_level = true; 762 762 } 763 763 764 764 if (!cur_value_match_level) 765 - size += sprintf(buf + size, " %uMhz *\n", cur_value); 765 + size += sysfs_emit_at(buf, size, " %uMhz *\n", cur_value); 766 766 break; 767 767 default: 768 768 break; ··· 1035 1035 if (workload_type < 0) 1036 1036 continue; 1037 1037 1038 - size += sprintf(buf + size, "%2d %14s%s\n", 1038 + size += sysfs_emit_at(buf, size, "%2d %14s%s\n", 1039 1039 i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " "); 1040 1040 } 1041 1041
+10 -10
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
··· 510 510 0, &max); 511 511 if (ret) 512 512 return ret; 513 - size += sprintf(buf + size, "OD_RANGE\nSCLK: %10uMhz %10uMhz\n", min, max); 513 + size += sysfs_emit_at(buf, size, "OD_RANGE\nSCLK: %10uMhz %10uMhz\n", min, max); 514 514 } 515 515 break; 516 516 case SMU_OD_SCLK: 517 517 if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) { 518 518 min = (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq; 519 519 max = (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq; 520 - size += sprintf(buf + size, "OD_SCLK\n"); 521 - size += sprintf(buf + size, "0:%10uMhz\n", min); 522 - size += sprintf(buf + size, "1:%10uMhz\n", max); 520 + size += sysfs_emit_at(buf, size, "OD_SCLK\n"); 521 + size += sysfs_emit_at(buf, size, "0:%10uMhz\n", min); 522 + size += sysfs_emit_at(buf, size, "1:%10uMhz\n", max); 523 523 } 524 524 break; 525 525 case SMU_GFXCLK: ··· 536 536 else 537 537 i = 1; 538 538 539 - size += sprintf(buf + size, "0: %uMhz %s\n", min, 539 + size += sysfs_emit_at(buf, size, "0: %uMhz %s\n", min, 540 540 i == 0 ? "*" : ""); 541 - size += sprintf(buf + size, "1: %uMhz %s\n", 541 + size += sysfs_emit_at(buf, size, "1: %uMhz %s\n", 542 542 i == 1 ? cur_value : RENOIR_UMD_PSTATE_GFXCLK, 543 543 i == 1 ? "*" : ""); 544 - size += sprintf(buf + size, "2: %uMhz %s\n", max, 544 + size += sysfs_emit_at(buf, size, "2: %uMhz %s\n", max, 545 545 i == 2 ? "*" : ""); 546 546 } 547 547 return size; ··· 588 588 return ret; 589 589 if (!value) 590 590 continue; 591 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, value, 591 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value, 592 592 cur_value == value ? "*" : ""); 593 593 if (cur_value == value) 594 594 cur_value_match_level = true; 595 595 } 596 596 597 597 if (!cur_value_match_level) 598 - size += sprintf(buf + size, " %uMhz *\n", cur_value); 598 + size += sysfs_emit_at(buf, size, " %uMhz *\n", cur_value); 599 599 600 600 break; 601 601 default: ··· 1118 1118 if (workload_type < 0) 1119 1119 continue; 1120 1120 1121 - size += sprintf(buf + size, "%2d %14s%s\n", 1121 + size += sysfs_emit_at(buf, size, "%2d %14s%s\n", 1122 1122 i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " "); 1123 1123 } 1124 1124
+27 -17
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
··· 90 90 MSG_MAP(GetDriverIfVersion, PPSMC_MSG_GetDriverIfVersion, 1), 91 91 MSG_MAP(EnableAllSmuFeatures, PPSMC_MSG_EnableAllSmuFeatures, 0), 92 92 MSG_MAP(DisableAllSmuFeatures, PPSMC_MSG_DisableAllSmuFeatures, 0), 93 - MSG_MAP(GetEnabledSmuFeaturesLow, PPSMC_MSG_GetEnabledSmuFeaturesLow, 0), 94 - MSG_MAP(GetEnabledSmuFeaturesHigh, PPSMC_MSG_GetEnabledSmuFeaturesHigh, 0), 93 + MSG_MAP(GetEnabledSmuFeaturesLow, PPSMC_MSG_GetEnabledSmuFeaturesLow, 1), 94 + MSG_MAP(GetEnabledSmuFeaturesHigh, PPSMC_MSG_GetEnabledSmuFeaturesHigh, 1), 95 95 MSG_MAP(SetDriverDramAddrHigh, PPSMC_MSG_SetDriverDramAddrHigh, 1), 96 96 MSG_MAP(SetDriverDramAddrLow, PPSMC_MSG_SetDriverDramAddrLow, 1), 97 97 MSG_MAP(SetToolsDramAddrHigh, PPSMC_MSG_SetToolsDramAddrHigh, 0), ··· 156 156 ALDEBARAN_FEA_MAP(SMU_FEATURE_DPM_SOCCLK_BIT, FEATURE_DPM_SOCCLK_BIT), 157 157 ALDEBARAN_FEA_MAP(SMU_FEATURE_DPM_FCLK_BIT, FEATURE_DPM_FCLK_BIT), 158 158 ALDEBARAN_FEA_MAP(SMU_FEATURE_DPM_LCLK_BIT, FEATURE_DPM_LCLK_BIT), 159 - ALDEBARAN_FEA_MAP(SMU_FEATURE_XGMI_BIT, FEATURE_DPM_XGMI_BIT), 159 + ALDEBARAN_FEA_MAP(SMU_FEATURE_DPM_XGMI_BIT, FEATURE_DPM_XGMI_BIT), 160 160 ALDEBARAN_FEA_MAP(SMU_FEATURE_DS_GFXCLK_BIT, FEATURE_DS_GFXCLK_BIT), 161 161 ALDEBARAN_FEA_MAP(SMU_FEATURE_DS_SOCCLK_BIT, FEATURE_DS_SOCCLK_BIT), 162 162 ALDEBARAN_FEA_MAP(SMU_FEATURE_DS_LCLK_BIT, FEATURE_DS_LCLK_BIT), 163 163 ALDEBARAN_FEA_MAP(SMU_FEATURE_DS_FCLK_BIT, FEATURE_DS_FCLK_BIT), 164 164 ALDEBARAN_FEA_MAP(SMU_FEATURE_DS_UCLK_BIT, FEATURE_DS_UCLK_BIT), 165 165 ALDEBARAN_FEA_MAP(SMU_FEATURE_GFX_SS_BIT, FEATURE_GFX_SS_BIT), 166 - ALDEBARAN_FEA_MAP(SMU_FEATURE_VCN_PG_BIT, FEATURE_DPM_VCN_BIT), 166 + ALDEBARAN_FEA_MAP(SMU_FEATURE_VCN_DPM_BIT, FEATURE_DPM_VCN_BIT), 167 167 ALDEBARAN_FEA_MAP(SMU_FEATURE_RSMU_SMN_CG_BIT, FEATURE_RSMU_SMN_CG_BIT), 168 168 ALDEBARAN_FEA_MAP(SMU_FEATURE_WAFL_CG_BIT, FEATURE_WAFL_CG_BIT), 169 169 ALDEBARAN_FEA_MAP(SMU_FEATURE_PPT_BIT, FEATURE_PPT_BIT), ··· 735 735 uint32_t min_clk, max_clk; 736 736 737 737 if (amdgpu_ras_intr_triggered()) 738 - return snprintf(buf, PAGE_SIZE, "unavailable\n"); 738 + return sysfs_emit(buf, "unavailable\n"); 739 739 740 740 dpm_context = smu_dpm->dpm_context; 741 741 742 742 switch (type) { 743 743 744 744 case SMU_OD_SCLK: 745 - size = sprintf(buf, "%s:\n", "GFXCLK"); 745 + size = sysfs_emit(buf, "%s:\n", "GFXCLK"); 746 746 fallthrough; 747 747 case SMU_SCLK: 748 748 ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_GFXCLK, &now); ··· 779 779 */ 780 780 if (display_levels == clocks.num_levels) { 781 781 for (i = 0; i < clocks.num_levels; i++) 782 - size += sprintf( 783 - buf + size, "%d: %uMhz %s\n", i, 782 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, 784 783 freq_values[i], 785 784 (clocks.num_levels == 1) ? 786 785 "*" : ··· 789 790 "")); 790 791 } else { 791 792 for (i = 0; i < display_levels; i++) 792 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, 793 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, 793 794 freq_values[i], i == 1 ? "*" : ""); 794 795 } 795 796 796 797 break; 797 798 798 799 case SMU_OD_MCLK: 799 - size = sprintf(buf, "%s:\n", "MCLK"); 800 + size = sysfs_emit(buf, "%s:\n", "MCLK"); 800 801 fallthrough; 801 802 case SMU_MCLK: 802 803 ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_UCLK, &now); ··· 813 814 } 814 815 815 816 for (i = 0; i < clocks.num_levels; i++) 816 - size += sprintf(buf + size, "%d: %uMhz %s\n", 817 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 817 818 i, clocks.data[i].clocks_in_khz / 1000, 818 819 (clocks.num_levels == 1) ? "*" : 819 820 (aldebaran_freqs_in_same_level( ··· 836 837 } 837 838 838 839 for (i = 0; i < clocks.num_levels; i++) 839 - size += sprintf(buf + size, "%d: %uMhz %s\n", 840 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 840 841 i, clocks.data[i].clocks_in_khz / 1000, 841 842 (clocks.num_levels == 1) ? "*" : 842 843 (aldebaran_freqs_in_same_level( ··· 859 860 } 860 861 861 862 for (i = 0; i < single_dpm_table->count; i++) 862 - size += sprintf(buf + size, "%d: %uMhz %s\n", 863 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 863 864 i, single_dpm_table->dpm_levels[i].value, 864 865 (clocks.num_levels == 1) ? "*" : 865 866 (aldebaran_freqs_in_same_level( ··· 882 883 } 883 884 884 885 for (i = 0; i < single_dpm_table->count; i++) 885 - size += sprintf(buf + size, "%d: %uMhz %s\n", 886 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 886 887 i, single_dpm_table->dpm_levels[i].value, 887 888 (clocks.num_levels == 1) ? "*" : 888 889 (aldebaran_freqs_in_same_level( ··· 905 906 } 906 907 907 908 for (i = 0; i < single_dpm_table->count; i++) 908 - size += sprintf(buf + size, "%d: %uMhz %s\n", 909 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", 909 910 i, single_dpm_table->dpm_levels[i].value, 910 911 (clocks.num_levels == 1) ? "*" : 911 912 (aldebaran_freqs_in_same_level( ··· 1193 1194 uint32_t power_limit = 0; 1194 1195 int ret; 1195 1196 1196 - if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_PPT_BIT)) 1197 - return -EINVAL; 1197 + if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_PPT_BIT)) { 1198 + if (current_power_limit) 1199 + *current_power_limit = 0; 1200 + if (default_power_limit) 1201 + *default_power_limit = 0; 1202 + if (max_power_limit) 1203 + *max_power_limit = 0; 1204 + 1205 + dev_warn(smu->adev->dev, 1206 + "PPT feature is not enabled, power values can't be fetched."); 1207 + 1208 + return 0; 1209 + } 1198 1210 1199 1211 /* Valid power data is available only from primary die. 1200 1212 * For secondary die show the value as 0.
+75 -37
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
··· 85 85 const struct common_firmware_header *header; 86 86 struct amdgpu_firmware_info *ucode = NULL; 87 87 88 + /* doesn't need to load smu firmware in IOV mode */ 89 + if (amdgpu_sriov_vf(adev)) 90 + return 0; 91 + 88 92 switch (adev->asic_type) { 89 93 case CHIP_ALDEBARAN: 90 94 chip_name = "aldebaran"; ··· 272 268 return 0; 273 269 } 274 270 271 + static int smu_v13_0_get_pptable_from_vbios(struct smu_context *smu, void **table, uint32_t *size) 272 + { 273 + struct amdgpu_device *adev = smu->adev; 274 + uint16_t atom_table_size; 275 + uint8_t frev, crev; 276 + int ret, index; 277 + 278 + dev_info(adev->dev, "use vbios provided pptable\n"); 279 + index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, 280 + powerplayinfo); 281 + 282 + ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev, 283 + (uint8_t **)table); 284 + if (ret) 285 + return ret; 286 + 287 + if (size) 288 + *size = atom_table_size; 289 + 290 + return 0; 291 + } 292 + 293 + static int smu_v13_0_get_pptable_from_firmware(struct smu_context *smu, void **table, uint32_t *size, 294 + uint32_t pptable_id) 295 + { 296 + const struct smc_firmware_header_v1_0 *hdr; 297 + struct amdgpu_device *adev = smu->adev; 298 + uint16_t version_major, version_minor; 299 + int ret; 300 + 301 + hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data; 302 + if (!hdr) 303 + return -EINVAL; 304 + 305 + dev_info(adev->dev, "use driver provided pptable %d\n", pptable_id); 306 + 307 + version_major = le16_to_cpu(hdr->header.header_version_major); 308 + version_minor = le16_to_cpu(hdr->header.header_version_minor); 309 + if (version_major != 2) { 310 + dev_err(adev->dev, "Unsupported smu firmware version %d.%d\n", 311 + version_major, version_minor); 312 + return -EINVAL; 313 + } 314 + 315 + switch (version_minor) { 316 + case 1: 317 + ret = smu_v13_0_set_pptable_v2_1(smu, table, size, pptable_id); 318 + break; 319 + default: 320 + ret = -EINVAL; 321 + break; 322 + } 323 + 324 + return ret; 325 + } 326 + 275 327 int smu_v13_0_setup_pptable(struct smu_context *smu) 276 328 { 277 329 struct amdgpu_device *adev = smu->adev; 278 - const struct smc_firmware_header_v1_0 *hdr; 279 - int ret, index; 280 - uint32_t size = 0; 281 - uint16_t atom_table_size; 282 - uint8_t frev, crev; 330 + uint32_t size = 0, pptable_id = 0; 283 331 void *table; 284 - uint16_t version_major, version_minor; 332 + int ret = 0; 285 333 286 - 334 + /* override pptable_id from driver parameter */ 287 335 if (amdgpu_smu_pptable_id >= 0) { 288 - smu->smu_table.boot_values.pp_table_id = amdgpu_smu_pptable_id; 289 - dev_info(adev->dev, "override pptable id %d\n", amdgpu_smu_pptable_id); 290 - } 291 - 292 - hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data; 293 - version_major = le16_to_cpu(hdr->header.header_version_major); 294 - version_minor = le16_to_cpu(hdr->header.header_version_minor); 295 - if (version_major == 2 && smu->smu_table.boot_values.pp_table_id > 0) { 296 - dev_info(adev->dev, "use driver provided pptable %d\n", smu->smu_table.boot_values.pp_table_id); 297 - switch (version_minor) { 298 - case 1: 299 - ret = smu_v13_0_set_pptable_v2_1(smu, &table, &size, 300 - smu->smu_table.boot_values.pp_table_id); 301 - break; 302 - default: 303 - ret = -EINVAL; 304 - break; 305 - } 306 - if (ret) 307 - return ret; 308 - 336 + pptable_id = amdgpu_smu_pptable_id; 337 + dev_info(adev->dev, "override pptable id %d\n", pptable_id); 309 338 } else { 310 - dev_info(adev->dev, "use vbios provided pptable\n"); 311 - index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, 312 - powerplayinfo); 313 - 314 - ret = amdgpu_atombios_get_data_table(adev, index, &atom_table_size, &frev, &crev, 315 - (uint8_t **)&table); 316 - if (ret) 317 - return ret; 318 - size = atom_table_size; 339 + pptable_id = smu->smu_table.boot_values.pp_table_id; 319 340 } 341 + 342 + /* force using vbios pptable in sriov mode */ 343 + if (amdgpu_sriov_vf(adev) || !pptable_id) 344 + ret = smu_v13_0_get_pptable_from_vbios(smu, &table, &size); 345 + else 346 + ret = smu_v13_0_get_pptable_from_firmware(smu, &table, &size, pptable_id); 347 + 348 + if (ret) 349 + return ret; 320 350 321 351 if (!smu->smu_table.power_play_table) 322 352 smu->smu_table.power_play_table = table;
+7 -7
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c
··· 572 572 if (workload_type < 0) 573 573 continue; 574 574 575 - size += sprintf(buf + size, "%2d %14s%s\n", 575 + size += sysfs_emit_at(buf, size, "%2d %14s%s\n", 576 576 i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " "); 577 577 } 578 578 ··· 1054 1054 1055 1055 switch (clk_type) { 1056 1056 case SMU_OD_SCLK: 1057 - size = sprintf(buf, "%s:\n", "OD_SCLK"); 1058 - size += sprintf(buf + size, "0: %10uMhz\n", 1057 + size = sysfs_emit(buf, "%s:\n", "OD_SCLK"); 1058 + size += sysfs_emit_at(buf, size, "0: %10uMhz\n", 1059 1059 (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq); 1060 - size += sprintf(buf + size, "1: %10uMhz\n", 1060 + size += sysfs_emit_at(buf, size, "1: %10uMhz\n", 1061 1061 (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq); 1062 1062 break; 1063 1063 case SMU_OD_RANGE: 1064 - size = sprintf(buf, "%s:\n", "OD_RANGE"); 1065 - size += sprintf(buf + size, "SCLK: %7uMhz %10uMhz\n", 1064 + size = sysfs_emit(buf, "%s:\n", "OD_RANGE"); 1065 + size += sysfs_emit_at(buf, size, "SCLK: %7uMhz %10uMhz\n", 1066 1066 smu->gfx_default_hard_min_freq, smu->gfx_default_soft_max_freq); 1067 1067 break; 1068 1068 case SMU_SOCCLK: ··· 1083 1083 if (ret) 1084 1084 goto print_clk_out; 1085 1085 1086 - size += sprintf(buf + size, "%d: %uMhz %s\n", i, value, 1086 + size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value, 1087 1087 cur_value == value ? "*" : ""); 1088 1088 } 1089 1089 break;
+3 -3
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
··· 710 710 return 0; 711 711 } 712 712 713 - size = sprintf(buf + size, "features high: 0x%08x low: 0x%08x\n", 713 + size = sysfs_emit_at(buf, size, "features high: 0x%08x low: 0x%08x\n", 714 714 feature_mask[1], feature_mask[0]); 715 715 716 716 memset(sort_feature, -1, sizeof(sort_feature)); ··· 725 725 sort_feature[feature_index] = i; 726 726 } 727 727 728 - size += sprintf(buf + size, "%-2s. %-20s %-3s : %-s\n", 728 + size += sysfs_emit_at(buf, size, "%-2s. %-20s %-3s : %-s\n", 729 729 "No", "Feature", "Bit", "State"); 730 730 731 731 for (i = 0; i < SMU_FEATURE_COUNT; i++) { 732 732 if (sort_feature[i] < 0) 733 733 continue; 734 734 735 - size += sprintf(buf + size, "%02d. %-20s (%2d) : %s\n", 735 + size += sysfs_emit_at(buf, size, "%02d. %-20s (%2d) : %s\n", 736 736 count++, 737 737 smu_get_feature_name(smu, sort_feature[i]), 738 738 i,
+1
drivers/gpu/drm/radeon/radeon_fb.c
··· 168 168 break; 169 169 case 2: 170 170 tiling_flags |= RADEON_TILING_SWAP_16BIT; 171 + break; 171 172 default: 172 173 break; 173 174 }