aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c110
1 files changed, 80 insertions, 30 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index bd6e9a40f421..4b7824d30e73 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -190,8 +190,12 @@ static int amdgpu_firmware_info(struct drm_amdgpu_info_firmware *fw_info,
190 fw_info->ver = adev->uvd.fw_version; 190 fw_info->ver = adev->uvd.fw_version;
191 fw_info->feature = 0; 191 fw_info->feature = 0;
192 break; 192 break;
193 case AMDGPU_INFO_FW_VCN:
194 fw_info->ver = adev->vcn.fw_version;
195 fw_info->feature = 0;
196 break;
193 case AMDGPU_INFO_FW_GMC: 197 case AMDGPU_INFO_FW_GMC:
194 fw_info->ver = adev->mc.fw_version; 198 fw_info->ver = adev->gmc.fw_version;
195 fw_info->feature = 0; 199 fw_info->feature = 0;
196 break; 200 break;
197 case AMDGPU_INFO_FW_GFX_ME: 201 case AMDGPU_INFO_FW_GFX_ME:
@@ -470,9 +474,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
470 case AMDGPU_INFO_VRAM_GTT: { 474 case AMDGPU_INFO_VRAM_GTT: {
471 struct drm_amdgpu_info_vram_gtt vram_gtt; 475 struct drm_amdgpu_info_vram_gtt vram_gtt;
472 476
473 vram_gtt.vram_size = adev->mc.real_vram_size; 477 vram_gtt.vram_size = adev->gmc.real_vram_size;
474 vram_gtt.vram_size -= adev->vram_pin_size; 478 vram_gtt.vram_size -= adev->vram_pin_size;
475 vram_gtt.vram_cpu_accessible_size = adev->mc.visible_vram_size; 479 vram_gtt.vram_cpu_accessible_size = adev->gmc.visible_vram_size;
476 vram_gtt.vram_cpu_accessible_size -= (adev->vram_pin_size - adev->invisible_pin_size); 480 vram_gtt.vram_cpu_accessible_size -= (adev->vram_pin_size - adev->invisible_pin_size);
477 vram_gtt.gtt_size = adev->mman.bdev.man[TTM_PL_TT].size; 481 vram_gtt.gtt_size = adev->mman.bdev.man[TTM_PL_TT].size;
478 vram_gtt.gtt_size *= PAGE_SIZE; 482 vram_gtt.gtt_size *= PAGE_SIZE;
@@ -484,17 +488,17 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
484 struct drm_amdgpu_memory_info mem; 488 struct drm_amdgpu_memory_info mem;
485 489
486 memset(&mem, 0, sizeof(mem)); 490 memset(&mem, 0, sizeof(mem));
487 mem.vram.total_heap_size = adev->mc.real_vram_size; 491 mem.vram.total_heap_size = adev->gmc.real_vram_size;
488 mem.vram.usable_heap_size = 492 mem.vram.usable_heap_size =
489 adev->mc.real_vram_size - adev->vram_pin_size; 493 adev->gmc.real_vram_size - adev->vram_pin_size;
490 mem.vram.heap_usage = 494 mem.vram.heap_usage =
491 amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); 495 amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
492 mem.vram.max_allocation = mem.vram.usable_heap_size * 3 / 4; 496 mem.vram.max_allocation = mem.vram.usable_heap_size * 3 / 4;
493 497
494 mem.cpu_accessible_vram.total_heap_size = 498 mem.cpu_accessible_vram.total_heap_size =
495 adev->mc.visible_vram_size; 499 adev->gmc.visible_vram_size;
496 mem.cpu_accessible_vram.usable_heap_size = 500 mem.cpu_accessible_vram.usable_heap_size =
497 adev->mc.visible_vram_size - 501 adev->gmc.visible_vram_size -
498 (adev->vram_pin_size - adev->invisible_pin_size); 502 (adev->vram_pin_size - adev->invisible_pin_size);
499 mem.cpu_accessible_vram.heap_usage = 503 mem.cpu_accessible_vram.heap_usage =
500 amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]); 504 amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
@@ -580,11 +584,16 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
580 dev_info.ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION; 584 dev_info.ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION;
581 585
582 vm_size = adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE; 586 vm_size = adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE;
587 vm_size -= AMDGPU_VA_RESERVED_SIZE;
588
589 /* Older VCE FW versions are buggy and can handle only 40bits */
590 if (adev->vce.fw_version < AMDGPU_VCE_FW_53_45)
591 vm_size = min(vm_size, 1ULL << 40);
592
583 dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE; 593 dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE;
584 dev_info.virtual_address_max = 594 dev_info.virtual_address_max =
585 min(vm_size, AMDGPU_VA_HOLE_START); 595 min(vm_size, AMDGPU_VA_HOLE_START);
586 596
587 vm_size -= AMDGPU_VA_RESERVED_SIZE;
588 if (vm_size > AMDGPU_VA_HOLE_START) { 597 if (vm_size > AMDGPU_VA_HOLE_START) {
589 dev_info.high_va_offset = AMDGPU_VA_HOLE_END; 598 dev_info.high_va_offset = AMDGPU_VA_HOLE_END;
590 dev_info.high_va_max = AMDGPU_VA_HOLE_END | vm_size; 599 dev_info.high_va_max = AMDGPU_VA_HOLE_END | vm_size;
@@ -599,8 +608,8 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
599 sizeof(adev->gfx.cu_info.ao_cu_bitmap)); 608 sizeof(adev->gfx.cu_info.ao_cu_bitmap));
600 memcpy(&dev_info.cu_bitmap[0], &adev->gfx.cu_info.bitmap[0], 609 memcpy(&dev_info.cu_bitmap[0], &adev->gfx.cu_info.bitmap[0],
601 sizeof(adev->gfx.cu_info.bitmap)); 610 sizeof(adev->gfx.cu_info.bitmap));
602 dev_info.vram_type = adev->mc.vram_type; 611 dev_info.vram_type = adev->gmc.vram_type;
603 dev_info.vram_bit_width = adev->mc.vram_width; 612 dev_info.vram_bit_width = adev->gmc.vram_width;
604 dev_info.vce_harvest_config = adev->vce.harvest_config; 613 dev_info.vce_harvest_config = adev->vce.harvest_config;
605 dev_info.gc_double_offchip_lds_buf = 614 dev_info.gc_double_offchip_lds_buf =
606 adev->gfx.config.double_offchip_lds_buf; 615 adev->gfx.config.double_offchip_lds_buf;
@@ -758,6 +767,24 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
758 return -EINVAL; 767 return -EINVAL;
759 } 768 }
760 break; 769 break;
770 case AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK:
771 /* get stable pstate sclk in Mhz */
772 if (amdgpu_dpm_read_sensor(adev,
773 AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK,
774 (void *)&ui32, &ui32_size)) {
775 return -EINVAL;
776 }
777 ui32 /= 100;
778 break;
779 case AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK:
780 /* get stable pstate mclk in Mhz */
781 if (amdgpu_dpm_read_sensor(adev,
782 AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK,
783 (void *)&ui32, &ui32_size)) {
784 return -EINVAL;
785 }
786 ui32 /= 100;
787 break;
761 default: 788 default:
762 DRM_DEBUG_KMS("Invalid request %d\n", 789 DRM_DEBUG_KMS("Invalid request %d\n",
763 info->sensor_info.type); 790 info->sensor_info.type);
@@ -805,7 +832,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
805{ 832{
806 struct amdgpu_device *adev = dev->dev_private; 833 struct amdgpu_device *adev = dev->dev_private;
807 struct amdgpu_fpriv *fpriv; 834 struct amdgpu_fpriv *fpriv;
808 int r; 835 int r, pasid;
809 836
810 file_priv->driver_priv = NULL; 837 file_priv->driver_priv = NULL;
811 838
@@ -819,28 +846,25 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
819 goto out_suspend; 846 goto out_suspend;
820 } 847 }
821 848
822 r = amdgpu_vm_init(adev, &fpriv->vm, 849 pasid = amdgpu_pasid_alloc(16);
823 AMDGPU_VM_CONTEXT_GFX, 0); 850 if (pasid < 0) {
824 if (r) { 851 dev_warn(adev->dev, "No more PASIDs available!");
825 kfree(fpriv); 852 pasid = 0;
826 goto out_suspend;
827 } 853 }
854 r = amdgpu_vm_init(adev, &fpriv->vm, AMDGPU_VM_CONTEXT_GFX, pasid);
855 if (r)
856 goto error_pasid;
828 857
829 fpriv->prt_va = amdgpu_vm_bo_add(adev, &fpriv->vm, NULL); 858 fpriv->prt_va = amdgpu_vm_bo_add(adev, &fpriv->vm, NULL);
830 if (!fpriv->prt_va) { 859 if (!fpriv->prt_va) {
831 r = -ENOMEM; 860 r = -ENOMEM;
832 amdgpu_vm_fini(adev, &fpriv->vm); 861 goto error_vm;
833 kfree(fpriv);
834 goto out_suspend;
835 } 862 }
836 863
837 if (amdgpu_sriov_vf(adev)) { 864 if (amdgpu_sriov_vf(adev)) {
838 r = amdgpu_map_static_csa(adev, &fpriv->vm, &fpriv->csa_va); 865 r = amdgpu_map_static_csa(adev, &fpriv->vm, &fpriv->csa_va);
839 if (r) { 866 if (r)
840 amdgpu_vm_fini(adev, &fpriv->vm); 867 goto error_vm;
841 kfree(fpriv);
842 goto out_suspend;
843 }
844 } 868 }
845 869
846 mutex_init(&fpriv->bo_list_lock); 870 mutex_init(&fpriv->bo_list_lock);
@@ -849,6 +873,16 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
849 amdgpu_ctx_mgr_init(&fpriv->ctx_mgr); 873 amdgpu_ctx_mgr_init(&fpriv->ctx_mgr);
850 874
851 file_priv->driver_priv = fpriv; 875 file_priv->driver_priv = fpriv;
876 goto out_suspend;
877
878error_vm:
879 amdgpu_vm_fini(adev, &fpriv->vm);
880
881error_pasid:
882 if (pasid)
883 amdgpu_pasid_free(pasid);
884
885 kfree(fpriv);
852 886
853out_suspend: 887out_suspend:
854 pm_runtime_mark_last_busy(dev->dev); 888 pm_runtime_mark_last_busy(dev->dev);
@@ -871,6 +905,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
871 struct amdgpu_device *adev = dev->dev_private; 905 struct amdgpu_device *adev = dev->dev_private;
872 struct amdgpu_fpriv *fpriv = file_priv->driver_priv; 906 struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
873 struct amdgpu_bo_list *list; 907 struct amdgpu_bo_list *list;
908 struct amdgpu_bo *pd;
909 unsigned int pasid;
874 int handle; 910 int handle;
875 911
876 if (!fpriv) 912 if (!fpriv)
@@ -895,7 +931,13 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
895 amdgpu_bo_unreserve(adev->virt.csa_obj); 931 amdgpu_bo_unreserve(adev->virt.csa_obj);
896 } 932 }
897 933
934 pasid = fpriv->vm.pasid;
935 pd = amdgpu_bo_ref(fpriv->vm.root.base.bo);
936
898 amdgpu_vm_fini(adev, &fpriv->vm); 937 amdgpu_vm_fini(adev, &fpriv->vm);
938 if (pasid)
939 amdgpu_pasid_free_delayed(pd->tbo.resv, pasid);
940 amdgpu_bo_unref(&pd);
899 941
900 idr_for_each_entry(&fpriv->bo_list_handles, list, handle) 942 idr_for_each_entry(&fpriv->bo_list_handles, list, handle)
901 amdgpu_bo_list_free(list); 943 amdgpu_bo_list_free(list);
@@ -947,11 +989,11 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
947 */ 989 */
948 do { 990 do {
949 count = amdgpu_display_vblank_get_counter(adev, pipe); 991 count = amdgpu_display_vblank_get_counter(adev, pipe);
950 /* Ask amdgpu_get_crtc_scanoutpos to return vpos as 992 /* Ask amdgpu_display_get_crtc_scanoutpos to return
951 * distance to start of vblank, instead of regular 993 * vpos as distance to start of vblank, instead of
952 * vertical scanout pos. 994 * regular vertical scanout pos.
953 */ 995 */
954 stat = amdgpu_get_crtc_scanoutpos( 996 stat = amdgpu_display_get_crtc_scanoutpos(
955 dev, pipe, GET_DISTANCE_TO_VBLANKSTART, 997 dev, pipe, GET_DISTANCE_TO_VBLANKSTART,
956 &vpos, &hpos, NULL, NULL, 998 &vpos, &hpos, NULL, NULL,
957 &adev->mode_info.crtcs[pipe]->base.hwmode); 999 &adev->mode_info.crtcs[pipe]->base.hwmode);
@@ -992,7 +1034,7 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
992int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe) 1034int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe)
993{ 1035{
994 struct amdgpu_device *adev = dev->dev_private; 1036 struct amdgpu_device *adev = dev->dev_private;
995 int idx = amdgpu_crtc_idx_to_irq_type(adev, pipe); 1037 int idx = amdgpu_display_crtc_idx_to_irq_type(adev, pipe);
996 1038
997 return amdgpu_irq_get(adev, &adev->crtc_irq, idx); 1039 return amdgpu_irq_get(adev, &adev->crtc_irq, idx);
998} 1040}
@@ -1008,7 +1050,7 @@ int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe)
1008void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe) 1050void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
1009{ 1051{
1010 struct amdgpu_device *adev = dev->dev_private; 1052 struct amdgpu_device *adev = dev->dev_private;
1011 int idx = amdgpu_crtc_idx_to_irq_type(adev, pipe); 1053 int idx = amdgpu_display_crtc_idx_to_irq_type(adev, pipe);
1012 1054
1013 amdgpu_irq_put(adev, &adev->crtc_irq, idx); 1055 amdgpu_irq_put(adev, &adev->crtc_irq, idx);
1014} 1056}
@@ -1160,6 +1202,14 @@ static int amdgpu_debugfs_firmware_info(struct seq_file *m, void *data)
1160 i, fw_info.feature, fw_info.ver); 1202 i, fw_info.feature, fw_info.ver);
1161 } 1203 }
1162 1204
1205 /* VCN */
1206 query_fw.fw_type = AMDGPU_INFO_FW_VCN;
1207 ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
1208 if (ret)
1209 return ret;
1210 seq_printf(m, "VCN feature version: %u, firmware version: 0x%08x\n",
1211 fw_info.feature, fw_info.ver);
1212
1163 return 0; 1213 return 0;
1164} 1214}
1165 1215