diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index 7a8bfa34682f..017556ca22e6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | |||
@@ -146,7 +146,8 @@ static int amdgpu_cgs_alloc_gpu_mem(struct cgs_device *cgs_device, | |||
146 | switch(type) { | 146 | switch(type) { |
147 | case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB: | 147 | case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB: |
148 | case CGS_GPU_MEM_TYPE__VISIBLE_FB: | 148 | case CGS_GPU_MEM_TYPE__VISIBLE_FB: |
149 | flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; | 149 | flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | |
150 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; | ||
150 | domain = AMDGPU_GEM_DOMAIN_VRAM; | 151 | domain = AMDGPU_GEM_DOMAIN_VRAM; |
151 | if (max_offset > adev->mc.real_vram_size) | 152 | if (max_offset > adev->mc.real_vram_size) |
152 | return -EINVAL; | 153 | return -EINVAL; |
@@ -157,7 +158,8 @@ static int amdgpu_cgs_alloc_gpu_mem(struct cgs_device *cgs_device, | |||
157 | break; | 158 | break; |
158 | case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB: | 159 | case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB: |
159 | case CGS_GPU_MEM_TYPE__INVISIBLE_FB: | 160 | case CGS_GPU_MEM_TYPE__INVISIBLE_FB: |
160 | flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS; | 161 | flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS | |
162 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; | ||
161 | domain = AMDGPU_GEM_DOMAIN_VRAM; | 163 | domain = AMDGPU_GEM_DOMAIN_VRAM; |
162 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size) { | 164 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size) { |
163 | place.fpfn = | 165 | place.fpfn = |
@@ -240,7 +242,7 @@ static int amdgpu_cgs_gmap_gpu_mem(struct cgs_device *cgs_device, cgs_handle_t h | |||
240 | r = amdgpu_bo_reserve(obj, false); | 242 | r = amdgpu_bo_reserve(obj, false); |
241 | if (unlikely(r != 0)) | 243 | if (unlikely(r != 0)) |
242 | return r; | 244 | return r; |
243 | r = amdgpu_bo_pin_restricted(obj, AMDGPU_GEM_DOMAIN_GTT, | 245 | r = amdgpu_bo_pin_restricted(obj, obj->prefered_domains, |
244 | min_offset, max_offset, mcaddr); | 246 | min_offset, max_offset, mcaddr); |
245 | amdgpu_bo_unreserve(obj); | 247 | amdgpu_bo_unreserve(obj); |
246 | return r; | 248 | return r; |
@@ -624,11 +626,11 @@ static int amdgpu_cgs_set_clockgating_state(struct cgs_device *cgs_device, | |||
624 | int i, r = -1; | 626 | int i, r = -1; |
625 | 627 | ||
626 | for (i = 0; i < adev->num_ip_blocks; i++) { | 628 | for (i = 0; i < adev->num_ip_blocks; i++) { |
627 | if (!adev->ip_block_status[i].valid) | 629 | if (!adev->ip_blocks[i].status.valid) |
628 | continue; | 630 | continue; |
629 | 631 | ||
630 | if (adev->ip_blocks[i].type == block_type) { | 632 | if (adev->ip_blocks[i].version->type == block_type) { |
631 | r = adev->ip_blocks[i].funcs->set_clockgating_state( | 633 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state( |
632 | (void *)adev, | 634 | (void *)adev, |
633 | state); | 635 | state); |
634 | break; | 636 | break; |
@@ -645,11 +647,11 @@ static int amdgpu_cgs_set_powergating_state(struct cgs_device *cgs_device, | |||
645 | int i, r = -1; | 647 | int i, r = -1; |
646 | 648 | ||
647 | for (i = 0; i < adev->num_ip_blocks; i++) { | 649 | for (i = 0; i < adev->num_ip_blocks; i++) { |
648 | if (!adev->ip_block_status[i].valid) | 650 | if (!adev->ip_blocks[i].status.valid) |
649 | continue; | 651 | continue; |
650 | 652 | ||
651 | if (adev->ip_blocks[i].type == block_type) { | 653 | if (adev->ip_blocks[i].version->type == block_type) { |
652 | r = adev->ip_blocks[i].funcs->set_powergating_state( | 654 | r = adev->ip_blocks[i].version->funcs->set_powergating_state( |
653 | (void *)adev, | 655 | (void *)adev, |
654 | state); | 656 | state); |
655 | break; | 657 | break; |
@@ -685,15 +687,21 @@ static uint32_t fw_type_convert(struct cgs_device *cgs_device, uint32_t fw_type) | |||
685 | result = AMDGPU_UCODE_ID_CP_MEC1; | 687 | result = AMDGPU_UCODE_ID_CP_MEC1; |
686 | break; | 688 | break; |
687 | case CGS_UCODE_ID_CP_MEC_JT2: | 689 | case CGS_UCODE_ID_CP_MEC_JT2: |
688 | if (adev->asic_type == CHIP_TONGA || adev->asic_type == CHIP_POLARIS11 | 690 | /* for VI. JT2 should be the same as JT1, because: |
689 | || adev->asic_type == CHIP_POLARIS10) | 691 | 1, MEC2 and MEC1 use exactly same FW. |
690 | result = AMDGPU_UCODE_ID_CP_MEC2; | 692 | 2, JT2 is not pached but JT1 is. |
691 | else | 693 | */ |
694 | if (adev->asic_type >= CHIP_TOPAZ) | ||
692 | result = AMDGPU_UCODE_ID_CP_MEC1; | 695 | result = AMDGPU_UCODE_ID_CP_MEC1; |
696 | else | ||
697 | result = AMDGPU_UCODE_ID_CP_MEC2; | ||
693 | break; | 698 | break; |
694 | case CGS_UCODE_ID_RLC_G: | 699 | case CGS_UCODE_ID_RLC_G: |
695 | result = AMDGPU_UCODE_ID_RLC_G; | 700 | result = AMDGPU_UCODE_ID_RLC_G; |
696 | break; | 701 | break; |
702 | case CGS_UCODE_ID_STORAGE: | ||
703 | result = AMDGPU_UCODE_ID_STORAGE; | ||
704 | break; | ||
697 | default: | 705 | default: |
698 | DRM_ERROR("Firmware type not supported\n"); | 706 | DRM_ERROR("Firmware type not supported\n"); |
699 | } | 707 | } |
@@ -776,12 +784,18 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, | |||
776 | 784 | ||
777 | if ((type == CGS_UCODE_ID_CP_MEC_JT1) || | 785 | if ((type == CGS_UCODE_ID_CP_MEC_JT1) || |
778 | (type == CGS_UCODE_ID_CP_MEC_JT2)) { | 786 | (type == CGS_UCODE_ID_CP_MEC_JT2)) { |
779 | gpu_addr += le32_to_cpu(header->jt_offset) << 2; | 787 | gpu_addr += ALIGN(le32_to_cpu(header->header.ucode_size_bytes), PAGE_SIZE); |
780 | data_size = le32_to_cpu(header->jt_size) << 2; | 788 | data_size = le32_to_cpu(header->jt_size) << 2; |
781 | } | 789 | } |
782 | info->mc_addr = gpu_addr; | 790 | |
791 | info->kptr = ucode->kaddr; | ||
783 | info->image_size = data_size; | 792 | info->image_size = data_size; |
793 | info->mc_addr = gpu_addr; | ||
784 | info->version = (uint16_t)le32_to_cpu(header->header.ucode_version); | 794 | info->version = (uint16_t)le32_to_cpu(header->header.ucode_version); |
795 | |||
796 | if (CGS_UCODE_ID_CP_MEC == type) | ||
797 | info->image_size = (header->jt_offset) << 2; | ||
798 | |||
785 | info->fw_version = amdgpu_get_firmware_version(cgs_device, type); | 799 | info->fw_version = amdgpu_get_firmware_version(cgs_device, type); |
786 | info->feature_version = (uint16_t)le32_to_cpu(header->ucode_feature_version); | 800 | info->feature_version = (uint16_t)le32_to_cpu(header->ucode_feature_version); |
787 | } else { | 801 | } else { |
@@ -851,6 +865,12 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, | |||
851 | return 0; | 865 | return 0; |
852 | } | 866 | } |
853 | 867 | ||
868 | static int amdgpu_cgs_is_virtualization_enabled(void *cgs_device) | ||
869 | { | ||
870 | CGS_FUNC_ADEV; | ||
871 | return amdgpu_sriov_vf(adev); | ||
872 | } | ||
873 | |||
854 | static int amdgpu_cgs_query_system_info(struct cgs_device *cgs_device, | 874 | static int amdgpu_cgs_query_system_info(struct cgs_device *cgs_device, |
855 | struct cgs_system_info *sys_info) | 875 | struct cgs_system_info *sys_info) |
856 | { | 876 | { |
@@ -1204,6 +1224,7 @@ static const struct cgs_ops amdgpu_cgs_ops = { | |||
1204 | amdgpu_cgs_notify_dpm_enabled, | 1224 | amdgpu_cgs_notify_dpm_enabled, |
1205 | amdgpu_cgs_call_acpi_method, | 1225 | amdgpu_cgs_call_acpi_method, |
1206 | amdgpu_cgs_query_system_info, | 1226 | amdgpu_cgs_query_system_info, |
1227 | amdgpu_cgs_is_virtualization_enabled | ||
1207 | }; | 1228 | }; |
1208 | 1229 | ||
1209 | static const struct cgs_os_ops amdgpu_cgs_os_ops = { | 1230 | static const struct cgs_os_ops amdgpu_cgs_os_ops = { |