diff options
| author | Dave Airlie <airlied@redhat.com> | 2018-09-27 19:48:35 -0400 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2018-09-27 19:48:40 -0400 |
| commit | 87c2ee740c07f1edae9eec8bc45cb9b32a68f323 (patch) | |
| tree | 1515f53eacb86689f2f96279e51cf0053ae8a308 /drivers/gpu | |
| parent | 2de0b0a158bf423208c3898522c8fa1c1078df48 (diff) | |
| parent | 6a96243056217662843694a4cbc83158d0e84403 (diff) | |
Merge branch 'drm-next-4.20' of git://people.freedesktop.org/~agd5f/linux into drm-next
More new features and fixes for 4.20:
- Add dynamic powergating support for VCN on picasso
- Scheduler cleanup
- Vega20 support for KFD
- DC cleanups and bug fixes
Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Alex Deucher <alexdeucher@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180927184348.2696-1-alexander.deucher@amd.com
Diffstat (limited to 'drivers/gpu')
116 files changed, 1841 insertions, 713 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 6cb35e3dab30..c05b39438663 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
| @@ -146,6 +146,7 @@ extern int amdgpu_cik_support; | |||
| 146 | #define AMDGPU_DEFAULT_GTT_SIZE_MB 3072ULL /* 3GB by default */ | 146 | #define AMDGPU_DEFAULT_GTT_SIZE_MB 3072ULL /* 3GB by default */ |
| 147 | #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 | 147 | #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 |
| 148 | #define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */ | 148 | #define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */ |
| 149 | #define AMDGPU_FENCE_JIFFIES_TIMEOUT (HZ / 2) | ||
| 149 | /* AMDGPU_IB_POOL_SIZE must be a power of 2 */ | 150 | /* AMDGPU_IB_POOL_SIZE must be a power of 2 */ |
| 150 | #define AMDGPU_IB_POOL_SIZE 16 | 151 | #define AMDGPU_IB_POOL_SIZE 16 |
| 151 | #define AMDGPU_DEBUGFS_MAX_COMPONENTS 32 | 152 | #define AMDGPU_DEBUGFS_MAX_COMPONENTS 32 |
| @@ -408,16 +409,25 @@ typedef enum _AMDGPU_DOORBELL64_ASSIGNMENT | |||
| 408 | AMDGPU_DOORBELL64_GFX_RING0 = 0x8b, | 409 | AMDGPU_DOORBELL64_GFX_RING0 = 0x8b, |
| 409 | 410 | ||
| 410 | /* | 411 | /* |
| 411 | * Other graphics doorbells can be allocated here: from 0x8c to 0xef | 412 | * Other graphics doorbells can be allocated here: from 0x8c to 0xdf |
| 412 | * Graphics voltage island aperture 1 | 413 | * Graphics voltage island aperture 1 |
| 413 | * default non-graphics QWORD index is 0xF0 - 0xFF inclusive | 414 | * default non-graphics QWORD index is 0xe0 - 0xFF inclusive |
| 414 | */ | 415 | */ |
| 415 | 416 | ||
| 416 | /* sDMA engines */ | 417 | /* sDMA engines reserved from 0xe0 -oxef */ |
| 417 | AMDGPU_DOORBELL64_sDMA_ENGINE0 = 0xF0, | 418 | AMDGPU_DOORBELL64_sDMA_ENGINE0 = 0xE0, |
| 418 | AMDGPU_DOORBELL64_sDMA_HI_PRI_ENGINE0 = 0xF1, | 419 | AMDGPU_DOORBELL64_sDMA_HI_PRI_ENGINE0 = 0xE1, |
| 419 | AMDGPU_DOORBELL64_sDMA_ENGINE1 = 0xF2, | 420 | AMDGPU_DOORBELL64_sDMA_ENGINE1 = 0xE8, |
| 420 | AMDGPU_DOORBELL64_sDMA_HI_PRI_ENGINE1 = 0xF3, | 421 | AMDGPU_DOORBELL64_sDMA_HI_PRI_ENGINE1 = 0xE9, |
| 422 | |||
| 423 | /* For vega10 sriov, the sdma doorbell must be fixed as follow | ||
| 424 | * to keep the same setting with host driver, or it will | ||
| 425 | * happen conflicts | ||
| 426 | */ | ||
| 427 | AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE0 = 0xF0, | ||
| 428 | AMDGPU_VEGA10_DOORBELL64_sDMA_HI_PRI_ENGINE0 = 0xF1, | ||
| 429 | AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE1 = 0xF2, | ||
| 430 | AMDGPU_VEGA10_DOORBELL64_sDMA_HI_PRI_ENGINE1 = 0xF3, | ||
| 421 | 431 | ||
| 422 | /* Interrupt handler */ | 432 | /* Interrupt handler */ |
| 423 | AMDGPU_DOORBELL64_IH = 0xF4, /* For legacy interrupt ring buffer */ | 433 | AMDGPU_DOORBELL64_IH = 0xF4, /* For legacy interrupt ring buffer */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c index 0f9947edb12a..c31a8849e9f8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | |||
| @@ -76,6 +76,7 @@ void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev) | |||
| 76 | kfd2kgd = amdgpu_amdkfd_gfx_8_0_get_functions(); | 76 | kfd2kgd = amdgpu_amdkfd_gfx_8_0_get_functions(); |
| 77 | break; | 77 | break; |
| 78 | case CHIP_VEGA10: | 78 | case CHIP_VEGA10: |
| 79 | case CHIP_VEGA20: | ||
| 79 | case CHIP_RAVEN: | 80 | case CHIP_RAVEN: |
| 80 | kfd2kgd = amdgpu_amdkfd_gfx_9_0_get_functions(); | 81 | kfd2kgd = amdgpu_amdkfd_gfx_9_0_get_functions(); |
| 81 | break; | 82 | break; |
| @@ -123,7 +124,7 @@ static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev, | |||
| 123 | 124 | ||
| 124 | void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) | 125 | void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) |
| 125 | { | 126 | { |
| 126 | int i; | 127 | int i, n; |
| 127 | int last_valid_bit; | 128 | int last_valid_bit; |
| 128 | if (adev->kfd) { | 129 | if (adev->kfd) { |
| 129 | struct kgd2kfd_shared_resources gpu_resources = { | 130 | struct kgd2kfd_shared_resources gpu_resources = { |
| @@ -162,7 +163,15 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) | |||
| 162 | &gpu_resources.doorbell_physical_address, | 163 | &gpu_resources.doorbell_physical_address, |
| 163 | &gpu_resources.doorbell_aperture_size, | 164 | &gpu_resources.doorbell_aperture_size, |
| 164 | &gpu_resources.doorbell_start_offset); | 165 | &gpu_resources.doorbell_start_offset); |
| 165 | if (adev->asic_type >= CHIP_VEGA10) { | 166 | |
| 167 | if (adev->asic_type < CHIP_VEGA10) { | ||
| 168 | kgd2kfd->device_init(adev->kfd, &gpu_resources); | ||
| 169 | return; | ||
| 170 | } | ||
| 171 | |||
| 172 | n = (adev->asic_type < CHIP_VEGA20) ? 2 : 8; | ||
| 173 | |||
| 174 | for (i = 0; i < n; i += 2) { | ||
| 166 | /* On SOC15 the BIF is involved in routing | 175 | /* On SOC15 the BIF is involved in routing |
| 167 | * doorbells using the low 12 bits of the | 176 | * doorbells using the low 12 bits of the |
| 168 | * address. Communicate the assignments to | 177 | * address. Communicate the assignments to |
| @@ -170,20 +179,31 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) | |||
| 170 | * process in case of 64-bit doorbells so we | 179 | * process in case of 64-bit doorbells so we |
| 171 | * can use each doorbell assignment twice. | 180 | * can use each doorbell assignment twice. |
| 172 | */ | 181 | */ |
| 173 | gpu_resources.sdma_doorbell[0][0] = | 182 | if (adev->asic_type == CHIP_VEGA10) { |
| 174 | AMDGPU_DOORBELL64_sDMA_ENGINE0; | 183 | gpu_resources.sdma_doorbell[0][i] = |
| 175 | gpu_resources.sdma_doorbell[0][1] = | 184 | AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE0 + (i >> 1); |
| 176 | AMDGPU_DOORBELL64_sDMA_ENGINE0 + 0x200; | 185 | gpu_resources.sdma_doorbell[0][i+1] = |
| 177 | gpu_resources.sdma_doorbell[1][0] = | 186 | AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE0 + 0x200 + (i >> 1); |
| 178 | AMDGPU_DOORBELL64_sDMA_ENGINE1; | 187 | gpu_resources.sdma_doorbell[1][i] = |
| 179 | gpu_resources.sdma_doorbell[1][1] = | 188 | AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE1 + (i >> 1); |
| 180 | AMDGPU_DOORBELL64_sDMA_ENGINE1 + 0x200; | 189 | gpu_resources.sdma_doorbell[1][i+1] = |
| 181 | /* Doorbells 0x0f0-0ff and 0x2f0-2ff are reserved for | 190 | AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE1 + 0x200 + (i >> 1); |
| 182 | * SDMA, IH and VCN. So don't use them for the CP. | 191 | } else { |
| 183 | */ | 192 | gpu_resources.sdma_doorbell[0][i] = |
| 184 | gpu_resources.reserved_doorbell_mask = 0x1f0; | 193 | AMDGPU_DOORBELL64_sDMA_ENGINE0 + (i >> 1); |
| 185 | gpu_resources.reserved_doorbell_val = 0x0f0; | 194 | gpu_resources.sdma_doorbell[0][i+1] = |
| 195 | AMDGPU_DOORBELL64_sDMA_ENGINE0 + 0x200 + (i >> 1); | ||
| 196 | gpu_resources.sdma_doorbell[1][i] = | ||
| 197 | AMDGPU_DOORBELL64_sDMA_ENGINE1 + (i >> 1); | ||
| 198 | gpu_resources.sdma_doorbell[1][i+1] = | ||
| 199 | AMDGPU_DOORBELL64_sDMA_ENGINE1 + 0x200 + (i >> 1); | ||
| 200 | } | ||
| 186 | } | 201 | } |
| 202 | /* Doorbells 0x0e0-0ff and 0x2e0-2ff are reserved for | ||
| 203 | * SDMA, IH and VCN. So don't use them for the CP. | ||
| 204 | */ | ||
| 205 | gpu_resources.reserved_doorbell_mask = 0x1e0; | ||
| 206 | gpu_resources.reserved_doorbell_val = 0x0e0; | ||
| 187 | 207 | ||
| 188 | kgd2kfd->device_init(adev->kfd, &gpu_resources); | 208 | kgd2kfd->device_init(adev->kfd, &gpu_resources); |
| 189 | } | 209 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h index 056fc6ef6c63..8e0d4f7196b4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | |||
| @@ -174,7 +174,7 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev, | |||
| 174 | struct amdgpu_vm *vm); | 174 | struct amdgpu_vm *vm); |
| 175 | void amdgpu_amdkfd_gpuvm_destroy_process_vm(struct kgd_dev *kgd, void *vm); | 175 | void amdgpu_amdkfd_gpuvm_destroy_process_vm(struct kgd_dev *kgd, void *vm); |
| 176 | void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *vm); | 176 | void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *vm); |
| 177 | uint32_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *vm); | 177 | uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *vm); |
| 178 | int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( | 178 | int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( |
| 179 | struct kgd_dev *kgd, uint64_t va, uint64_t size, | 179 | struct kgd_dev *kgd, uint64_t va, uint64_t size, |
| 180 | void *vm, struct kgd_mem **mem, | 180 | void *vm, struct kgd_mem **mem, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c index b2e45c8e2e0d..244d9834a381 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | |||
| @@ -142,7 +142,7 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type); | |||
| 142 | static void set_scratch_backing_va(struct kgd_dev *kgd, | 142 | static void set_scratch_backing_va(struct kgd_dev *kgd, |
| 143 | uint64_t va, uint32_t vmid); | 143 | uint64_t va, uint32_t vmid); |
| 144 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, | 144 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, |
| 145 | uint32_t page_table_base); | 145 | uint64_t page_table_base); |
| 146 | static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid); | 146 | static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid); |
| 147 | static int invalidate_tlbs_vmid(struct kgd_dev *kgd, uint16_t vmid); | 147 | static int invalidate_tlbs_vmid(struct kgd_dev *kgd, uint16_t vmid); |
| 148 | static uint32_t read_vmid_from_vmfault_reg(struct kgd_dev *kgd); | 148 | static uint32_t read_vmid_from_vmfault_reg(struct kgd_dev *kgd); |
| @@ -874,7 +874,7 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type) | |||
| 874 | } | 874 | } |
| 875 | 875 | ||
| 876 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, | 876 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, |
| 877 | uint32_t page_table_base) | 877 | uint64_t page_table_base) |
| 878 | { | 878 | { |
| 879 | struct amdgpu_device *adev = get_amdgpu_device(kgd); | 879 | struct amdgpu_device *adev = get_amdgpu_device(kgd); |
| 880 | 880 | ||
| @@ -882,7 +882,8 @@ static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, | |||
| 882 | pr_err("trying to set page table base for wrong VMID\n"); | 882 | pr_err("trying to set page table base for wrong VMID\n"); |
| 883 | return; | 883 | return; |
| 884 | } | 884 | } |
| 885 | WREG32(mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + vmid - 8, page_table_base); | 885 | WREG32(mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + vmid - 8, |
| 886 | lower_32_bits(page_table_base)); | ||
| 886 | } | 887 | } |
| 887 | 888 | ||
| 888 | static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid) | 889 | static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c index ea7c18ce7754..9f149914ad6c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | |||
| @@ -45,8 +45,6 @@ enum hqd_dequeue_request_type { | |||
| 45 | RESET_WAVES | 45 | RESET_WAVES |
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | struct vi_sdma_mqd; | ||
| 49 | |||
| 50 | /* | 48 | /* |
| 51 | * Register access functions | 49 | * Register access functions |
| 52 | */ | 50 | */ |
| @@ -100,7 +98,7 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type); | |||
| 100 | static void set_scratch_backing_va(struct kgd_dev *kgd, | 98 | static void set_scratch_backing_va(struct kgd_dev *kgd, |
| 101 | uint64_t va, uint32_t vmid); | 99 | uint64_t va, uint32_t vmid); |
| 102 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, | 100 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, |
| 103 | uint32_t page_table_base); | 101 | uint64_t page_table_base); |
| 104 | static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid); | 102 | static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid); |
| 105 | static int invalidate_tlbs_vmid(struct kgd_dev *kgd, uint16_t vmid); | 103 | static int invalidate_tlbs_vmid(struct kgd_dev *kgd, uint16_t vmid); |
| 106 | 104 | ||
| @@ -282,7 +280,8 @@ static int kgd_init_interrupts(struct kgd_dev *kgd, uint32_t pipe_id) | |||
| 282 | 280 | ||
| 283 | lock_srbm(kgd, mec, pipe, 0, 0); | 281 | lock_srbm(kgd, mec, pipe, 0, 0); |
| 284 | 282 | ||
| 285 | WREG32(mmCPC_INT_CNTL, CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK); | 283 | WREG32(mmCPC_INT_CNTL, CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK | |
| 284 | CP_INT_CNTL_RING0__OPCODE_ERROR_INT_ENABLE_MASK); | ||
| 286 | 285 | ||
| 287 | unlock_srbm(kgd); | 286 | unlock_srbm(kgd); |
| 288 | 287 | ||
| @@ -834,7 +833,7 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type) | |||
| 834 | } | 833 | } |
| 835 | 834 | ||
| 836 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, | 835 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, |
| 837 | uint32_t page_table_base) | 836 | uint64_t page_table_base) |
| 838 | { | 837 | { |
| 839 | struct amdgpu_device *adev = get_amdgpu_device(kgd); | 838 | struct amdgpu_device *adev = get_amdgpu_device(kgd); |
| 840 | 839 | ||
| @@ -842,7 +841,8 @@ static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, | |||
| 842 | pr_err("trying to set page table base for wrong VMID\n"); | 841 | pr_err("trying to set page table base for wrong VMID\n"); |
| 843 | return; | 842 | return; |
| 844 | } | 843 | } |
| 845 | WREG32(mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + vmid - 8, page_table_base); | 844 | WREG32(mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + vmid - 8, |
| 845 | lower_32_bits(page_table_base)); | ||
| 846 | } | 846 | } |
| 847 | 847 | ||
| 848 | static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid) | 848 | static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c index c9176537550b..42cb4c4e0929 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | |||
| @@ -138,7 +138,7 @@ static bool get_atc_vmid_pasid_mapping_valid(struct kgd_dev *kgd, | |||
| 138 | static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd, | 138 | static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd, |
| 139 | uint8_t vmid); | 139 | uint8_t vmid); |
| 140 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, | 140 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, |
| 141 | uint32_t page_table_base); | 141 | uint64_t page_table_base); |
| 142 | static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type); | 142 | static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type); |
| 143 | static void set_scratch_backing_va(struct kgd_dev *kgd, | 143 | static void set_scratch_backing_va(struct kgd_dev *kgd, |
| 144 | uint64_t va, uint32_t vmid); | 144 | uint64_t va, uint32_t vmid); |
| @@ -1013,11 +1013,10 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type) | |||
| 1013 | } | 1013 | } |
| 1014 | 1014 | ||
| 1015 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, | 1015 | static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, |
| 1016 | uint32_t page_table_base) | 1016 | uint64_t page_table_base) |
| 1017 | { | 1017 | { |
| 1018 | struct amdgpu_device *adev = get_amdgpu_device(kgd); | 1018 | struct amdgpu_device *adev = get_amdgpu_device(kgd); |
| 1019 | uint64_t base = (uint64_t)page_table_base << PAGE_SHIFT | | 1019 | uint64_t base = page_table_base | AMDGPU_PTE_VALID; |
| 1020 | AMDGPU_PTE_VALID; | ||
| 1021 | 1020 | ||
| 1022 | if (!amdgpu_amdkfd_is_kfd_vmid(adev, vmid)) { | 1021 | if (!amdgpu_amdkfd_is_kfd_vmid(adev, vmid)) { |
| 1023 | pr_err("trying to set page table base for wrong VMID %u\n", | 1022 | pr_err("trying to set page table base for wrong VMID %u\n", |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 6ee9dc476c86..df0a059565f9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | |||
| @@ -1131,11 +1131,15 @@ void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *vm) | |||
| 1131 | amdgpu_vm_release_compute(adev, avm); | 1131 | amdgpu_vm_release_compute(adev, avm); |
| 1132 | } | 1132 | } |
| 1133 | 1133 | ||
| 1134 | uint32_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *vm) | 1134 | uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *vm) |
| 1135 | { | 1135 | { |
| 1136 | struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; | 1136 | struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; |
| 1137 | struct amdgpu_bo *pd = avm->root.base.bo; | ||
| 1138 | struct amdgpu_device *adev = amdgpu_ttm_adev(pd->tbo.bdev); | ||
| 1137 | 1139 | ||
| 1138 | return avm->pd_phys_addr >> AMDGPU_GPU_PAGE_SHIFT; | 1140 | if (adev->asic_type < CHIP_VEGA10) |
| 1141 | return avm->pd_phys_addr >> AMDGPU_GPU_PAGE_SHIFT; | ||
| 1142 | return avm->pd_phys_addr; | ||
| 1139 | } | 1143 | } |
| 1140 | 1144 | ||
| 1141 | int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( | 1145 | int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 176f28777f5e..5448cf27654e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | |||
| @@ -196,6 +196,19 @@ int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s) | |||
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | /** | 198 | /** |
| 199 | * amdgpu_fence_schedule_fallback - schedule fallback check | ||
| 200 | * | ||
| 201 | * @ring: pointer to struct amdgpu_ring | ||
| 202 | * | ||
| 203 | * Start a timer as fallback to our interrupts. | ||
| 204 | */ | ||
| 205 | static void amdgpu_fence_schedule_fallback(struct amdgpu_ring *ring) | ||
| 206 | { | ||
| 207 | mod_timer(&ring->fence_drv.fallback_timer, | ||
| 208 | jiffies + AMDGPU_FENCE_JIFFIES_TIMEOUT); | ||
| 209 | } | ||
| 210 | |||
| 211 | /** | ||
| 199 | * amdgpu_fence_process - check for fence activity | 212 | * amdgpu_fence_process - check for fence activity |
| 200 | * | 213 | * |
| 201 | * @ring: pointer to struct amdgpu_ring | 214 | * @ring: pointer to struct amdgpu_ring |
| @@ -203,8 +216,10 @@ int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s) | |||
| 203 | * Checks the current fence value and calculates the last | 216 | * Checks the current fence value and calculates the last |
| 204 | * signalled fence value. Wakes the fence queue if the | 217 | * signalled fence value. Wakes the fence queue if the |
| 205 | * sequence number has increased. | 218 | * sequence number has increased. |
| 219 | * | ||
| 220 | * Returns true if fence was processed | ||
| 206 | */ | 221 | */ |
| 207 | void amdgpu_fence_process(struct amdgpu_ring *ring) | 222 | bool amdgpu_fence_process(struct amdgpu_ring *ring) |
| 208 | { | 223 | { |
| 209 | struct amdgpu_fence_driver *drv = &ring->fence_drv; | 224 | struct amdgpu_fence_driver *drv = &ring->fence_drv; |
| 210 | uint32_t seq, last_seq; | 225 | uint32_t seq, last_seq; |
| @@ -216,8 +231,12 @@ void amdgpu_fence_process(struct amdgpu_ring *ring) | |||
| 216 | 231 | ||
| 217 | } while (atomic_cmpxchg(&drv->last_seq, last_seq, seq) != last_seq); | 232 | } while (atomic_cmpxchg(&drv->last_seq, last_seq, seq) != last_seq); |
| 218 | 233 | ||
| 234 | if (del_timer(&ring->fence_drv.fallback_timer) && | ||
| 235 | seq != ring->fence_drv.sync_seq) | ||
| 236 | amdgpu_fence_schedule_fallback(ring); | ||
| 237 | |||
| 219 | if (unlikely(seq == last_seq)) | 238 | if (unlikely(seq == last_seq)) |
| 220 | return; | 239 | return false; |
| 221 | 240 | ||
| 222 | last_seq &= drv->num_fences_mask; | 241 | last_seq &= drv->num_fences_mask; |
| 223 | seq &= drv->num_fences_mask; | 242 | seq &= drv->num_fences_mask; |
| @@ -244,6 +263,24 @@ void amdgpu_fence_process(struct amdgpu_ring *ring) | |||
| 244 | 263 | ||
| 245 | dma_fence_put(fence); | 264 | dma_fence_put(fence); |
| 246 | } while (last_seq != seq); | 265 | } while (last_seq != seq); |
| 266 | |||
| 267 | return true; | ||
| 268 | } | ||
| 269 | |||
| 270 | /** | ||
| 271 | * amdgpu_fence_fallback - fallback for hardware interrupts | ||
| 272 | * | ||
| 273 | * @work: delayed work item | ||
| 274 | * | ||
| 275 | * Checks for fence activity. | ||
| 276 | */ | ||
| 277 | static void amdgpu_fence_fallback(struct timer_list *t) | ||
| 278 | { | ||
| 279 | struct amdgpu_ring *ring = from_timer(ring, t, | ||
| 280 | fence_drv.fallback_timer); | ||
| 281 | |||
| 282 | if (amdgpu_fence_process(ring)) | ||
| 283 | DRM_WARN("Fence fallback timer expired on ring %s\n", ring->name); | ||
| 247 | } | 284 | } |
| 248 | 285 | ||
| 249 | /** | 286 | /** |
| @@ -393,6 +430,8 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, | |||
| 393 | atomic_set(&ring->fence_drv.last_seq, 0); | 430 | atomic_set(&ring->fence_drv.last_seq, 0); |
| 394 | ring->fence_drv.initialized = false; | 431 | ring->fence_drv.initialized = false; |
| 395 | 432 | ||
| 433 | timer_setup(&ring->fence_drv.fallback_timer, amdgpu_fence_fallback, 0); | ||
| 434 | |||
| 396 | ring->fence_drv.num_fences_mask = num_hw_submission * 2 - 1; | 435 | ring->fence_drv.num_fences_mask = num_hw_submission * 2 - 1; |
| 397 | spin_lock_init(&ring->fence_drv.lock); | 436 | spin_lock_init(&ring->fence_drv.lock); |
| 398 | ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), | 437 | ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), |
| @@ -468,6 +507,7 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev) | |||
| 468 | amdgpu_irq_put(adev, ring->fence_drv.irq_src, | 507 | amdgpu_irq_put(adev, ring->fence_drv.irq_src, |
| 469 | ring->fence_drv.irq_type); | 508 | ring->fence_drv.irq_type); |
| 470 | drm_sched_fini(&ring->sched); | 509 | drm_sched_fini(&ring->sched); |
| 510 | del_timer_sync(&ring->fence_drv.fallback_timer); | ||
| 471 | for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) | 511 | for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) |
| 472 | dma_fence_put(ring->fence_drv.fences[j]); | 512 | dma_fence_put(ring->fence_drv.fences[j]); |
| 473 | kfree(ring->fence_drv.fences); | 513 | kfree(ring->fence_drv.fences); |
| @@ -561,6 +601,27 @@ static const char *amdgpu_fence_get_timeline_name(struct dma_fence *f) | |||
| 561 | } | 601 | } |
| 562 | 602 | ||
| 563 | /** | 603 | /** |
| 604 | * amdgpu_fence_enable_signaling - enable signalling on fence | ||
| 605 | * @fence: fence | ||
| 606 | * | ||
| 607 | * This function is called with fence_queue lock held, and adds a callback | ||
| 608 | * to fence_queue that checks if this fence is signaled, and if so it | ||
| 609 | * signals the fence and removes itself. | ||
| 610 | */ | ||
| 611 | static bool amdgpu_fence_enable_signaling(struct dma_fence *f) | ||
| 612 | { | ||
| 613 | struct amdgpu_fence *fence = to_amdgpu_fence(f); | ||
| 614 | struct amdgpu_ring *ring = fence->ring; | ||
| 615 | |||
| 616 | if (!timer_pending(&ring->fence_drv.fallback_timer)) | ||
| 617 | amdgpu_fence_schedule_fallback(ring); | ||
| 618 | |||
| 619 | DMA_FENCE_TRACE(&fence->base, "armed on ring %i!\n", ring->idx); | ||
| 620 | |||
| 621 | return true; | ||
| 622 | } | ||
| 623 | |||
| 624 | /** | ||
| 564 | * amdgpu_fence_free - free up the fence memory | 625 | * amdgpu_fence_free - free up the fence memory |
| 565 | * | 626 | * |
| 566 | * @rcu: RCU callback head | 627 | * @rcu: RCU callback head |
| @@ -590,6 +651,7 @@ static void amdgpu_fence_release(struct dma_fence *f) | |||
| 590 | static const struct dma_fence_ops amdgpu_fence_ops = { | 651 | static const struct dma_fence_ops amdgpu_fence_ops = { |
| 591 | .get_driver_name = amdgpu_fence_get_driver_name, | 652 | .get_driver_name = amdgpu_fence_get_driver_name, |
| 592 | .get_timeline_name = amdgpu_fence_get_timeline_name, | 653 | .get_timeline_name = amdgpu_fence_get_timeline_name, |
| 654 | .enable_signaling = amdgpu_fence_enable_signaling, | ||
| 593 | .release = amdgpu_fence_release, | 655 | .release = amdgpu_fence_release, |
| 594 | }; | 656 | }; |
| 595 | 657 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c index 4ed86218cef3..8af67f649660 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | |||
| @@ -24,46 +24,21 @@ | |||
| 24 | #include <drm/drmP.h> | 24 | #include <drm/drmP.h> |
| 25 | #include "amdgpu.h" | 25 | #include "amdgpu.h" |
| 26 | #include "amdgpu_ih.h" | 26 | #include "amdgpu_ih.h" |
| 27 | #include "amdgpu_amdkfd.h" | ||
| 28 | |||
| 29 | /** | ||
| 30 | * amdgpu_ih_ring_alloc - allocate memory for the IH ring | ||
| 31 | * | ||
| 32 | * @adev: amdgpu_device pointer | ||
| 33 | * | ||
| 34 | * Allocate a ring buffer for the interrupt controller. | ||
| 35 | * Returns 0 for success, errors for failure. | ||
| 36 | */ | ||
| 37 | static int amdgpu_ih_ring_alloc(struct amdgpu_device *adev) | ||
| 38 | { | ||
| 39 | int r; | ||
| 40 | |||
| 41 | /* Allocate ring buffer */ | ||
| 42 | if (adev->irq.ih.ring_obj == NULL) { | ||
| 43 | r = amdgpu_bo_create_kernel(adev, adev->irq.ih.ring_size, | ||
| 44 | PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT, | ||
| 45 | &adev->irq.ih.ring_obj, | ||
| 46 | &adev->irq.ih.gpu_addr, | ||
| 47 | (void **)&adev->irq.ih.ring); | ||
| 48 | if (r) { | ||
| 49 | DRM_ERROR("amdgpu: failed to create ih ring buffer (%d).\n", r); | ||
| 50 | return r; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | 27 | ||
| 56 | /** | 28 | /** |
| 57 | * amdgpu_ih_ring_init - initialize the IH state | 29 | * amdgpu_ih_ring_init - initialize the IH state |
| 58 | * | 30 | * |
| 59 | * @adev: amdgpu_device pointer | 31 | * @adev: amdgpu_device pointer |
| 32 | * @ih: ih ring to initialize | ||
| 33 | * @ring_size: ring size to allocate | ||
| 34 | * @use_bus_addr: true when we can use dma_alloc_coherent | ||
| 60 | * | 35 | * |
| 61 | * Initializes the IH state and allocates a buffer | 36 | * Initializes the IH state and allocates a buffer |
| 62 | * for the IH ring buffer. | 37 | * for the IH ring buffer. |
| 63 | * Returns 0 for success, errors for failure. | 38 | * Returns 0 for success, errors for failure. |
| 64 | */ | 39 | */ |
| 65 | int amdgpu_ih_ring_init(struct amdgpu_device *adev, unsigned ring_size, | 40 | int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, |
| 66 | bool use_bus_addr) | 41 | unsigned ring_size, bool use_bus_addr) |
| 67 | { | 42 | { |
| 68 | u32 rb_bufsz; | 43 | u32 rb_bufsz; |
| 69 | int r; | 44 | int r; |
| @@ -71,70 +46,76 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, unsigned ring_size, | |||
| 71 | /* Align ring size */ | 46 | /* Align ring size */ |
| 72 | rb_bufsz = order_base_2(ring_size / 4); | 47 | rb_bufsz = order_base_2(ring_size / 4); |
| 73 | ring_size = (1 << rb_bufsz) * 4; | 48 | ring_size = (1 << rb_bufsz) * 4; |
| 74 | adev->irq.ih.ring_size = ring_size; | 49 | ih->ring_size = ring_size; |
| 75 | adev->irq.ih.ptr_mask = adev->irq.ih.ring_size - 1; | 50 | ih->ptr_mask = ih->ring_size - 1; |
| 76 | adev->irq.ih.rptr = 0; | 51 | ih->rptr = 0; |
| 77 | adev->irq.ih.use_bus_addr = use_bus_addr; | 52 | ih->use_bus_addr = use_bus_addr; |
| 78 | 53 | ||
| 79 | if (adev->irq.ih.use_bus_addr) { | 54 | if (use_bus_addr) { |
| 80 | if (!adev->irq.ih.ring) { | 55 | if (ih->ring) |
| 81 | /* add 8 bytes for the rptr/wptr shadows and | 56 | return 0; |
| 82 | * add them to the end of the ring allocation. | 57 | |
| 83 | */ | 58 | /* add 8 bytes for the rptr/wptr shadows and |
| 84 | adev->irq.ih.ring = pci_alloc_consistent(adev->pdev, | 59 | * add them to the end of the ring allocation. |
| 85 | adev->irq.ih.ring_size + 8, | 60 | */ |
| 86 | &adev->irq.ih.rb_dma_addr); | 61 | ih->ring = dma_alloc_coherent(adev->dev, ih->ring_size + 8, |
| 87 | if (adev->irq.ih.ring == NULL) | 62 | &ih->rb_dma_addr, GFP_KERNEL); |
| 88 | return -ENOMEM; | 63 | if (ih->ring == NULL) |
| 89 | memset((void *)adev->irq.ih.ring, 0, adev->irq.ih.ring_size + 8); | 64 | return -ENOMEM; |
| 90 | adev->irq.ih.wptr_offs = (adev->irq.ih.ring_size / 4) + 0; | 65 | |
| 91 | adev->irq.ih.rptr_offs = (adev->irq.ih.ring_size / 4) + 1; | 66 | memset((void *)ih->ring, 0, ih->ring_size + 8); |
| 92 | } | 67 | ih->wptr_offs = (ih->ring_size / 4) + 0; |
| 93 | return 0; | 68 | ih->rptr_offs = (ih->ring_size / 4) + 1; |
| 94 | } else { | 69 | } else { |
| 95 | r = amdgpu_device_wb_get(adev, &adev->irq.ih.wptr_offs); | 70 | r = amdgpu_device_wb_get(adev, &ih->wptr_offs); |
| 71 | if (r) | ||
| 72 | return r; | ||
| 73 | |||
| 74 | r = amdgpu_device_wb_get(adev, &ih->rptr_offs); | ||
| 96 | if (r) { | 75 | if (r) { |
| 97 | dev_err(adev->dev, "(%d) ih wptr_offs wb alloc failed\n", r); | 76 | amdgpu_device_wb_free(adev, ih->wptr_offs); |
| 98 | return r; | 77 | return r; |
| 99 | } | 78 | } |
| 100 | 79 | ||
| 101 | r = amdgpu_device_wb_get(adev, &adev->irq.ih.rptr_offs); | 80 | r = amdgpu_bo_create_kernel(adev, ih->ring_size, PAGE_SIZE, |
| 81 | AMDGPU_GEM_DOMAIN_GTT, | ||
| 82 | &ih->ring_obj, &ih->gpu_addr, | ||
| 83 | (void **)&ih->ring); | ||
| 102 | if (r) { | 84 | if (r) { |
| 103 | amdgpu_device_wb_free(adev, adev->irq.ih.wptr_offs); | 85 | amdgpu_device_wb_free(adev, ih->rptr_offs); |
| 104 | dev_err(adev->dev, "(%d) ih rptr_offs wb alloc failed\n", r); | 86 | amdgpu_device_wb_free(adev, ih->wptr_offs); |
| 105 | return r; | 87 | return r; |
| 106 | } | 88 | } |
| 107 | |||
| 108 | return amdgpu_ih_ring_alloc(adev); | ||
| 109 | } | 89 | } |
| 90 | return 0; | ||
| 110 | } | 91 | } |
| 111 | 92 | ||
| 112 | /** | 93 | /** |
| 113 | * amdgpu_ih_ring_fini - tear down the IH state | 94 | * amdgpu_ih_ring_fini - tear down the IH state |
| 114 | * | 95 | * |
| 115 | * @adev: amdgpu_device pointer | 96 | * @adev: amdgpu_device pointer |
| 97 | * @ih: ih ring to tear down | ||
| 116 | * | 98 | * |
| 117 | * Tears down the IH state and frees buffer | 99 | * Tears down the IH state and frees buffer |
| 118 | * used for the IH ring buffer. | 100 | * used for the IH ring buffer. |
| 119 | */ | 101 | */ |
| 120 | void amdgpu_ih_ring_fini(struct amdgpu_device *adev) | 102 | void amdgpu_ih_ring_fini(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih) |
| 121 | { | 103 | { |
| 122 | if (adev->irq.ih.use_bus_addr) { | 104 | if (ih->use_bus_addr) { |
| 123 | if (adev->irq.ih.ring) { | 105 | if (!ih->ring) |
| 124 | /* add 8 bytes for the rptr/wptr shadows and | 106 | return; |
| 125 | * add them to the end of the ring allocation. | 107 | |
| 126 | */ | 108 | /* add 8 bytes for the rptr/wptr shadows and |
| 127 | pci_free_consistent(adev->pdev, adev->irq.ih.ring_size + 8, | 109 | * add them to the end of the ring allocation. |
| 128 | (void *)adev->irq.ih.ring, | 110 | */ |
| 129 | adev->irq.ih.rb_dma_addr); | 111 | dma_free_coherent(adev->dev, ih->ring_size + 8, |
| 130 | adev->irq.ih.ring = NULL; | 112 | (void *)ih->ring, ih->rb_dma_addr); |
| 131 | } | 113 | ih->ring = NULL; |
| 132 | } else { | 114 | } else { |
| 133 | amdgpu_bo_free_kernel(&adev->irq.ih.ring_obj, | 115 | amdgpu_bo_free_kernel(&ih->ring_obj, &ih->gpu_addr, |
| 134 | &adev->irq.ih.gpu_addr, | 116 | (void **)&ih->ring); |
| 135 | (void **)&adev->irq.ih.ring); | 117 | amdgpu_device_wb_free(adev, ih->wptr_offs); |
| 136 | amdgpu_device_wb_free(adev, adev->irq.ih.wptr_offs); | 118 | amdgpu_device_wb_free(adev, ih->rptr_offs); |
| 137 | amdgpu_device_wb_free(adev, adev->irq.ih.rptr_offs); | ||
| 138 | } | 119 | } |
| 139 | } | 120 | } |
| 140 | 121 | ||
| @@ -142,56 +123,43 @@ void amdgpu_ih_ring_fini(struct amdgpu_device *adev) | |||
| 142 | * amdgpu_ih_process - interrupt handler | 123 | * amdgpu_ih_process - interrupt handler |
| 143 | * | 124 | * |
| 144 | * @adev: amdgpu_device pointer | 125 | * @adev: amdgpu_device pointer |
| 126 | * @ih: ih ring to process | ||
| 145 | * | 127 | * |
| 146 | * Interrupt hander (VI), walk the IH ring. | 128 | * Interrupt hander (VI), walk the IH ring. |
| 147 | * Returns irq process return code. | 129 | * Returns irq process return code. |
| 148 | */ | 130 | */ |
| 149 | int amdgpu_ih_process(struct amdgpu_device *adev) | 131 | int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, |
| 132 | void (*callback)(struct amdgpu_device *adev, | ||
| 133 | struct amdgpu_ih_ring *ih)) | ||
| 150 | { | 134 | { |
| 151 | struct amdgpu_iv_entry entry; | ||
| 152 | u32 wptr; | 135 | u32 wptr; |
| 153 | 136 | ||
| 154 | if (!adev->irq.ih.enabled || adev->shutdown) | 137 | if (!ih->enabled || adev->shutdown) |
| 155 | return IRQ_NONE; | 138 | return IRQ_NONE; |
| 156 | 139 | ||
| 157 | wptr = amdgpu_ih_get_wptr(adev); | 140 | wptr = amdgpu_ih_get_wptr(adev); |
| 158 | 141 | ||
| 159 | restart_ih: | 142 | restart_ih: |
| 160 | /* is somebody else already processing irqs? */ | 143 | /* is somebody else already processing irqs? */ |
| 161 | if (atomic_xchg(&adev->irq.ih.lock, 1)) | 144 | if (atomic_xchg(&ih->lock, 1)) |
| 162 | return IRQ_NONE; | 145 | return IRQ_NONE; |
| 163 | 146 | ||
| 164 | DRM_DEBUG("%s: rptr %d, wptr %d\n", __func__, adev->irq.ih.rptr, wptr); | 147 | DRM_DEBUG("%s: rptr %d, wptr %d\n", __func__, ih->rptr, wptr); |
| 165 | 148 | ||
| 166 | /* Order reading of wptr vs. reading of IH ring data */ | 149 | /* Order reading of wptr vs. reading of IH ring data */ |
| 167 | rmb(); | 150 | rmb(); |
| 168 | 151 | ||
| 169 | while (adev->irq.ih.rptr != wptr) { | 152 | while (ih->rptr != wptr) { |
| 170 | u32 ring_index = adev->irq.ih.rptr >> 2; | 153 | callback(adev, ih); |
| 171 | 154 | ih->rptr &= ih->ptr_mask; | |
| 172 | /* Prescreening of high-frequency interrupts */ | ||
| 173 | if (!amdgpu_ih_prescreen_iv(adev)) { | ||
| 174 | adev->irq.ih.rptr &= adev->irq.ih.ptr_mask; | ||
| 175 | continue; | ||
| 176 | } | ||
| 177 | |||
| 178 | /* Before dispatching irq to IP blocks, send it to amdkfd */ | ||
| 179 | amdgpu_amdkfd_interrupt(adev, | ||
| 180 | (const void *) &adev->irq.ih.ring[ring_index]); | ||
| 181 | |||
| 182 | entry.iv_entry = (const uint32_t *) | ||
| 183 | &adev->irq.ih.ring[ring_index]; | ||
| 184 | amdgpu_ih_decode_iv(adev, &entry); | ||
| 185 | adev->irq.ih.rptr &= adev->irq.ih.ptr_mask; | ||
| 186 | |||
| 187 | amdgpu_irq_dispatch(adev, &entry); | ||
| 188 | } | 155 | } |
| 156 | |||
| 189 | amdgpu_ih_set_rptr(adev); | 157 | amdgpu_ih_set_rptr(adev); |
| 190 | atomic_set(&adev->irq.ih.lock, 0); | 158 | atomic_set(&ih->lock, 0); |
| 191 | 159 | ||
| 192 | /* make sure wptr hasn't changed while processing */ | 160 | /* make sure wptr hasn't changed while processing */ |
| 193 | wptr = amdgpu_ih_get_wptr(adev); | 161 | wptr = amdgpu_ih_get_wptr(adev); |
| 194 | if (wptr != adev->irq.ih.rptr) | 162 | if (wptr != ih->rptr) |
| 195 | goto restart_ih; | 163 | goto restart_ih; |
| 196 | 164 | ||
| 197 | return IRQ_HANDLED; | 165 | return IRQ_HANDLED; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h index 0d5b3f5201d2..9ce8c93ec19b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h | |||
| @@ -24,12 +24,8 @@ | |||
| 24 | #ifndef __AMDGPU_IH_H__ | 24 | #ifndef __AMDGPU_IH_H__ |
| 25 | #define __AMDGPU_IH_H__ | 25 | #define __AMDGPU_IH_H__ |
| 26 | 26 | ||
| 27 | #include "soc15_ih_clientid.h" | ||
| 28 | |||
| 29 | struct amdgpu_device; | 27 | struct amdgpu_device; |
| 30 | 28 | struct amdgpu_iv_entry; | |
| 31 | #define AMDGPU_IH_CLIENTID_LEGACY 0 | ||
| 32 | #define AMDGPU_IH_CLIENTID_MAX SOC15_IH_CLIENTID_MAX | ||
| 33 | 29 | ||
| 34 | /* | 30 | /* |
| 35 | * R6xx+ IH ring | 31 | * R6xx+ IH ring |
| @@ -51,22 +47,6 @@ struct amdgpu_ih_ring { | |||
| 51 | dma_addr_t rb_dma_addr; /* only used when use_bus_addr = true */ | 47 | dma_addr_t rb_dma_addr; /* only used when use_bus_addr = true */ |
| 52 | }; | 48 | }; |
| 53 | 49 | ||
| 54 | #define AMDGPU_IH_SRC_DATA_MAX_SIZE_DW 4 | ||
| 55 | |||
| 56 | struct amdgpu_iv_entry { | ||
| 57 | unsigned client_id; | ||
| 58 | unsigned src_id; | ||
| 59 | unsigned ring_id; | ||
| 60 | unsigned vmid; | ||
| 61 | unsigned vmid_src; | ||
| 62 | uint64_t timestamp; | ||
| 63 | unsigned timestamp_src; | ||
| 64 | unsigned pasid; | ||
| 65 | unsigned pasid_src; | ||
| 66 | unsigned src_data[AMDGPU_IH_SRC_DATA_MAX_SIZE_DW]; | ||
| 67 | const uint32_t *iv_entry; | ||
| 68 | }; | ||
| 69 | |||
| 70 | /* provided by the ih block */ | 50 | /* provided by the ih block */ |
| 71 | struct amdgpu_ih_funcs { | 51 | struct amdgpu_ih_funcs { |
| 72 | /* ring read/write ptr handling, called from interrupt context */ | 52 | /* ring read/write ptr handling, called from interrupt context */ |
| @@ -82,9 +62,11 @@ struct amdgpu_ih_funcs { | |||
| 82 | #define amdgpu_ih_decode_iv(adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv)) | 62 | #define amdgpu_ih_decode_iv(adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv)) |
| 83 | #define amdgpu_ih_set_rptr(adev) (adev)->irq.ih_funcs->set_rptr((adev)) | 63 | #define amdgpu_ih_set_rptr(adev) (adev)->irq.ih_funcs->set_rptr((adev)) |
| 84 | 64 | ||
| 85 | int amdgpu_ih_ring_init(struct amdgpu_device *adev, unsigned ring_size, | 65 | int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, |
| 86 | bool use_bus_addr); | 66 | unsigned ring_size, bool use_bus_addr); |
| 87 | void amdgpu_ih_ring_fini(struct amdgpu_device *adev); | 67 | void amdgpu_ih_ring_fini(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih); |
| 88 | int amdgpu_ih_process(struct amdgpu_device *adev); | 68 | int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, |
| 69 | void (*callback)(struct amdgpu_device *adev, | ||
| 70 | struct amdgpu_ih_ring *ih)); | ||
| 89 | 71 | ||
| 90 | #endif | 72 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index b927e8798534..52c17f6219a7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | #include "atom.h" | 51 | #include "atom.h" |
| 52 | #include "amdgpu_connectors.h" | 52 | #include "amdgpu_connectors.h" |
| 53 | #include "amdgpu_trace.h" | 53 | #include "amdgpu_trace.h" |
| 54 | #include "amdgpu_amdkfd.h" | ||
| 54 | 55 | ||
| 55 | #include <linux/pm_runtime.h> | 56 | #include <linux/pm_runtime.h> |
| 56 | 57 | ||
| @@ -123,7 +124,7 @@ void amdgpu_irq_disable_all(struct amdgpu_device *adev) | |||
| 123 | int r; | 124 | int r; |
| 124 | 125 | ||
| 125 | spin_lock_irqsave(&adev->irq.lock, irqflags); | 126 | spin_lock_irqsave(&adev->irq.lock, irqflags); |
| 126 | for (i = 0; i < AMDGPU_IH_CLIENTID_MAX; ++i) { | 127 | for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) { |
| 127 | if (!adev->irq.client[i].sources) | 128 | if (!adev->irq.client[i].sources) |
| 128 | continue; | 129 | continue; |
| 129 | 130 | ||
| @@ -147,6 +148,34 @@ void amdgpu_irq_disable_all(struct amdgpu_device *adev) | |||
| 147 | } | 148 | } |
| 148 | 149 | ||
| 149 | /** | 150 | /** |
| 151 | * amdgpu_irq_callback - callback from the IH ring | ||
| 152 | * | ||
| 153 | * @adev: amdgpu device pointer | ||
| 154 | * @ih: amdgpu ih ring | ||
| 155 | * | ||
| 156 | * Callback from IH ring processing to handle the entry at the current position | ||
| 157 | * and advance the read pointer. | ||
| 158 | */ | ||
| 159 | static void amdgpu_irq_callback(struct amdgpu_device *adev, | ||
| 160 | struct amdgpu_ih_ring *ih) | ||
| 161 | { | ||
| 162 | u32 ring_index = ih->rptr >> 2; | ||
| 163 | struct amdgpu_iv_entry entry; | ||
| 164 | |||
| 165 | /* Prescreening of high-frequency interrupts */ | ||
| 166 | if (!amdgpu_ih_prescreen_iv(adev)) | ||
| 167 | return; | ||
| 168 | |||
| 169 | /* Before dispatching irq to IP blocks, send it to amdkfd */ | ||
| 170 | amdgpu_amdkfd_interrupt(adev, (const void *) &ih->ring[ring_index]); | ||
| 171 | |||
| 172 | entry.iv_entry = (const uint32_t *)&ih->ring[ring_index]; | ||
| 173 | amdgpu_ih_decode_iv(adev, &entry); | ||
| 174 | |||
| 175 | amdgpu_irq_dispatch(adev, &entry); | ||
| 176 | } | ||
| 177 | |||
| 178 | /** | ||
| 150 | * amdgpu_irq_handler - IRQ handler | 179 | * amdgpu_irq_handler - IRQ handler |
| 151 | * | 180 | * |
| 152 | * @irq: IRQ number (unused) | 181 | * @irq: IRQ number (unused) |
| @@ -163,7 +192,7 @@ irqreturn_t amdgpu_irq_handler(int irq, void *arg) | |||
| 163 | struct amdgpu_device *adev = dev->dev_private; | 192 | struct amdgpu_device *adev = dev->dev_private; |
| 164 | irqreturn_t ret; | 193 | irqreturn_t ret; |
| 165 | 194 | ||
| 166 | ret = amdgpu_ih_process(adev); | 195 | ret = amdgpu_ih_process(adev, &adev->irq.ih, amdgpu_irq_callback); |
| 167 | if (ret == IRQ_HANDLED) | 196 | if (ret == IRQ_HANDLED) |
| 168 | pm_runtime_mark_last_busy(dev->dev); | 197 | pm_runtime_mark_last_busy(dev->dev); |
| 169 | return ret; | 198 | return ret; |
| @@ -273,7 +302,7 @@ void amdgpu_irq_fini(struct amdgpu_device *adev) | |||
| 273 | cancel_work_sync(&adev->reset_work); | 302 | cancel_work_sync(&adev->reset_work); |
| 274 | } | 303 | } |
| 275 | 304 | ||
| 276 | for (i = 0; i < AMDGPU_IH_CLIENTID_MAX; ++i) { | 305 | for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) { |
| 277 | if (!adev->irq.client[i].sources) | 306 | if (!adev->irq.client[i].sources) |
| 278 | continue; | 307 | continue; |
| 279 | 308 | ||
| @@ -313,7 +342,7 @@ int amdgpu_irq_add_id(struct amdgpu_device *adev, | |||
| 313 | unsigned client_id, unsigned src_id, | 342 | unsigned client_id, unsigned src_id, |
| 314 | struct amdgpu_irq_src *source) | 343 | struct amdgpu_irq_src *source) |
| 315 | { | 344 | { |
| 316 | if (client_id >= AMDGPU_IH_CLIENTID_MAX) | 345 | if (client_id >= AMDGPU_IRQ_CLIENTID_MAX) |
| 317 | return -EINVAL; | 346 | return -EINVAL; |
| 318 | 347 | ||
| 319 | if (src_id >= AMDGPU_MAX_IRQ_SRC_ID) | 348 | if (src_id >= AMDGPU_MAX_IRQ_SRC_ID) |
| @@ -367,7 +396,7 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev, | |||
| 367 | 396 | ||
| 368 | trace_amdgpu_iv(entry); | 397 | trace_amdgpu_iv(entry); |
| 369 | 398 | ||
| 370 | if (client_id >= AMDGPU_IH_CLIENTID_MAX) { | 399 | if (client_id >= AMDGPU_IRQ_CLIENTID_MAX) { |
| 371 | DRM_DEBUG("Invalid client_id in IV: %d\n", client_id); | 400 | DRM_DEBUG("Invalid client_id in IV: %d\n", client_id); |
| 372 | return; | 401 | return; |
| 373 | } | 402 | } |
| @@ -440,7 +469,7 @@ void amdgpu_irq_gpu_reset_resume_helper(struct amdgpu_device *adev) | |||
| 440 | { | 469 | { |
| 441 | int i, j, k; | 470 | int i, j, k; |
| 442 | 471 | ||
| 443 | for (i = 0; i < AMDGPU_IH_CLIENTID_MAX; ++i) { | 472 | for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) { |
| 444 | if (!adev->irq.client[i].sources) | 473 | if (!adev->irq.client[i].sources) |
| 445 | continue; | 474 | continue; |
| 446 | 475 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h index 3375ad778edc..f6ce171cb8aa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h | |||
| @@ -25,19 +25,38 @@ | |||
| 25 | #define __AMDGPU_IRQ_H__ | 25 | #define __AMDGPU_IRQ_H__ |
| 26 | 26 | ||
| 27 | #include <linux/irqdomain.h> | 27 | #include <linux/irqdomain.h> |
| 28 | #include "soc15_ih_clientid.h" | ||
| 28 | #include "amdgpu_ih.h" | 29 | #include "amdgpu_ih.h" |
| 29 | 30 | ||
| 30 | #define AMDGPU_MAX_IRQ_SRC_ID 0x100 | 31 | #define AMDGPU_MAX_IRQ_SRC_ID 0x100 |
| 31 | #define AMDGPU_MAX_IRQ_CLIENT_ID 0x100 | 32 | #define AMDGPU_MAX_IRQ_CLIENT_ID 0x100 |
| 32 | 33 | ||
| 34 | #define AMDGPU_IRQ_CLIENTID_LEGACY 0 | ||
| 35 | #define AMDGPU_IRQ_CLIENTID_MAX SOC15_IH_CLIENTID_MAX | ||
| 36 | |||
| 37 | #define AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW 4 | ||
| 38 | |||
| 33 | struct amdgpu_device; | 39 | struct amdgpu_device; |
| 34 | struct amdgpu_iv_entry; | ||
| 35 | 40 | ||
| 36 | enum amdgpu_interrupt_state { | 41 | enum amdgpu_interrupt_state { |
| 37 | AMDGPU_IRQ_STATE_DISABLE, | 42 | AMDGPU_IRQ_STATE_DISABLE, |
| 38 | AMDGPU_IRQ_STATE_ENABLE, | 43 | AMDGPU_IRQ_STATE_ENABLE, |
| 39 | }; | 44 | }; |
| 40 | 45 | ||
| 46 | struct amdgpu_iv_entry { | ||
| 47 | unsigned client_id; | ||
| 48 | unsigned src_id; | ||
| 49 | unsigned ring_id; | ||
| 50 | unsigned vmid; | ||
| 51 | unsigned vmid_src; | ||
| 52 | uint64_t timestamp; | ||
| 53 | unsigned timestamp_src; | ||
| 54 | unsigned pasid; | ||
| 55 | unsigned pasid_src; | ||
| 56 | unsigned src_data[AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW]; | ||
| 57 | const uint32_t *iv_entry; | ||
| 58 | }; | ||
| 59 | |||
| 41 | struct amdgpu_irq_src { | 60 | struct amdgpu_irq_src { |
| 42 | unsigned num_types; | 61 | unsigned num_types; |
| 43 | atomic_t *enabled_types; | 62 | atomic_t *enabled_types; |
| @@ -63,7 +82,7 @@ struct amdgpu_irq { | |||
| 63 | bool installed; | 82 | bool installed; |
| 64 | spinlock_t lock; | 83 | spinlock_t lock; |
| 65 | /* interrupt sources */ | 84 | /* interrupt sources */ |
| 66 | struct amdgpu_irq_client client[AMDGPU_IH_CLIENTID_MAX]; | 85 | struct amdgpu_irq_client client[AMDGPU_IRQ_CLIENTID_MAX]; |
| 67 | 86 | ||
| 68 | /* status, etc. */ | 87 | /* status, etc. */ |
| 69 | bool msi_enabled; /* msi enabled */ | 88 | bool msi_enabled; /* msi enabled */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index 8c334fc808c2..18d989e0e362 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
| @@ -1976,6 +1976,7 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev) | |||
| 1976 | static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *adev) | 1976 | static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *adev) |
| 1977 | { | 1977 | { |
| 1978 | uint32_t value; | 1978 | uint32_t value; |
| 1979 | uint64_t value64; | ||
| 1979 | uint32_t query = 0; | 1980 | uint32_t query = 0; |
| 1980 | int size; | 1981 | int size; |
| 1981 | 1982 | ||
| @@ -2014,6 +2015,10 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *a | |||
| 2014 | seq_printf(m, "GPU Load: %u %%\n", value); | 2015 | seq_printf(m, "GPU Load: %u %%\n", value); |
| 2015 | seq_printf(m, "\n"); | 2016 | seq_printf(m, "\n"); |
| 2016 | 2017 | ||
| 2018 | /* SMC feature mask */ | ||
| 2019 | if (!amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK, (void *)&value64, &size)) | ||
| 2020 | seq_printf(m, "SMC Feature Mask: 0x%016llx\n", value64); | ||
| 2021 | |||
| 2017 | /* UVD clocks */ | 2022 | /* UVD clocks */ |
| 2018 | if (!amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_UVD_POWER, (void *)&value, &size)) { | 2023 | if (!amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_UVD_POWER, (void *)&value, &size)) { |
| 2019 | if (!value) { | 2024 | if (!value) { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index 44fc665e4577..4caa301ce454 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | |||
| @@ -77,6 +77,7 @@ struct amdgpu_fence_driver { | |||
| 77 | bool initialized; | 77 | bool initialized; |
| 78 | struct amdgpu_irq_src *irq_src; | 78 | struct amdgpu_irq_src *irq_src; |
| 79 | unsigned irq_type; | 79 | unsigned irq_type; |
| 80 | struct timer_list fallback_timer; | ||
| 80 | unsigned num_fences_mask; | 81 | unsigned num_fences_mask; |
| 81 | spinlock_t lock; | 82 | spinlock_t lock; |
| 82 | struct dma_fence **fences; | 83 | struct dma_fence **fences; |
| @@ -96,7 +97,7 @@ void amdgpu_fence_driver_resume(struct amdgpu_device *adev); | |||
| 96 | int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **fence, | 97 | int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **fence, |
| 97 | unsigned flags); | 98 | unsigned flags); |
| 98 | int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s); | 99 | int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s); |
| 99 | void amdgpu_fence_process(struct amdgpu_ring *ring); | 100 | bool amdgpu_fence_process(struct amdgpu_ring *ring); |
| 100 | int amdgpu_fence_wait_empty(struct amdgpu_ring *ring); | 101 | int amdgpu_fence_wait_empty(struct amdgpu_ring *ring); |
| 101 | signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring, | 102 | signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring, |
| 102 | uint32_t wait_seq, | 103 | uint32_t wait_seq, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h index 2e87414422f9..e9bf70e2ac51 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | |||
| @@ -103,7 +103,7 @@ TRACE_EVENT(amdgpu_iv, | |||
| 103 | __entry->src_data[2] = iv->src_data[2]; | 103 | __entry->src_data[2] = iv->src_data[2]; |
| 104 | __entry->src_data[3] = iv->src_data[3]; | 104 | __entry->src_data[3] = iv->src_data[3]; |
| 105 | ), | 105 | ), |
| 106 | TP_printk("client_id:%u src_id:%u ring:%u vmid:%u timestamp: %llu pasid:%u src_data: %08x %08x %08x %08x\n", | 106 | TP_printk("client_id:%u src_id:%u ring:%u vmid:%u timestamp: %llu pasid:%u src_data: %08x %08x %08x %08x", |
| 107 | __entry->client_id, __entry->src_id, | 107 | __entry->client_id, __entry->src_id, |
| 108 | __entry->ring_id, __entry->vmid, | 108 | __entry->ring_id, __entry->vmid, |
| 109 | __entry->timestamp, __entry->pasid, | 109 | __entry->timestamp, __entry->pasid, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c index a73674f9a0f5..2a2eb0143f48 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include "soc15_common.h" | 36 | #include "soc15_common.h" |
| 37 | 37 | ||
| 38 | #include "vcn/vcn_1_0_offset.h" | 38 | #include "vcn/vcn_1_0_offset.h" |
| 39 | #include "vcn/vcn_1_0_sh_mask.h" | ||
| 39 | 40 | ||
| 40 | /* 1 second timeout */ | 41 | /* 1 second timeout */ |
| 41 | #define VCN_IDLE_TIMEOUT msecs_to_jiffies(1000) | 42 | #define VCN_IDLE_TIMEOUT msecs_to_jiffies(1000) |
| @@ -212,18 +213,158 @@ int amdgpu_vcn_resume(struct amdgpu_device *adev) | |||
| 212 | return 0; | 213 | return 0; |
| 213 | } | 214 | } |
| 214 | 215 | ||
| 216 | static int amdgpu_vcn_pause_dpg_mode(struct amdgpu_device *adev, | ||
| 217 | struct dpg_pause_state *new_state) | ||
| 218 | { | ||
| 219 | int ret_code; | ||
| 220 | uint32_t reg_data = 0; | ||
| 221 | uint32_t reg_data2 = 0; | ||
| 222 | struct amdgpu_ring *ring; | ||
| 223 | |||
| 224 | /* pause/unpause if state is changed */ | ||
| 225 | if (adev->vcn.pause_state.fw_based != new_state->fw_based) { | ||
| 226 | DRM_DEBUG("dpg pause state changed %d:%d -> %d:%d", | ||
| 227 | adev->vcn.pause_state.fw_based, adev->vcn.pause_state.jpeg, | ||
| 228 | new_state->fw_based, new_state->jpeg); | ||
| 229 | |||
| 230 | reg_data = RREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE) & | ||
| 231 | (~UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK); | ||
| 232 | |||
| 233 | if (new_state->fw_based == VCN_DPG_STATE__PAUSE) { | ||
| 234 | ret_code = 0; | ||
| 235 | |||
| 236 | if (!(reg_data & UVD_DPG_PAUSE__JPEG_PAUSE_DPG_ACK_MASK)) | ||
| 237 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, | ||
| 238 | UVD_POWER_STATUS__UVD_POWER_STATUS_TILES_OFF, | ||
| 239 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); | ||
| 240 | |||
| 241 | if (!ret_code) { | ||
| 242 | /* pause DPG non-jpeg */ | ||
| 243 | reg_data |= UVD_DPG_PAUSE__NJ_PAUSE_DPG_REQ_MASK; | ||
| 244 | WREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE, reg_data); | ||
| 245 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_DPG_PAUSE, | ||
| 246 | UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK, | ||
| 247 | UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK, ret_code); | ||
| 248 | |||
| 249 | /* Restore */ | ||
| 250 | ring = &adev->vcn.ring_enc[0]; | ||
| 251 | WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_LO, ring->gpu_addr); | ||
| 252 | WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_HI, upper_32_bits(ring->gpu_addr)); | ||
| 253 | WREG32_SOC15(UVD, 0, mmUVD_RB_SIZE, ring->ring_size / 4); | ||
| 254 | WREG32_SOC15(UVD, 0, mmUVD_RB_RPTR, lower_32_bits(ring->wptr)); | ||
| 255 | WREG32_SOC15(UVD, 0, mmUVD_RB_WPTR, lower_32_bits(ring->wptr)); | ||
| 256 | |||
| 257 | ring = &adev->vcn.ring_enc[1]; | ||
| 258 | WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_LO2, ring->gpu_addr); | ||
| 259 | WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_HI2, upper_32_bits(ring->gpu_addr)); | ||
| 260 | WREG32_SOC15(UVD, 0, mmUVD_RB_SIZE2, ring->ring_size / 4); | ||
| 261 | WREG32_SOC15(UVD, 0, mmUVD_RB_RPTR2, lower_32_bits(ring->wptr)); | ||
| 262 | WREG32_SOC15(UVD, 0, mmUVD_RB_WPTR2, lower_32_bits(ring->wptr)); | ||
| 263 | |||
| 264 | ring = &adev->vcn.ring_dec; | ||
| 265 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, | ||
| 266 | lower_32_bits(ring->wptr) | 0x80000000); | ||
| 267 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, | ||
| 268 | UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, | ||
| 269 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); | ||
| 270 | } | ||
| 271 | } else { | ||
| 272 | /* unpause dpg non-jpeg, no need to wait */ | ||
| 273 | reg_data &= ~UVD_DPG_PAUSE__NJ_PAUSE_DPG_REQ_MASK; | ||
| 274 | WREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE, reg_data); | ||
| 275 | } | ||
| 276 | adev->vcn.pause_state.fw_based = new_state->fw_based; | ||
| 277 | } | ||
| 278 | |||
| 279 | /* pause/unpause if state is changed */ | ||
| 280 | if (adev->vcn.pause_state.jpeg != new_state->jpeg) { | ||
| 281 | DRM_DEBUG("dpg pause state changed %d:%d -> %d:%d", | ||
| 282 | adev->vcn.pause_state.fw_based, adev->vcn.pause_state.jpeg, | ||
| 283 | new_state->fw_based, new_state->jpeg); | ||
| 284 | |||
| 285 | reg_data = RREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE) & | ||
| 286 | (~UVD_DPG_PAUSE__JPEG_PAUSE_DPG_ACK_MASK); | ||
| 287 | |||
| 288 | if (new_state->jpeg == VCN_DPG_STATE__PAUSE) { | ||
| 289 | ret_code = 0; | ||
| 290 | |||
| 291 | if (!(reg_data & UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK)) | ||
| 292 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, | ||
| 293 | UVD_POWER_STATUS__UVD_POWER_STATUS_TILES_OFF, | ||
| 294 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); | ||
| 295 | |||
| 296 | if (!ret_code) { | ||
| 297 | /* Make sure JPRG Snoop is disabled before sending the pause */ | ||
| 298 | reg_data2 = RREG32_SOC15(UVD, 0, mmUVD_POWER_STATUS); | ||
| 299 | reg_data2 |= UVD_POWER_STATUS__JRBC_SNOOP_DIS_MASK; | ||
| 300 | WREG32_SOC15(UVD, 0, mmUVD_POWER_STATUS, reg_data2); | ||
| 301 | |||
| 302 | /* pause DPG jpeg */ | ||
| 303 | reg_data |= UVD_DPG_PAUSE__JPEG_PAUSE_DPG_REQ_MASK; | ||
| 304 | WREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE, reg_data); | ||
| 305 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_DPG_PAUSE, | ||
| 306 | UVD_DPG_PAUSE__JPEG_PAUSE_DPG_ACK_MASK, | ||
| 307 | UVD_DPG_PAUSE__JPEG_PAUSE_DPG_ACK_MASK, ret_code); | ||
| 308 | |||
| 309 | /* Restore */ | ||
| 310 | ring = &adev->vcn.ring_jpeg; | ||
| 311 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_VMID, 0); | ||
| 312 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 0x00000001L | 0x00000002L); | ||
| 313 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_LOW, | ||
| 314 | lower_32_bits(ring->gpu_addr)); | ||
| 315 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH, | ||
| 316 | upper_32_bits(ring->gpu_addr)); | ||
| 317 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_RPTR, ring->wptr); | ||
| 318 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR, ring->wptr); | ||
| 319 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 0x00000002L); | ||
| 320 | |||
| 321 | ring = &adev->vcn.ring_dec; | ||
| 322 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, | ||
| 323 | lower_32_bits(ring->wptr) | 0x80000000); | ||
| 324 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, | ||
| 325 | UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, | ||
| 326 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); | ||
| 327 | } | ||
| 328 | } else { | ||
| 329 | /* unpause dpg jpeg, no need to wait */ | ||
| 330 | reg_data &= ~UVD_DPG_PAUSE__JPEG_PAUSE_DPG_REQ_MASK; | ||
| 331 | WREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE, reg_data); | ||
| 332 | } | ||
| 333 | adev->vcn.pause_state.jpeg = new_state->jpeg; | ||
| 334 | } | ||
| 335 | |||
| 336 | return 0; | ||
| 337 | } | ||
| 338 | |||
| 215 | static void amdgpu_vcn_idle_work_handler(struct work_struct *work) | 339 | static void amdgpu_vcn_idle_work_handler(struct work_struct *work) |
| 216 | { | 340 | { |
| 217 | struct amdgpu_device *adev = | 341 | struct amdgpu_device *adev = |
| 218 | container_of(work, struct amdgpu_device, vcn.idle_work.work); | 342 | container_of(work, struct amdgpu_device, vcn.idle_work.work); |
| 219 | unsigned fences = amdgpu_fence_count_emitted(&adev->vcn.ring_dec); | 343 | unsigned int fences = 0; |
| 220 | unsigned i; | 344 | unsigned int i; |
| 221 | 345 | ||
| 222 | for (i = 0; i < adev->vcn.num_enc_rings; ++i) { | 346 | for (i = 0; i < adev->vcn.num_enc_rings; ++i) { |
| 223 | fences += amdgpu_fence_count_emitted(&adev->vcn.ring_enc[i]); | 347 | fences += amdgpu_fence_count_emitted(&adev->vcn.ring_enc[i]); |
| 224 | } | 348 | } |
| 225 | 349 | ||
| 350 | if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) { | ||
| 351 | struct dpg_pause_state new_state; | ||
| 352 | |||
| 353 | if (fences) | ||
| 354 | new_state.fw_based = VCN_DPG_STATE__PAUSE; | ||
| 355 | else | ||
| 356 | new_state.fw_based = VCN_DPG_STATE__UNPAUSE; | ||
| 357 | |||
| 358 | if (amdgpu_fence_count_emitted(&adev->vcn.ring_jpeg)) | ||
| 359 | new_state.jpeg = VCN_DPG_STATE__PAUSE; | ||
| 360 | else | ||
| 361 | new_state.jpeg = VCN_DPG_STATE__UNPAUSE; | ||
| 362 | |||
| 363 | amdgpu_vcn_pause_dpg_mode(adev, &new_state); | ||
| 364 | } | ||
| 365 | |||
| 226 | fences += amdgpu_fence_count_emitted(&adev->vcn.ring_jpeg); | 366 | fences += amdgpu_fence_count_emitted(&adev->vcn.ring_jpeg); |
| 367 | fences += amdgpu_fence_count_emitted(&adev->vcn.ring_dec); | ||
| 227 | 368 | ||
| 228 | if (fences == 0) { | 369 | if (fences == 0) { |
| 229 | amdgpu_gfx_off_ctrl(adev, true); | 370 | amdgpu_gfx_off_ctrl(adev, true); |
| @@ -250,6 +391,22 @@ void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring) | |||
| 250 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, | 391 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, |
| 251 | AMD_PG_STATE_UNGATE); | 392 | AMD_PG_STATE_UNGATE); |
| 252 | } | 393 | } |
| 394 | |||
| 395 | if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) { | ||
| 396 | struct dpg_pause_state new_state; | ||
| 397 | |||
| 398 | if (ring->funcs->type == AMDGPU_RING_TYPE_VCN_ENC) | ||
| 399 | new_state.fw_based = VCN_DPG_STATE__PAUSE; | ||
| 400 | else | ||
| 401 | new_state.fw_based = adev->vcn.pause_state.fw_based; | ||
| 402 | |||
| 403 | if (ring->funcs->type == AMDGPU_RING_TYPE_VCN_JPEG) | ||
| 404 | new_state.jpeg = VCN_DPG_STATE__PAUSE; | ||
| 405 | else | ||
| 406 | new_state.jpeg = adev->vcn.pause_state.jpeg; | ||
| 407 | |||
| 408 | amdgpu_vcn_pause_dpg_mode(adev, &new_state); | ||
| 409 | } | ||
| 253 | } | 410 | } |
| 254 | 411 | ||
| 255 | void amdgpu_vcn_ring_end_use(struct amdgpu_ring *ring) | 412 | void amdgpu_vcn_ring_end_use(struct amdgpu_ring *ring) |
| @@ -264,7 +421,7 @@ int amdgpu_vcn_dec_ring_test_ring(struct amdgpu_ring *ring) | |||
| 264 | unsigned i; | 421 | unsigned i; |
| 265 | int r; | 422 | int r; |
| 266 | 423 | ||
| 267 | WREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_CONTEXT_ID), 0xCAFEDEAD); | 424 | WREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_SCRATCH9), 0xCAFEDEAD); |
| 268 | r = amdgpu_ring_alloc(ring, 3); | 425 | r = amdgpu_ring_alloc(ring, 3); |
| 269 | if (r) { | 426 | if (r) { |
| 270 | DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", | 427 | DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", |
| @@ -272,11 +429,11 @@ int amdgpu_vcn_dec_ring_test_ring(struct amdgpu_ring *ring) | |||
| 272 | return r; | 429 | return r; |
| 273 | } | 430 | } |
| 274 | amdgpu_ring_write(ring, | 431 | amdgpu_ring_write(ring, |
| 275 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_CONTEXT_ID), 0)); | 432 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_SCRATCH9), 0)); |
| 276 | amdgpu_ring_write(ring, 0xDEADBEEF); | 433 | amdgpu_ring_write(ring, 0xDEADBEEF); |
| 277 | amdgpu_ring_commit(ring); | 434 | amdgpu_ring_commit(ring); |
| 278 | for (i = 0; i < adev->usec_timeout; i++) { | 435 | for (i = 0; i < adev->usec_timeout; i++) { |
| 279 | tmp = RREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_CONTEXT_ID)); | 436 | tmp = RREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_SCRATCH9)); |
| 280 | if (tmp == 0xDEADBEEF) | 437 | if (tmp == 0xDEADBEEF) |
| 281 | break; | 438 | break; |
| 282 | DRM_UDELAY(1); | 439 | DRM_UDELAY(1); |
| @@ -616,7 +773,7 @@ int amdgpu_vcn_jpeg_ring_test_ring(struct amdgpu_ring *ring) | |||
| 616 | unsigned i; | 773 | unsigned i; |
| 617 | int r; | 774 | int r; |
| 618 | 775 | ||
| 619 | WREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_CONTEXT_ID), 0xCAFEDEAD); | 776 | WREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_SCRATCH9), 0xCAFEDEAD); |
| 620 | r = amdgpu_ring_alloc(ring, 3); | 777 | r = amdgpu_ring_alloc(ring, 3); |
| 621 | 778 | ||
| 622 | if (r) { | 779 | if (r) { |
| @@ -626,12 +783,12 @@ int amdgpu_vcn_jpeg_ring_test_ring(struct amdgpu_ring *ring) | |||
| 626 | } | 783 | } |
| 627 | 784 | ||
| 628 | amdgpu_ring_write(ring, | 785 | amdgpu_ring_write(ring, |
| 629 | PACKETJ(SOC15_REG_OFFSET(UVD, 0, mmUVD_CONTEXT_ID), 0, 0, 0)); | 786 | PACKETJ(SOC15_REG_OFFSET(UVD, 0, mmUVD_SCRATCH9), 0, 0, 0)); |
| 630 | amdgpu_ring_write(ring, 0xDEADBEEF); | 787 | amdgpu_ring_write(ring, 0xDEADBEEF); |
| 631 | amdgpu_ring_commit(ring); | 788 | amdgpu_ring_commit(ring); |
| 632 | 789 | ||
| 633 | for (i = 0; i < adev->usec_timeout; i++) { | 790 | for (i = 0; i < adev->usec_timeout; i++) { |
| 634 | tmp = RREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_CONTEXT_ID)); | 791 | tmp = RREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_SCRATCH9)); |
| 635 | if (tmp == 0xDEADBEEF) | 792 | if (tmp == 0xDEADBEEF) |
| 636 | break; | 793 | break; |
| 637 | DRM_UDELAY(1); | 794 | DRM_UDELAY(1); |
| @@ -665,7 +822,7 @@ static int amdgpu_vcn_jpeg_set_reg(struct amdgpu_ring *ring, uint32_t handle, | |||
| 665 | 822 | ||
| 666 | ib = &job->ibs[0]; | 823 | ib = &job->ibs[0]; |
| 667 | 824 | ||
| 668 | ib->ptr[0] = PACKETJ(SOC15_REG_OFFSET(UVD, 0, mmUVD_JPEG_PITCH), 0, 0, PACKETJ_TYPE0); | 825 | ib->ptr[0] = PACKETJ(SOC15_REG_OFFSET(UVD, 0, mmUVD_SCRATCH9), 0, 0, PACKETJ_TYPE0); |
| 669 | ib->ptr[1] = 0xDEADBEEF; | 826 | ib->ptr[1] = 0xDEADBEEF; |
| 670 | for (i = 2; i < 16; i += 2) { | 827 | for (i = 2; i < 16; i += 2) { |
| 671 | ib->ptr[i] = PACKETJ(0, 0, 0, PACKETJ_TYPE6); | 828 | ib->ptr[i] = PACKETJ(0, 0, 0, PACKETJ_TYPE6); |
| @@ -714,7 +871,7 @@ int amdgpu_vcn_jpeg_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
| 714 | r = 0; | 871 | r = 0; |
| 715 | 872 | ||
| 716 | for (i = 0; i < adev->usec_timeout; i++) { | 873 | for (i = 0; i < adev->usec_timeout; i++) { |
| 717 | tmp = RREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_JPEG_PITCH)); | 874 | tmp = RREG32(SOC15_REG_OFFSET(UVD, 0, mmUVD_SCRATCH9)); |
| 718 | if (tmp == 0xDEADBEEF) | 875 | if (tmp == 0xDEADBEEF) |
| 719 | break; | 876 | break; |
| 720 | DRM_UDELAY(1); | 877 | DRM_UDELAY(1); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h index 0b0b8638d73f..0b88a4672da5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | |||
| @@ -56,6 +56,16 @@ enum engine_status_constants { | |||
| 56 | UVD_STATUS__RBC_BUSY = 0x1, | 56 | UVD_STATUS__RBC_BUSY = 0x1, |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | enum internal_dpg_state { | ||
| 60 | VCN_DPG_STATE__UNPAUSE = 0, | ||
| 61 | VCN_DPG_STATE__PAUSE, | ||
| 62 | }; | ||
| 63 | |||
| 64 | struct dpg_pause_state { | ||
| 65 | enum internal_dpg_state fw_based; | ||
| 66 | enum internal_dpg_state jpeg; | ||
| 67 | }; | ||
| 68 | |||
| 59 | struct amdgpu_vcn { | 69 | struct amdgpu_vcn { |
| 60 | struct amdgpu_bo *vcpu_bo; | 70 | struct amdgpu_bo *vcpu_bo; |
| 61 | void *cpu_addr; | 71 | void *cpu_addr; |
| @@ -69,6 +79,8 @@ struct amdgpu_vcn { | |||
| 69 | struct amdgpu_ring ring_jpeg; | 79 | struct amdgpu_ring ring_jpeg; |
| 70 | struct amdgpu_irq_src irq; | 80 | struct amdgpu_irq_src irq; |
| 71 | unsigned num_enc_rings; | 81 | unsigned num_enc_rings; |
| 82 | enum amd_powergating_state cur_state; | ||
| 83 | struct dpg_pause_state pause_state; | ||
| 72 | }; | 84 | }; |
| 73 | 85 | ||
| 74 | int amdgpu_vcn_sw_init(struct amdgpu_device *adev); | 86 | int amdgpu_vcn_sw_init(struct amdgpu_device *adev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c index d2469453dca2..79220a91abe3 100644 --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c | |||
| @@ -6277,12 +6277,12 @@ static int ci_dpm_sw_init(void *handle) | |||
| 6277 | int ret; | 6277 | int ret; |
| 6278 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 6278 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 6279 | 6279 | ||
| 6280 | ret = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 230, | 6280 | ret = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 230, |
| 6281 | &adev->pm.dpm.thermal.irq); | 6281 | &adev->pm.dpm.thermal.irq); |
| 6282 | if (ret) | 6282 | if (ret) |
| 6283 | return ret; | 6283 | return ret; |
| 6284 | 6284 | ||
| 6285 | ret = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 231, | 6285 | ret = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 231, |
| 6286 | &adev->pm.dpm.thermal.irq); | 6286 | &adev->pm.dpm.thermal.irq); |
| 6287 | if (ret) | 6287 | if (ret) |
| 6288 | return ret; | 6288 | return ret; |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_ih.c b/drivers/gpu/drm/amd/amdgpu/cik_ih.c index 44d10c2172f6..b5775c6a857b 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/cik_ih.c | |||
| @@ -276,7 +276,7 @@ static void cik_ih_decode_iv(struct amdgpu_device *adev, | |||
| 276 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); | 276 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); |
| 277 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); | 277 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); |
| 278 | 278 | ||
| 279 | entry->client_id = AMDGPU_IH_CLIENTID_LEGACY; | 279 | entry->client_id = AMDGPU_IRQ_CLIENTID_LEGACY; |
| 280 | entry->src_id = dw[0] & 0xff; | 280 | entry->src_id = dw[0] & 0xff; |
| 281 | entry->src_data[0] = dw[1] & 0xfffffff; | 281 | entry->src_data[0] = dw[1] & 0xfffffff; |
| 282 | entry->ring_id = dw[2] & 0xff; | 282 | entry->ring_id = dw[2] & 0xff; |
| @@ -318,7 +318,7 @@ static int cik_ih_sw_init(void *handle) | |||
| 318 | int r; | 318 | int r; |
| 319 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 319 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 320 | 320 | ||
| 321 | r = amdgpu_ih_ring_init(adev, 64 * 1024, false); | 321 | r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 64 * 1024, false); |
| 322 | if (r) | 322 | if (r) |
| 323 | return r; | 323 | return r; |
| 324 | 324 | ||
| @@ -332,7 +332,7 @@ static int cik_ih_sw_fini(void *handle) | |||
| 332 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 332 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 333 | 333 | ||
| 334 | amdgpu_irq_fini(adev); | 334 | amdgpu_irq_fini(adev); |
| 335 | amdgpu_ih_ring_fini(adev); | 335 | amdgpu_ih_ring_fini(adev, &adev->irq.ih); |
| 336 | amdgpu_irq_remove_domain(adev); | 336 | amdgpu_irq_remove_domain(adev); |
| 337 | 337 | ||
| 338 | return 0; | 338 | return 0; |
| @@ -468,8 +468,7 @@ static const struct amdgpu_ih_funcs cik_ih_funcs = { | |||
| 468 | 468 | ||
| 469 | static void cik_ih_set_interrupt_funcs(struct amdgpu_device *adev) | 469 | static void cik_ih_set_interrupt_funcs(struct amdgpu_device *adev) |
| 470 | { | 470 | { |
| 471 | if (adev->irq.ih_funcs == NULL) | 471 | adev->irq.ih_funcs = &cik_ih_funcs; |
| 472 | adev->irq.ih_funcs = &cik_ih_funcs; | ||
| 473 | } | 472 | } |
| 474 | 473 | ||
| 475 | const struct amdgpu_ip_block_version cik_ih_ip_block = | 474 | const struct amdgpu_ip_block_version cik_ih_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c index 154b1499b07e..b918c8886b75 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c +++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c | |||
| @@ -970,19 +970,19 @@ static int cik_sdma_sw_init(void *handle) | |||
| 970 | } | 970 | } |
| 971 | 971 | ||
| 972 | /* SDMA trap event */ | 972 | /* SDMA trap event */ |
| 973 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 224, | 973 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 224, |
| 974 | &adev->sdma.trap_irq); | 974 | &adev->sdma.trap_irq); |
| 975 | if (r) | 975 | if (r) |
| 976 | return r; | 976 | return r; |
| 977 | 977 | ||
| 978 | /* SDMA Privileged inst */ | 978 | /* SDMA Privileged inst */ |
| 979 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 241, | 979 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 241, |
| 980 | &adev->sdma.illegal_inst_irq); | 980 | &adev->sdma.illegal_inst_irq); |
| 981 | if (r) | 981 | if (r) |
| 982 | return r; | 982 | return r; |
| 983 | 983 | ||
| 984 | /* SDMA Privileged inst */ | 984 | /* SDMA Privileged inst */ |
| 985 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 247, | 985 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 247, |
| 986 | &adev->sdma.illegal_inst_irq); | 986 | &adev->sdma.illegal_inst_irq); |
| 987 | if (r) | 987 | if (r) |
| 988 | return r; | 988 | return r; |
| @@ -1370,10 +1370,8 @@ static const struct amdgpu_buffer_funcs cik_sdma_buffer_funcs = { | |||
| 1370 | 1370 | ||
| 1371 | static void cik_sdma_set_buffer_funcs(struct amdgpu_device *adev) | 1371 | static void cik_sdma_set_buffer_funcs(struct amdgpu_device *adev) |
| 1372 | { | 1372 | { |
| 1373 | if (adev->mman.buffer_funcs == NULL) { | 1373 | adev->mman.buffer_funcs = &cik_sdma_buffer_funcs; |
| 1374 | adev->mman.buffer_funcs = &cik_sdma_buffer_funcs; | 1374 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; |
| 1375 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; | ||
| 1376 | } | ||
| 1377 | } | 1375 | } |
| 1378 | 1376 | ||
| 1379 | static const struct amdgpu_vm_pte_funcs cik_sdma_vm_pte_funcs = { | 1377 | static const struct amdgpu_vm_pte_funcs cik_sdma_vm_pte_funcs = { |
| @@ -1389,15 +1387,13 @@ static void cik_sdma_set_vm_pte_funcs(struct amdgpu_device *adev) | |||
| 1389 | struct drm_gpu_scheduler *sched; | 1387 | struct drm_gpu_scheduler *sched; |
| 1390 | unsigned i; | 1388 | unsigned i; |
| 1391 | 1389 | ||
| 1392 | if (adev->vm_manager.vm_pte_funcs == NULL) { | 1390 | adev->vm_manager.vm_pte_funcs = &cik_sdma_vm_pte_funcs; |
| 1393 | adev->vm_manager.vm_pte_funcs = &cik_sdma_vm_pte_funcs; | 1391 | for (i = 0; i < adev->sdma.num_instances; i++) { |
| 1394 | for (i = 0; i < adev->sdma.num_instances; i++) { | 1392 | sched = &adev->sdma.instance[i].ring.sched; |
| 1395 | sched = &adev->sdma.instance[i].ring.sched; | 1393 | adev->vm_manager.vm_pte_rqs[i] = |
| 1396 | adev->vm_manager.vm_pte_rqs[i] = | 1394 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; |
| 1397 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; | ||
| 1398 | } | ||
| 1399 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 1400 | } | 1395 | } |
| 1396 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 1401 | } | 1397 | } |
| 1402 | 1398 | ||
| 1403 | const struct amdgpu_ip_block_version cik_sdma_ip_block = | 1399 | const struct amdgpu_ip_block_version cik_sdma_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_ih.c b/drivers/gpu/drm/amd/amdgpu/cz_ih.c index 960c29e17da6..df5ac4d85a00 100644 --- a/drivers/gpu/drm/amd/amdgpu/cz_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/cz_ih.c | |||
| @@ -255,7 +255,7 @@ static void cz_ih_decode_iv(struct amdgpu_device *adev, | |||
| 255 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); | 255 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); |
| 256 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); | 256 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); |
| 257 | 257 | ||
| 258 | entry->client_id = AMDGPU_IH_CLIENTID_LEGACY; | 258 | entry->client_id = AMDGPU_IRQ_CLIENTID_LEGACY; |
| 259 | entry->src_id = dw[0] & 0xff; | 259 | entry->src_id = dw[0] & 0xff; |
| 260 | entry->src_data[0] = dw[1] & 0xfffffff; | 260 | entry->src_data[0] = dw[1] & 0xfffffff; |
| 261 | entry->ring_id = dw[2] & 0xff; | 261 | entry->ring_id = dw[2] & 0xff; |
| @@ -297,7 +297,7 @@ static int cz_ih_sw_init(void *handle) | |||
| 297 | int r; | 297 | int r; |
| 298 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 298 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 299 | 299 | ||
| 300 | r = amdgpu_ih_ring_init(adev, 64 * 1024, false); | 300 | r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 64 * 1024, false); |
| 301 | if (r) | 301 | if (r) |
| 302 | return r; | 302 | return r; |
| 303 | 303 | ||
| @@ -311,7 +311,7 @@ static int cz_ih_sw_fini(void *handle) | |||
| 311 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 311 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 312 | 312 | ||
| 313 | amdgpu_irq_fini(adev); | 313 | amdgpu_irq_fini(adev); |
| 314 | amdgpu_ih_ring_fini(adev); | 314 | amdgpu_ih_ring_fini(adev, &adev->irq.ih); |
| 315 | amdgpu_irq_remove_domain(adev); | 315 | amdgpu_irq_remove_domain(adev); |
| 316 | 316 | ||
| 317 | return 0; | 317 | return 0; |
| @@ -449,8 +449,7 @@ static const struct amdgpu_ih_funcs cz_ih_funcs = { | |||
| 449 | 449 | ||
| 450 | static void cz_ih_set_interrupt_funcs(struct amdgpu_device *adev) | 450 | static void cz_ih_set_interrupt_funcs(struct amdgpu_device *adev) |
| 451 | { | 451 | { |
| 452 | if (adev->irq.ih_funcs == NULL) | 452 | adev->irq.ih_funcs = &cz_ih_funcs; |
| 453 | adev->irq.ih_funcs = &cz_ih_funcs; | ||
| 454 | } | 453 | } |
| 455 | 454 | ||
| 456 | const struct amdgpu_ip_block_version cz_ih_ip_block = | 455 | const struct amdgpu_ip_block_version cz_ih_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c index 3916aa6cc4ec..4cfecdce29a3 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | |||
| @@ -2746,19 +2746,19 @@ static int dce_v10_0_sw_init(void *handle) | |||
| 2746 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2746 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 2747 | 2747 | ||
| 2748 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | 2748 | for (i = 0; i < adev->mode_info.num_crtc; i++) { |
| 2749 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i + 1, &adev->crtc_irq); | 2749 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i + 1, &adev->crtc_irq); |
| 2750 | if (r) | 2750 | if (r) |
| 2751 | return r; | 2751 | return r; |
| 2752 | } | 2752 | } |
| 2753 | 2753 | ||
| 2754 | for (i = VISLANDS30_IV_SRCID_D1_GRPH_PFLIP; i < 20; i += 2) { | 2754 | for (i = VISLANDS30_IV_SRCID_D1_GRPH_PFLIP; i < 20; i += 2) { |
| 2755 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i, &adev->pageflip_irq); | 2755 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i, &adev->pageflip_irq); |
| 2756 | if (r) | 2756 | if (r) |
| 2757 | return r; | 2757 | return r; |
| 2758 | } | 2758 | } |
| 2759 | 2759 | ||
| 2760 | /* HPD hotplug */ | 2760 | /* HPD hotplug */ |
| 2761 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_HOTPLUG_DETECT_A, &adev->hpd_irq); | 2761 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_HOTPLUG_DETECT_A, &adev->hpd_irq); |
| 2762 | if (r) | 2762 | if (r) |
| 2763 | return r; | 2763 | return r; |
| 2764 | 2764 | ||
| @@ -3570,8 +3570,7 @@ static const struct amdgpu_display_funcs dce_v10_0_display_funcs = { | |||
| 3570 | 3570 | ||
| 3571 | static void dce_v10_0_set_display_funcs(struct amdgpu_device *adev) | 3571 | static void dce_v10_0_set_display_funcs(struct amdgpu_device *adev) |
| 3572 | { | 3572 | { |
| 3573 | if (adev->mode_info.funcs == NULL) | 3573 | adev->mode_info.funcs = &dce_v10_0_display_funcs; |
| 3574 | adev->mode_info.funcs = &dce_v10_0_display_funcs; | ||
| 3575 | } | 3574 | } |
| 3576 | 3575 | ||
| 3577 | static const struct amdgpu_irq_src_funcs dce_v10_0_crtc_irq_funcs = { | 3576 | static const struct amdgpu_irq_src_funcs dce_v10_0_crtc_irq_funcs = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c index 4ffb612a4e53..7c868916d90f 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | |||
| @@ -2867,19 +2867,19 @@ static int dce_v11_0_sw_init(void *handle) | |||
| 2867 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2867 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 2868 | 2868 | ||
| 2869 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | 2869 | for (i = 0; i < adev->mode_info.num_crtc; i++) { |
| 2870 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i + 1, &adev->crtc_irq); | 2870 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i + 1, &adev->crtc_irq); |
| 2871 | if (r) | 2871 | if (r) |
| 2872 | return r; | 2872 | return r; |
| 2873 | } | 2873 | } |
| 2874 | 2874 | ||
| 2875 | for (i = VISLANDS30_IV_SRCID_D1_GRPH_PFLIP; i < 20; i += 2) { | 2875 | for (i = VISLANDS30_IV_SRCID_D1_GRPH_PFLIP; i < 20; i += 2) { |
| 2876 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i, &adev->pageflip_irq); | 2876 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i, &adev->pageflip_irq); |
| 2877 | if (r) | 2877 | if (r) |
| 2878 | return r; | 2878 | return r; |
| 2879 | } | 2879 | } |
| 2880 | 2880 | ||
| 2881 | /* HPD hotplug */ | 2881 | /* HPD hotplug */ |
| 2882 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_HOTPLUG_DETECT_A, &adev->hpd_irq); | 2882 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_HOTPLUG_DETECT_A, &adev->hpd_irq); |
| 2883 | if (r) | 2883 | if (r) |
| 2884 | return r; | 2884 | return r; |
| 2885 | 2885 | ||
| @@ -3702,8 +3702,7 @@ static const struct amdgpu_display_funcs dce_v11_0_display_funcs = { | |||
| 3702 | 3702 | ||
| 3703 | static void dce_v11_0_set_display_funcs(struct amdgpu_device *adev) | 3703 | static void dce_v11_0_set_display_funcs(struct amdgpu_device *adev) |
| 3704 | { | 3704 | { |
| 3705 | if (adev->mode_info.funcs == NULL) | 3705 | adev->mode_info.funcs = &dce_v11_0_display_funcs; |
| 3706 | adev->mode_info.funcs = &dce_v11_0_display_funcs; | ||
| 3707 | } | 3706 | } |
| 3708 | 3707 | ||
| 3709 | static const struct amdgpu_irq_src_funcs dce_v11_0_crtc_irq_funcs = { | 3708 | static const struct amdgpu_irq_src_funcs dce_v11_0_crtc_irq_funcs = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c index 480c5348a14f..17eaaba36017 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | |||
| @@ -2616,19 +2616,19 @@ static int dce_v6_0_sw_init(void *handle) | |||
| 2616 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2616 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 2617 | 2617 | ||
| 2618 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | 2618 | for (i = 0; i < adev->mode_info.num_crtc; i++) { |
| 2619 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i + 1, &adev->crtc_irq); | 2619 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i + 1, &adev->crtc_irq); |
| 2620 | if (r) | 2620 | if (r) |
| 2621 | return r; | 2621 | return r; |
| 2622 | } | 2622 | } |
| 2623 | 2623 | ||
| 2624 | for (i = 8; i < 20; i += 2) { | 2624 | for (i = 8; i < 20; i += 2) { |
| 2625 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i, &adev->pageflip_irq); | 2625 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i, &adev->pageflip_irq); |
| 2626 | if (r) | 2626 | if (r) |
| 2627 | return r; | 2627 | return r; |
| 2628 | } | 2628 | } |
| 2629 | 2629 | ||
| 2630 | /* HPD hotplug */ | 2630 | /* HPD hotplug */ |
| 2631 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 42, &adev->hpd_irq); | 2631 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 42, &adev->hpd_irq); |
| 2632 | if (r) | 2632 | if (r) |
| 2633 | return r; | 2633 | return r; |
| 2634 | 2634 | ||
| @@ -3376,8 +3376,7 @@ static const struct amdgpu_display_funcs dce_v6_0_display_funcs = { | |||
| 3376 | 3376 | ||
| 3377 | static void dce_v6_0_set_display_funcs(struct amdgpu_device *adev) | 3377 | static void dce_v6_0_set_display_funcs(struct amdgpu_device *adev) |
| 3378 | { | 3378 | { |
| 3379 | if (adev->mode_info.funcs == NULL) | 3379 | adev->mode_info.funcs = &dce_v6_0_display_funcs; |
| 3380 | adev->mode_info.funcs = &dce_v6_0_display_funcs; | ||
| 3381 | } | 3380 | } |
| 3382 | 3381 | ||
| 3383 | static const struct amdgpu_irq_src_funcs dce_v6_0_crtc_irq_funcs = { | 3382 | static const struct amdgpu_irq_src_funcs dce_v6_0_crtc_irq_funcs = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c index 797196476c94..8c0576978d36 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | |||
| @@ -2643,19 +2643,19 @@ static int dce_v8_0_sw_init(void *handle) | |||
| 2643 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2643 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 2644 | 2644 | ||
| 2645 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | 2645 | for (i = 0; i < adev->mode_info.num_crtc; i++) { |
| 2646 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i + 1, &adev->crtc_irq); | 2646 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i + 1, &adev->crtc_irq); |
| 2647 | if (r) | 2647 | if (r) |
| 2648 | return r; | 2648 | return r; |
| 2649 | } | 2649 | } |
| 2650 | 2650 | ||
| 2651 | for (i = 8; i < 20; i += 2) { | 2651 | for (i = 8; i < 20; i += 2) { |
| 2652 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i, &adev->pageflip_irq); | 2652 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i, &adev->pageflip_irq); |
| 2653 | if (r) | 2653 | if (r) |
| 2654 | return r; | 2654 | return r; |
| 2655 | } | 2655 | } |
| 2656 | 2656 | ||
| 2657 | /* HPD hotplug */ | 2657 | /* HPD hotplug */ |
| 2658 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 42, &adev->hpd_irq); | 2658 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 42, &adev->hpd_irq); |
| 2659 | if (r) | 2659 | if (r) |
| 2660 | return r; | 2660 | return r; |
| 2661 | 2661 | ||
| @@ -3458,8 +3458,7 @@ static const struct amdgpu_display_funcs dce_v8_0_display_funcs = { | |||
| 3458 | 3458 | ||
| 3459 | static void dce_v8_0_set_display_funcs(struct amdgpu_device *adev) | 3459 | static void dce_v8_0_set_display_funcs(struct amdgpu_device *adev) |
| 3460 | { | 3460 | { |
| 3461 | if (adev->mode_info.funcs == NULL) | 3461 | adev->mode_info.funcs = &dce_v8_0_display_funcs; |
| 3462 | adev->mode_info.funcs = &dce_v8_0_display_funcs; | ||
| 3463 | } | 3462 | } |
| 3464 | 3463 | ||
| 3465 | static const struct amdgpu_irq_src_funcs dce_v8_0_crtc_irq_funcs = { | 3464 | static const struct amdgpu_irq_src_funcs dce_v8_0_crtc_irq_funcs = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c index 15257634a53a..fdace004544d 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c | |||
| @@ -372,7 +372,7 @@ static int dce_virtual_sw_init(void *handle) | |||
| 372 | int r, i; | 372 | int r, i; |
| 373 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 373 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 374 | 374 | ||
| 375 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SMU_DISP_TIMER2_TRIGGER, &adev->crtc_irq); | 375 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SMU_DISP_TIMER2_TRIGGER, &adev->crtc_irq); |
| 376 | if (r) | 376 | if (r) |
| 377 | return r; | 377 | return r; |
| 378 | 378 | ||
| @@ -649,8 +649,7 @@ static const struct amdgpu_display_funcs dce_virtual_display_funcs = { | |||
| 649 | 649 | ||
| 650 | static void dce_virtual_set_display_funcs(struct amdgpu_device *adev) | 650 | static void dce_virtual_set_display_funcs(struct amdgpu_device *adev) |
| 651 | { | 651 | { |
| 652 | if (adev->mode_info.funcs == NULL) | 652 | adev->mode_info.funcs = &dce_virtual_display_funcs; |
| 653 | adev->mode_info.funcs = &dce_virtual_display_funcs; | ||
| 654 | } | 653 | } |
| 655 | 654 | ||
| 656 | static int dce_virtual_pageflip(struct amdgpu_device *adev, | 655 | static int dce_virtual_pageflip(struct amdgpu_device *adev, |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c index de184a886057..d76eb27945dc 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | |||
| @@ -1552,7 +1552,7 @@ static void gfx_v6_0_config_init(struct amdgpu_device *adev) | |||
| 1552 | adev->gfx.config.double_offchip_lds_buf = 0; | 1552 | adev->gfx.config.double_offchip_lds_buf = 0; |
| 1553 | } | 1553 | } |
| 1554 | 1554 | ||
| 1555 | static void gfx_v6_0_gpu_init(struct amdgpu_device *adev) | 1555 | static void gfx_v6_0_constants_init(struct amdgpu_device *adev) |
| 1556 | { | 1556 | { |
| 1557 | u32 gb_addr_config = 0; | 1557 | u32 gb_addr_config = 0; |
| 1558 | u32 mc_shared_chmap, mc_arb_ramcfg; | 1558 | u32 mc_shared_chmap, mc_arb_ramcfg; |
| @@ -3094,15 +3094,15 @@ static int gfx_v6_0_sw_init(void *handle) | |||
| 3094 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 3094 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 3095 | int i, r; | 3095 | int i, r; |
| 3096 | 3096 | ||
| 3097 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 181, &adev->gfx.eop_irq); | 3097 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 181, &adev->gfx.eop_irq); |
| 3098 | if (r) | 3098 | if (r) |
| 3099 | return r; | 3099 | return r; |
| 3100 | 3100 | ||
| 3101 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 184, &adev->gfx.priv_reg_irq); | 3101 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 184, &adev->gfx.priv_reg_irq); |
| 3102 | if (r) | 3102 | if (r) |
| 3103 | return r; | 3103 | return r; |
| 3104 | 3104 | ||
| 3105 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 185, &adev->gfx.priv_inst_irq); | 3105 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 185, &adev->gfx.priv_inst_irq); |
| 3106 | if (r) | 3106 | if (r) |
| 3107 | return r; | 3107 | return r; |
| 3108 | 3108 | ||
| @@ -3175,7 +3175,7 @@ static int gfx_v6_0_hw_init(void *handle) | |||
| 3175 | int r; | 3175 | int r; |
| 3176 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 3176 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 3177 | 3177 | ||
| 3178 | gfx_v6_0_gpu_init(adev); | 3178 | gfx_v6_0_constants_init(adev); |
| 3179 | 3179 | ||
| 3180 | r = gfx_v6_0_rlc_resume(adev); | 3180 | r = gfx_v6_0_rlc_resume(adev); |
| 3181 | if (r) | 3181 | if (r) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index fc39ebbc9d9f..0e72bc09939a 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | |||
| @@ -1886,14 +1886,14 @@ static void gfx_v7_0_config_init(struct amdgpu_device *adev) | |||
| 1886 | } | 1886 | } |
| 1887 | 1887 | ||
| 1888 | /** | 1888 | /** |
| 1889 | * gfx_v7_0_gpu_init - setup the 3D engine | 1889 | * gfx_v7_0_constants_init - setup the 3D engine |
| 1890 | * | 1890 | * |
| 1891 | * @adev: amdgpu_device pointer | 1891 | * @adev: amdgpu_device pointer |
| 1892 | * | 1892 | * |
| 1893 | * Configures the 3D engine and tiling configuration | 1893 | * init the gfx constants such as the 3D engine, tiling configuration |
| 1894 | * registers so that the 3D engine is usable. | 1894 | * registers, maximum number of quad pipes, render backends... |
| 1895 | */ | 1895 | */ |
| 1896 | static void gfx_v7_0_gpu_init(struct amdgpu_device *adev) | 1896 | static void gfx_v7_0_constants_init(struct amdgpu_device *adev) |
| 1897 | { | 1897 | { |
| 1898 | u32 sh_mem_cfg, sh_static_mem_cfg, sh_mem_base; | 1898 | u32 sh_mem_cfg, sh_static_mem_cfg, sh_mem_base; |
| 1899 | u32 tmp; | 1899 | u32 tmp; |
| @@ -4516,18 +4516,18 @@ static int gfx_v7_0_sw_init(void *handle) | |||
| 4516 | adev->gfx.mec.num_queue_per_pipe = 8; | 4516 | adev->gfx.mec.num_queue_per_pipe = 8; |
| 4517 | 4517 | ||
| 4518 | /* EOP Event */ | 4518 | /* EOP Event */ |
| 4519 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 181, &adev->gfx.eop_irq); | 4519 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 181, &adev->gfx.eop_irq); |
| 4520 | if (r) | 4520 | if (r) |
| 4521 | return r; | 4521 | return r; |
| 4522 | 4522 | ||
| 4523 | /* Privileged reg */ | 4523 | /* Privileged reg */ |
| 4524 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 184, | 4524 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 184, |
| 4525 | &adev->gfx.priv_reg_irq); | 4525 | &adev->gfx.priv_reg_irq); |
| 4526 | if (r) | 4526 | if (r) |
| 4527 | return r; | 4527 | return r; |
| 4528 | 4528 | ||
| 4529 | /* Privileged inst */ | 4529 | /* Privileged inst */ |
| 4530 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 185, | 4530 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 185, |
| 4531 | &adev->gfx.priv_inst_irq); | 4531 | &adev->gfx.priv_inst_irq); |
| 4532 | if (r) | 4532 | if (r) |
| 4533 | return r; | 4533 | return r; |
| @@ -4624,7 +4624,7 @@ static int gfx_v7_0_hw_init(void *handle) | |||
| 4624 | int r; | 4624 | int r; |
| 4625 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 4625 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 4626 | 4626 | ||
| 4627 | gfx_v7_0_gpu_init(adev); | 4627 | gfx_v7_0_constants_init(adev); |
| 4628 | 4628 | ||
| 4629 | /* init rlc */ | 4629 | /* init rlc */ |
| 4630 | r = gfx_v7_0_rlc_resume(adev); | 4630 | r = gfx_v7_0_rlc_resume(adev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index 470dc80f4fe7..2aeef2bb93a4 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
| @@ -2049,35 +2049,35 @@ static int gfx_v8_0_sw_init(void *handle) | |||
| 2049 | adev->gfx.mec.num_queue_per_pipe = 8; | 2049 | adev->gfx.mec.num_queue_per_pipe = 8; |
| 2050 | 2050 | ||
| 2051 | /* KIQ event */ | 2051 | /* KIQ event */ |
| 2052 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_INT_IB2, &adev->gfx.kiq.irq); | 2052 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_INT_IB2, &adev->gfx.kiq.irq); |
| 2053 | if (r) | 2053 | if (r) |
| 2054 | return r; | 2054 | return r; |
| 2055 | 2055 | ||
| 2056 | /* EOP Event */ | 2056 | /* EOP Event */ |
| 2057 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_END_OF_PIPE, &adev->gfx.eop_irq); | 2057 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_END_OF_PIPE, &adev->gfx.eop_irq); |
| 2058 | if (r) | 2058 | if (r) |
| 2059 | return r; | 2059 | return r; |
| 2060 | 2060 | ||
| 2061 | /* Privileged reg */ | 2061 | /* Privileged reg */ |
| 2062 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_PRIV_REG_FAULT, | 2062 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_PRIV_REG_FAULT, |
| 2063 | &adev->gfx.priv_reg_irq); | 2063 | &adev->gfx.priv_reg_irq); |
| 2064 | if (r) | 2064 | if (r) |
| 2065 | return r; | 2065 | return r; |
| 2066 | 2066 | ||
| 2067 | /* Privileged inst */ | 2067 | /* Privileged inst */ |
| 2068 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_PRIV_INSTR_FAULT, | 2068 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_PRIV_INSTR_FAULT, |
| 2069 | &adev->gfx.priv_inst_irq); | 2069 | &adev->gfx.priv_inst_irq); |
| 2070 | if (r) | 2070 | if (r) |
| 2071 | return r; | 2071 | return r; |
| 2072 | 2072 | ||
| 2073 | /* Add CP EDC/ECC irq */ | 2073 | /* Add CP EDC/ECC irq */ |
| 2074 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_ECC_ERROR, | 2074 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_ECC_ERROR, |
| 2075 | &adev->gfx.cp_ecc_error_irq); | 2075 | &adev->gfx.cp_ecc_error_irq); |
| 2076 | if (r) | 2076 | if (r) |
| 2077 | return r; | 2077 | return r; |
| 2078 | 2078 | ||
| 2079 | /* SQ interrupts. */ | 2079 | /* SQ interrupts. */ |
| 2080 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SQ_INTERRUPT_MSG, | 2080 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SQ_INTERRUPT_MSG, |
| 2081 | &adev->gfx.sq_irq); | 2081 | &adev->gfx.sq_irq); |
| 2082 | if (r) { | 2082 | if (r) { |
| 2083 | DRM_ERROR("amdgpu_irq_add() for SQ failed: %d\n", r); | 2083 | DRM_ERROR("amdgpu_irq_add() for SQ failed: %d\n", r); |
| @@ -3835,7 +3835,7 @@ static void gfx_v8_0_config_init(struct amdgpu_device *adev) | |||
| 3835 | } | 3835 | } |
| 3836 | } | 3836 | } |
| 3837 | 3837 | ||
| 3838 | static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) | 3838 | static void gfx_v8_0_constants_init(struct amdgpu_device *adev) |
| 3839 | { | 3839 | { |
| 3840 | u32 tmp, sh_static_mem_cfg; | 3840 | u32 tmp, sh_static_mem_cfg; |
| 3841 | int i; | 3841 | int i; |
| @@ -4208,31 +4208,11 @@ static int gfx_v8_0_rlc_load_microcode(struct amdgpu_device *adev) | |||
| 4208 | static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev) | 4208 | static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev) |
| 4209 | { | 4209 | { |
| 4210 | int r; | 4210 | int r; |
| 4211 | u32 tmp; | ||
| 4212 | 4211 | ||
| 4213 | gfx_v8_0_rlc_stop(adev); | 4212 | gfx_v8_0_rlc_stop(adev); |
| 4214 | |||
| 4215 | /* disable CG */ | ||
| 4216 | tmp = RREG32(mmRLC_CGCG_CGLS_CTRL); | ||
| 4217 | tmp &= ~(RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK | | ||
| 4218 | RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK); | ||
| 4219 | WREG32(mmRLC_CGCG_CGLS_CTRL, tmp); | ||
| 4220 | if (adev->asic_type == CHIP_POLARIS11 || | ||
| 4221 | adev->asic_type == CHIP_POLARIS10 || | ||
| 4222 | adev->asic_type == CHIP_POLARIS12 || | ||
| 4223 | adev->asic_type == CHIP_VEGAM) { | ||
| 4224 | tmp = RREG32(mmRLC_CGCG_CGLS_CTRL_3D); | ||
| 4225 | tmp &= ~0x3; | ||
| 4226 | WREG32(mmRLC_CGCG_CGLS_CTRL_3D, tmp); | ||
| 4227 | } | ||
| 4228 | |||
| 4229 | /* disable PG */ | ||
| 4230 | WREG32(mmRLC_PG_CNTL, 0); | ||
| 4231 | |||
| 4232 | gfx_v8_0_rlc_reset(adev); | 4213 | gfx_v8_0_rlc_reset(adev); |
| 4233 | gfx_v8_0_init_pg(adev); | 4214 | gfx_v8_0_init_pg(adev); |
| 4234 | 4215 | ||
| 4235 | |||
| 4236 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { | 4216 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { |
| 4237 | /* legacy rlc firmware loading */ | 4217 | /* legacy rlc firmware loading */ |
| 4238 | r = gfx_v8_0_rlc_load_microcode(adev); | 4218 | r = gfx_v8_0_rlc_load_microcode(adev); |
| @@ -5039,7 +5019,7 @@ static int gfx_v8_0_hw_init(void *handle) | |||
| 5039 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 5019 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 5040 | 5020 | ||
| 5041 | gfx_v8_0_init_golden_registers(adev); | 5021 | gfx_v8_0_init_golden_registers(adev); |
| 5042 | gfx_v8_0_gpu_init(adev); | 5022 | gfx_v8_0_constants_init(adev); |
| 5043 | 5023 | ||
| 5044 | r = gfx_v8_0_rlc_resume(adev); | 5024 | r = gfx_v8_0_rlc_resume(adev); |
| 5045 | if (r) | 5025 | if (r) |
| @@ -5080,6 +5060,55 @@ static int gfx_v8_0_kcq_disable(struct amdgpu_device *adev) | |||
| 5080 | return r; | 5060 | return r; |
| 5081 | } | 5061 | } |
| 5082 | 5062 | ||
| 5063 | static bool gfx_v8_0_is_idle(void *handle) | ||
| 5064 | { | ||
| 5065 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
| 5066 | |||
| 5067 | if (REG_GET_FIELD(RREG32(mmGRBM_STATUS), GRBM_STATUS, GUI_ACTIVE) | ||
| 5068 | || RREG32(mmGRBM_STATUS2) != 0x8) | ||
| 5069 | return false; | ||
| 5070 | else | ||
| 5071 | return true; | ||
| 5072 | } | ||
| 5073 | |||
| 5074 | static bool gfx_v8_0_rlc_is_idle(void *handle) | ||
| 5075 | { | ||
| 5076 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
| 5077 | |||
| 5078 | if (RREG32(mmGRBM_STATUS2) != 0x8) | ||
| 5079 | return false; | ||
| 5080 | else | ||
| 5081 | return true; | ||
| 5082 | } | ||
| 5083 | |||
| 5084 | static int gfx_v8_0_wait_for_rlc_idle(void *handle) | ||
| 5085 | { | ||
| 5086 | unsigned int i; | ||
| 5087 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
| 5088 | |||
| 5089 | for (i = 0; i < adev->usec_timeout; i++) { | ||
| 5090 | if (gfx_v8_0_rlc_is_idle(handle)) | ||
| 5091 | return 0; | ||
| 5092 | |||
| 5093 | udelay(1); | ||
| 5094 | } | ||
| 5095 | return -ETIMEDOUT; | ||
| 5096 | } | ||
| 5097 | |||
| 5098 | static int gfx_v8_0_wait_for_idle(void *handle) | ||
| 5099 | { | ||
| 5100 | unsigned int i; | ||
| 5101 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
| 5102 | |||
| 5103 | for (i = 0; i < adev->usec_timeout; i++) { | ||
| 5104 | if (gfx_v8_0_is_idle(handle)) | ||
| 5105 | return 0; | ||
| 5106 | |||
| 5107 | udelay(1); | ||
| 5108 | } | ||
| 5109 | return -ETIMEDOUT; | ||
| 5110 | } | ||
| 5111 | |||
| 5083 | static int gfx_v8_0_hw_fini(void *handle) | 5112 | static int gfx_v8_0_hw_fini(void *handle) |
| 5084 | { | 5113 | { |
| 5085 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 5114 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| @@ -5098,9 +5127,16 @@ static int gfx_v8_0_hw_fini(void *handle) | |||
| 5098 | pr_debug("For SRIOV client, shouldn't do anything.\n"); | 5127 | pr_debug("For SRIOV client, shouldn't do anything.\n"); |
| 5099 | return 0; | 5128 | return 0; |
| 5100 | } | 5129 | } |
| 5101 | gfx_v8_0_cp_enable(adev, false); | 5130 | adev->gfx.rlc.funcs->enter_safe_mode(adev); |
| 5102 | gfx_v8_0_rlc_stop(adev); | 5131 | if (!gfx_v8_0_wait_for_idle(adev)) |
| 5103 | 5132 | gfx_v8_0_cp_enable(adev, false); | |
| 5133 | else | ||
| 5134 | pr_err("cp is busy, skip halt cp\n"); | ||
| 5135 | if (!gfx_v8_0_wait_for_rlc_idle(adev)) | ||
| 5136 | gfx_v8_0_rlc_stop(adev); | ||
| 5137 | else | ||
| 5138 | pr_err("rlc is busy, skip halt rlc\n"); | ||
| 5139 | adev->gfx.rlc.funcs->exit_safe_mode(adev); | ||
| 5104 | return 0; | 5140 | return 0; |
| 5105 | } | 5141 | } |
| 5106 | 5142 | ||
| @@ -5121,30 +5157,6 @@ static int gfx_v8_0_resume(void *handle) | |||
| 5121 | return r; | 5157 | return r; |
| 5122 | } | 5158 | } |
| 5123 | 5159 | ||
| 5124 | static bool gfx_v8_0_is_idle(void *handle) | ||
| 5125 | { | ||
| 5126 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
| 5127 | |||
| 5128 | if (REG_GET_FIELD(RREG32(mmGRBM_STATUS), GRBM_STATUS, GUI_ACTIVE)) | ||
| 5129 | return false; | ||
| 5130 | else | ||
| 5131 | return true; | ||
| 5132 | } | ||
| 5133 | |||
| 5134 | static int gfx_v8_0_wait_for_idle(void *handle) | ||
| 5135 | { | ||
| 5136 | unsigned i; | ||
| 5137 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
| 5138 | |||
| 5139 | for (i = 0; i < adev->usec_timeout; i++) { | ||
| 5140 | if (gfx_v8_0_is_idle(handle)) | ||
| 5141 | return 0; | ||
| 5142 | |||
| 5143 | udelay(1); | ||
| 5144 | } | ||
| 5145 | return -ETIMEDOUT; | ||
| 5146 | } | ||
| 5147 | |||
| 5148 | static bool gfx_v8_0_check_soft_reset(void *handle) | 5160 | static bool gfx_v8_0_check_soft_reset(void *handle) |
| 5149 | { | 5161 | { |
| 5150 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 5162 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index f369d9603435..261bb051b14d 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | |||
| @@ -1847,7 +1847,7 @@ static void gfx_v9_0_init_compute_vmid(struct amdgpu_device *adev) | |||
| 1847 | mutex_unlock(&adev->srbm_mutex); | 1847 | mutex_unlock(&adev->srbm_mutex); |
| 1848 | } | 1848 | } |
| 1849 | 1849 | ||
| 1850 | static void gfx_v9_0_gpu_init(struct amdgpu_device *adev) | 1850 | static void gfx_v9_0_constants_init(struct amdgpu_device *adev) |
| 1851 | { | 1851 | { |
| 1852 | u32 tmp; | 1852 | u32 tmp; |
| 1853 | int i; | 1853 | int i; |
| @@ -3235,7 +3235,7 @@ static int gfx_v9_0_hw_init(void *handle) | |||
| 3235 | 3235 | ||
| 3236 | gfx_v9_0_init_golden_registers(adev); | 3236 | gfx_v9_0_init_golden_registers(adev); |
| 3237 | 3237 | ||
| 3238 | gfx_v9_0_gpu_init(adev); | 3238 | gfx_v9_0_constants_init(adev); |
| 3239 | 3239 | ||
| 3240 | r = gfx_v9_0_csb_vram_pin(adev); | 3240 | r = gfx_v9_0_csb_vram_pin(adev); |
| 3241 | if (r) | 3241 | if (r) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c index 65f58ebcf835..ceb7847b504f 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | |||
| @@ -82,7 +82,8 @@ static void gfxhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev) | |||
| 82 | * to get rid of the VM fault and hardware hang. | 82 | * to get rid of the VM fault and hardware hang. |
| 83 | */ | 83 | */ |
| 84 | WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, | 84 | WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 85 | (max(adev->gmc.vram_end, adev->gmc.agp_end) >> 18) + 0x1); | 85 | max((adev->gmc.vram_end >> 18) + 0x1, |
| 86 | adev->gmc.agp_end >> 18)); | ||
| 86 | else | 87 | else |
| 87 | WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, | 88 | WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 88 | max(adev->gmc.vram_end, adev->gmc.agp_end) >> 18); | 89 | max(adev->gmc.vram_end, adev->gmc.agp_end) >> 18); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c index 4411463ca719..e1c2b4e9c7b2 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | |||
| @@ -859,11 +859,11 @@ static int gmc_v6_0_sw_init(void *handle) | |||
| 859 | adev->gmc.vram_type = gmc_v6_0_convert_vram_type(tmp); | 859 | adev->gmc.vram_type = gmc_v6_0_convert_vram_type(tmp); |
| 860 | } | 860 | } |
| 861 | 861 | ||
| 862 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 146, &adev->gmc.vm_fault); | 862 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 146, &adev->gmc.vm_fault); |
| 863 | if (r) | 863 | if (r) |
| 864 | return r; | 864 | return r; |
| 865 | 865 | ||
| 866 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 147, &adev->gmc.vm_fault); | 866 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 147, &adev->gmc.vm_fault); |
| 867 | if (r) | 867 | if (r) |
| 868 | return r; | 868 | return r; |
| 869 | 869 | ||
| @@ -1180,8 +1180,7 @@ static const struct amdgpu_irq_src_funcs gmc_v6_0_irq_funcs = { | |||
| 1180 | 1180 | ||
| 1181 | static void gmc_v6_0_set_gmc_funcs(struct amdgpu_device *adev) | 1181 | static void gmc_v6_0_set_gmc_funcs(struct amdgpu_device *adev) |
| 1182 | { | 1182 | { |
| 1183 | if (adev->gmc.gmc_funcs == NULL) | 1183 | adev->gmc.gmc_funcs = &gmc_v6_0_gmc_funcs; |
| 1184 | adev->gmc.gmc_funcs = &gmc_v6_0_gmc_funcs; | ||
| 1185 | } | 1184 | } |
| 1186 | 1185 | ||
| 1187 | static void gmc_v6_0_set_irq_funcs(struct amdgpu_device *adev) | 1186 | static void gmc_v6_0_set_irq_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index ae776ce9a415..910c4ce19cb3 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | |||
| @@ -991,11 +991,11 @@ static int gmc_v7_0_sw_init(void *handle) | |||
| 991 | adev->gmc.vram_type = gmc_v7_0_convert_vram_type(tmp); | 991 | adev->gmc.vram_type = gmc_v7_0_convert_vram_type(tmp); |
| 992 | } | 992 | } |
| 993 | 993 | ||
| 994 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_PAGE_INV_FAULT, &adev->gmc.vm_fault); | 994 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_PAGE_INV_FAULT, &adev->gmc.vm_fault); |
| 995 | if (r) | 995 | if (r) |
| 996 | return r; | 996 | return r; |
| 997 | 997 | ||
| 998 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_MEM_PROT_FAULT, &adev->gmc.vm_fault); | 998 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_MEM_PROT_FAULT, &adev->gmc.vm_fault); |
| 999 | if (r) | 999 | if (r) |
| 1000 | return r; | 1000 | return r; |
| 1001 | 1001 | ||
| @@ -1388,8 +1388,7 @@ static const struct amdgpu_irq_src_funcs gmc_v7_0_irq_funcs = { | |||
| 1388 | 1388 | ||
| 1389 | static void gmc_v7_0_set_gmc_funcs(struct amdgpu_device *adev) | 1389 | static void gmc_v7_0_set_gmc_funcs(struct amdgpu_device *adev) |
| 1390 | { | 1390 | { |
| 1391 | if (adev->gmc.gmc_funcs == NULL) | 1391 | adev->gmc.gmc_funcs = &gmc_v7_0_gmc_funcs; |
| 1392 | adev->gmc.gmc_funcs = &gmc_v7_0_gmc_funcs; | ||
| 1393 | } | 1392 | } |
| 1394 | 1393 | ||
| 1395 | static void gmc_v7_0_set_irq_funcs(struct amdgpu_device *adev) | 1394 | static void gmc_v7_0_set_irq_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 53ae49b8bde8..1d3265c97b70 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | |||
| @@ -1095,11 +1095,11 @@ static int gmc_v8_0_sw_init(void *handle) | |||
| 1095 | adev->gmc.vram_type = gmc_v8_0_convert_vram_type(tmp); | 1095 | adev->gmc.vram_type = gmc_v8_0_convert_vram_type(tmp); |
| 1096 | } | 1096 | } |
| 1097 | 1097 | ||
| 1098 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_PAGE_INV_FAULT, &adev->gmc.vm_fault); | 1098 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_PAGE_INV_FAULT, &adev->gmc.vm_fault); |
| 1099 | if (r) | 1099 | if (r) |
| 1100 | return r; | 1100 | return r; |
| 1101 | 1101 | ||
| 1102 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_MEM_PROT_FAULT, &adev->gmc.vm_fault); | 1102 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_MEM_PROT_FAULT, &adev->gmc.vm_fault); |
| 1103 | if (r) | 1103 | if (r) |
| 1104 | return r; | 1104 | return r; |
| 1105 | 1105 | ||
| @@ -1733,8 +1733,7 @@ static const struct amdgpu_irq_src_funcs gmc_v8_0_irq_funcs = { | |||
| 1733 | 1733 | ||
| 1734 | static void gmc_v8_0_set_gmc_funcs(struct amdgpu_device *adev) | 1734 | static void gmc_v8_0_set_gmc_funcs(struct amdgpu_device *adev) |
| 1735 | { | 1735 | { |
| 1736 | if (adev->gmc.gmc_funcs == NULL) | 1736 | adev->gmc.gmc_funcs = &gmc_v8_0_gmc_funcs; |
| 1737 | adev->gmc.gmc_funcs = &gmc_v8_0_gmc_funcs; | ||
| 1738 | } | 1737 | } |
| 1739 | 1738 | ||
| 1740 | static void gmc_v8_0_set_irq_funcs(struct amdgpu_device *adev) | 1739 | static void gmc_v8_0_set_irq_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index aad3c7c5fb3a..f35d7a554ad5 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | |||
| @@ -593,8 +593,7 @@ static const struct amdgpu_gmc_funcs gmc_v9_0_gmc_funcs = { | |||
| 593 | 593 | ||
| 594 | static void gmc_v9_0_set_gmc_funcs(struct amdgpu_device *adev) | 594 | static void gmc_v9_0_set_gmc_funcs(struct amdgpu_device *adev) |
| 595 | { | 595 | { |
| 596 | if (adev->gmc.gmc_funcs == NULL) | 596 | adev->gmc.gmc_funcs = &gmc_v9_0_gmc_funcs; |
| 597 | adev->gmc.gmc_funcs = &gmc_v9_0_gmc_funcs; | ||
| 598 | } | 597 | } |
| 599 | 598 | ||
| 600 | static int gmc_v9_0_early_init(void *handle) | 599 | static int gmc_v9_0_early_init(void *handle) |
diff --git a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c index 842c4b677b4d..cf0fc61aebe6 100644 --- a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c | |||
| @@ -255,7 +255,7 @@ static void iceland_ih_decode_iv(struct amdgpu_device *adev, | |||
| 255 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); | 255 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); |
| 256 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); | 256 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); |
| 257 | 257 | ||
| 258 | entry->client_id = AMDGPU_IH_CLIENTID_LEGACY; | 258 | entry->client_id = AMDGPU_IRQ_CLIENTID_LEGACY; |
| 259 | entry->src_id = dw[0] & 0xff; | 259 | entry->src_id = dw[0] & 0xff; |
| 260 | entry->src_data[0] = dw[1] & 0xfffffff; | 260 | entry->src_data[0] = dw[1] & 0xfffffff; |
| 261 | entry->ring_id = dw[2] & 0xff; | 261 | entry->ring_id = dw[2] & 0xff; |
| @@ -297,7 +297,7 @@ static int iceland_ih_sw_init(void *handle) | |||
| 297 | int r; | 297 | int r; |
| 298 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 298 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 299 | 299 | ||
| 300 | r = amdgpu_ih_ring_init(adev, 64 * 1024, false); | 300 | r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 64 * 1024, false); |
| 301 | if (r) | 301 | if (r) |
| 302 | return r; | 302 | return r; |
| 303 | 303 | ||
| @@ -311,7 +311,7 @@ static int iceland_ih_sw_fini(void *handle) | |||
| 311 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 311 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 312 | 312 | ||
| 313 | amdgpu_irq_fini(adev); | 313 | amdgpu_irq_fini(adev); |
| 314 | amdgpu_ih_ring_fini(adev); | 314 | amdgpu_ih_ring_fini(adev, &adev->irq.ih); |
| 315 | amdgpu_irq_remove_domain(adev); | 315 | amdgpu_irq_remove_domain(adev); |
| 316 | 316 | ||
| 317 | return 0; | 317 | return 0; |
| @@ -447,8 +447,7 @@ static const struct amdgpu_ih_funcs iceland_ih_funcs = { | |||
| 447 | 447 | ||
| 448 | static void iceland_ih_set_interrupt_funcs(struct amdgpu_device *adev) | 448 | static void iceland_ih_set_interrupt_funcs(struct amdgpu_device *adev) |
| 449 | { | 449 | { |
| 450 | if (adev->irq.ih_funcs == NULL) | 450 | adev->irq.ih_funcs = &iceland_ih_funcs; |
| 451 | adev->irq.ih_funcs = &iceland_ih_funcs; | ||
| 452 | } | 451 | } |
| 453 | 452 | ||
| 454 | const struct amdgpu_ip_block_version iceland_ih_ip_block = | 453 | const struct amdgpu_ip_block_version iceland_ih_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c index cb79a93c2eb7..d0e478f43443 100644 --- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c | |||
| @@ -2995,12 +2995,12 @@ static int kv_dpm_sw_init(void *handle) | |||
| 2995 | int ret; | 2995 | int ret; |
| 2996 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2996 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 2997 | 2997 | ||
| 2998 | ret = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 230, | 2998 | ret = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 230, |
| 2999 | &adev->pm.dpm.thermal.irq); | 2999 | &adev->pm.dpm.thermal.irq); |
| 3000 | if (ret) | 3000 | if (ret) |
| 3001 | return ret; | 3001 | return ret; |
| 3002 | 3002 | ||
| 3003 | ret = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 231, | 3003 | ret = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 231, |
| 3004 | &adev->pm.dpm.thermal.irq); | 3004 | &adev->pm.dpm.thermal.irq); |
| 3005 | if (ret) | 3005 | if (ret) |
| 3006 | return ret; | 3006 | return ret; |
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c index 80698b5ffa4a..14649f8475f3 100644 --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | |||
| @@ -100,7 +100,8 @@ static void mmhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev) | |||
| 100 | * to get rid of the VM fault and hardware hang. | 100 | * to get rid of the VM fault and hardware hang. |
| 101 | */ | 101 | */ |
| 102 | WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, | 102 | WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 103 | (max(adev->gmc.vram_end, adev->gmc.agp_end) >> 18) + 0x1); | 103 | max((adev->gmc.vram_end >> 18) + 0x1, |
| 104 | adev->gmc.agp_end >> 18)); | ||
| 104 | else | 105 | else |
| 105 | WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, | 106 | WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 106 | max(adev->gmc.vram_end, adev->gmc.agp_end) >> 18); | 107 | max(adev->gmc.vram_end, adev->gmc.agp_end) >> 18); |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c index 842567b53df5..64e875d528dd 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | |||
| @@ -580,11 +580,11 @@ int xgpu_vi_mailbox_add_irq_id(struct amdgpu_device *adev) | |||
| 580 | { | 580 | { |
| 581 | int r; | 581 | int r; |
| 582 | 582 | ||
| 583 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 135, &adev->virt.rcv_irq); | 583 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 135, &adev->virt.rcv_irq); |
| 584 | if (r) | 584 | if (r) |
| 585 | return r; | 585 | return r; |
| 586 | 586 | ||
| 587 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 138, &adev->virt.ack_irq); | 587 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 138, &adev->virt.ack_irq); |
| 588 | if (r) { | 588 | if (r) { |
| 589 | amdgpu_irq_put(adev, &adev->virt.rcv_irq, 0); | 589 | amdgpu_irq_put(adev, &adev->virt.rcv_irq, 0); |
| 590 | return r; | 590 | return r; |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c index c403bdf8ad70..cd781abc4953 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | |||
| @@ -898,19 +898,19 @@ static int sdma_v2_4_sw_init(void *handle) | |||
| 898 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 898 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 899 | 899 | ||
| 900 | /* SDMA trap event */ | 900 | /* SDMA trap event */ |
| 901 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SDMA_TRAP, | 901 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SDMA_TRAP, |
| 902 | &adev->sdma.trap_irq); | 902 | &adev->sdma.trap_irq); |
| 903 | if (r) | 903 | if (r) |
| 904 | return r; | 904 | return r; |
| 905 | 905 | ||
| 906 | /* SDMA Privileged inst */ | 906 | /* SDMA Privileged inst */ |
| 907 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 241, | 907 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 241, |
| 908 | &adev->sdma.illegal_inst_irq); | 908 | &adev->sdma.illegal_inst_irq); |
| 909 | if (r) | 909 | if (r) |
| 910 | return r; | 910 | return r; |
| 911 | 911 | ||
| 912 | /* SDMA Privileged inst */ | 912 | /* SDMA Privileged inst */ |
| 913 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SDMA_SRBM_WRITE, | 913 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SDMA_SRBM_WRITE, |
| 914 | &adev->sdma.illegal_inst_irq); | 914 | &adev->sdma.illegal_inst_irq); |
| 915 | if (r) | 915 | if (r) |
| 916 | return r; | 916 | return r; |
| @@ -1296,10 +1296,8 @@ static const struct amdgpu_buffer_funcs sdma_v2_4_buffer_funcs = { | |||
| 1296 | 1296 | ||
| 1297 | static void sdma_v2_4_set_buffer_funcs(struct amdgpu_device *adev) | 1297 | static void sdma_v2_4_set_buffer_funcs(struct amdgpu_device *adev) |
| 1298 | { | 1298 | { |
| 1299 | if (adev->mman.buffer_funcs == NULL) { | 1299 | adev->mman.buffer_funcs = &sdma_v2_4_buffer_funcs; |
| 1300 | adev->mman.buffer_funcs = &sdma_v2_4_buffer_funcs; | 1300 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; |
| 1301 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; | ||
| 1302 | } | ||
| 1303 | } | 1301 | } |
| 1304 | 1302 | ||
| 1305 | static const struct amdgpu_vm_pte_funcs sdma_v2_4_vm_pte_funcs = { | 1303 | static const struct amdgpu_vm_pte_funcs sdma_v2_4_vm_pte_funcs = { |
| @@ -1315,15 +1313,13 @@ static void sdma_v2_4_set_vm_pte_funcs(struct amdgpu_device *adev) | |||
| 1315 | struct drm_gpu_scheduler *sched; | 1313 | struct drm_gpu_scheduler *sched; |
| 1316 | unsigned i; | 1314 | unsigned i; |
| 1317 | 1315 | ||
| 1318 | if (adev->vm_manager.vm_pte_funcs == NULL) { | 1316 | adev->vm_manager.vm_pte_funcs = &sdma_v2_4_vm_pte_funcs; |
| 1319 | adev->vm_manager.vm_pte_funcs = &sdma_v2_4_vm_pte_funcs; | 1317 | for (i = 0; i < adev->sdma.num_instances; i++) { |
| 1320 | for (i = 0; i < adev->sdma.num_instances; i++) { | 1318 | sched = &adev->sdma.instance[i].ring.sched; |
| 1321 | sched = &adev->sdma.instance[i].ring.sched; | 1319 | adev->vm_manager.vm_pte_rqs[i] = |
| 1322 | adev->vm_manager.vm_pte_rqs[i] = | 1320 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; |
| 1323 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; | ||
| 1324 | } | ||
| 1325 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 1326 | } | 1321 | } |
| 1322 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 1327 | } | 1323 | } |
| 1328 | 1324 | ||
| 1329 | const struct amdgpu_ip_block_version sdma_v2_4_ip_block = | 1325 | const struct amdgpu_ip_block_version sdma_v2_4_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c index 2677d6a1bf42..6d5c8ac64874 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | |||
| @@ -1177,19 +1177,19 @@ static int sdma_v3_0_sw_init(void *handle) | |||
| 1177 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1177 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1178 | 1178 | ||
| 1179 | /* SDMA trap event */ | 1179 | /* SDMA trap event */ |
| 1180 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SDMA_TRAP, | 1180 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SDMA_TRAP, |
| 1181 | &adev->sdma.trap_irq); | 1181 | &adev->sdma.trap_irq); |
| 1182 | if (r) | 1182 | if (r) |
| 1183 | return r; | 1183 | return r; |
| 1184 | 1184 | ||
| 1185 | /* SDMA Privileged inst */ | 1185 | /* SDMA Privileged inst */ |
| 1186 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 241, | 1186 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 241, |
| 1187 | &adev->sdma.illegal_inst_irq); | 1187 | &adev->sdma.illegal_inst_irq); |
| 1188 | if (r) | 1188 | if (r) |
| 1189 | return r; | 1189 | return r; |
| 1190 | 1190 | ||
| 1191 | /* SDMA Privileged inst */ | 1191 | /* SDMA Privileged inst */ |
| 1192 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SDMA_SRBM_WRITE, | 1192 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_SDMA_SRBM_WRITE, |
| 1193 | &adev->sdma.illegal_inst_irq); | 1193 | &adev->sdma.illegal_inst_irq); |
| 1194 | if (r) | 1194 | if (r) |
| 1195 | return r; | 1195 | return r; |
| @@ -1736,10 +1736,8 @@ static const struct amdgpu_buffer_funcs sdma_v3_0_buffer_funcs = { | |||
| 1736 | 1736 | ||
| 1737 | static void sdma_v3_0_set_buffer_funcs(struct amdgpu_device *adev) | 1737 | static void sdma_v3_0_set_buffer_funcs(struct amdgpu_device *adev) |
| 1738 | { | 1738 | { |
| 1739 | if (adev->mman.buffer_funcs == NULL) { | 1739 | adev->mman.buffer_funcs = &sdma_v3_0_buffer_funcs; |
| 1740 | adev->mman.buffer_funcs = &sdma_v3_0_buffer_funcs; | 1740 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; |
| 1741 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; | ||
| 1742 | } | ||
| 1743 | } | 1741 | } |
| 1744 | 1742 | ||
| 1745 | static const struct amdgpu_vm_pte_funcs sdma_v3_0_vm_pte_funcs = { | 1743 | static const struct amdgpu_vm_pte_funcs sdma_v3_0_vm_pte_funcs = { |
| @@ -1755,15 +1753,13 @@ static void sdma_v3_0_set_vm_pte_funcs(struct amdgpu_device *adev) | |||
| 1755 | struct drm_gpu_scheduler *sched; | 1753 | struct drm_gpu_scheduler *sched; |
| 1756 | unsigned i; | 1754 | unsigned i; |
| 1757 | 1755 | ||
| 1758 | if (adev->vm_manager.vm_pte_funcs == NULL) { | 1756 | adev->vm_manager.vm_pte_funcs = &sdma_v3_0_vm_pte_funcs; |
| 1759 | adev->vm_manager.vm_pte_funcs = &sdma_v3_0_vm_pte_funcs; | 1757 | for (i = 0; i < adev->sdma.num_instances; i++) { |
| 1760 | for (i = 0; i < adev->sdma.num_instances; i++) { | 1758 | sched = &adev->sdma.instance[i].ring.sched; |
| 1761 | sched = &adev->sdma.instance[i].ring.sched; | 1759 | adev->vm_manager.vm_pte_rqs[i] = |
| 1762 | adev->vm_manager.vm_pte_rqs[i] = | 1760 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; |
| 1763 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; | ||
| 1764 | } | ||
| 1765 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 1766 | } | 1761 | } |
| 1762 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 1767 | } | 1763 | } |
| 1768 | 1764 | ||
| 1769 | const struct amdgpu_ip_block_version sdma_v3_0_ip_block = | 1765 | const struct amdgpu_ip_block_version sdma_v3_0_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index 2ea1f0d8f5be..a3e2ed15fff2 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | |||
| @@ -1320,9 +1320,15 @@ static int sdma_v4_0_sw_init(void *handle) | |||
| 1320 | DRM_INFO("use_doorbell being set to: [%s]\n", | 1320 | DRM_INFO("use_doorbell being set to: [%s]\n", |
| 1321 | ring->use_doorbell?"true":"false"); | 1321 | ring->use_doorbell?"true":"false"); |
| 1322 | 1322 | ||
| 1323 | ring->doorbell_index = (i == 0) ? | 1323 | if (adev->asic_type == CHIP_VEGA10) |
| 1324 | (AMDGPU_DOORBELL64_sDMA_ENGINE0 << 1) //get DWORD offset | 1324 | ring->doorbell_index = (i == 0) ? |
| 1325 | : (AMDGPU_DOORBELL64_sDMA_ENGINE1 << 1); // get DWORD offset | 1325 | (AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE0 << 1) //get DWORD offset |
| 1326 | : (AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE1 << 1); // get DWORD offset | ||
| 1327 | else | ||
| 1328 | ring->doorbell_index = (i == 0) ? | ||
| 1329 | (AMDGPU_DOORBELL64_sDMA_ENGINE0 << 1) //get DWORD offset | ||
| 1330 | : (AMDGPU_DOORBELL64_sDMA_ENGINE1 << 1); // get DWORD offset | ||
| 1331 | |||
| 1326 | 1332 | ||
| 1327 | sprintf(ring->name, "sdma%d", i); | 1333 | sprintf(ring->name, "sdma%d", i); |
| 1328 | r = amdgpu_ring_init(adev, ring, 1024, | 1334 | r = amdgpu_ring_init(adev, ring, 1024, |
| @@ -1801,10 +1807,8 @@ static const struct amdgpu_buffer_funcs sdma_v4_0_buffer_funcs = { | |||
| 1801 | 1807 | ||
| 1802 | static void sdma_v4_0_set_buffer_funcs(struct amdgpu_device *adev) | 1808 | static void sdma_v4_0_set_buffer_funcs(struct amdgpu_device *adev) |
| 1803 | { | 1809 | { |
| 1804 | if (adev->mman.buffer_funcs == NULL) { | 1810 | adev->mman.buffer_funcs = &sdma_v4_0_buffer_funcs; |
| 1805 | adev->mman.buffer_funcs = &sdma_v4_0_buffer_funcs; | 1811 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; |
| 1806 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; | ||
| 1807 | } | ||
| 1808 | } | 1812 | } |
| 1809 | 1813 | ||
| 1810 | static const struct amdgpu_vm_pte_funcs sdma_v4_0_vm_pte_funcs = { | 1814 | static const struct amdgpu_vm_pte_funcs sdma_v4_0_vm_pte_funcs = { |
| @@ -1820,15 +1824,13 @@ static void sdma_v4_0_set_vm_pte_funcs(struct amdgpu_device *adev) | |||
| 1820 | struct drm_gpu_scheduler *sched; | 1824 | struct drm_gpu_scheduler *sched; |
| 1821 | unsigned i; | 1825 | unsigned i; |
| 1822 | 1826 | ||
| 1823 | if (adev->vm_manager.vm_pte_funcs == NULL) { | 1827 | adev->vm_manager.vm_pte_funcs = &sdma_v4_0_vm_pte_funcs; |
| 1824 | adev->vm_manager.vm_pte_funcs = &sdma_v4_0_vm_pte_funcs; | 1828 | for (i = 0; i < adev->sdma.num_instances; i++) { |
| 1825 | for (i = 0; i < adev->sdma.num_instances; i++) { | 1829 | sched = &adev->sdma.instance[i].ring.sched; |
| 1826 | sched = &adev->sdma.instance[i].ring.sched; | 1830 | adev->vm_manager.vm_pte_rqs[i] = |
| 1827 | adev->vm_manager.vm_pte_rqs[i] = | 1831 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; |
| 1828 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; | ||
| 1829 | } | ||
| 1830 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 1831 | } | 1832 | } |
| 1833 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 1832 | } | 1834 | } |
| 1833 | 1835 | ||
| 1834 | const struct amdgpu_ip_block_version sdma_v4_0_ip_block = { | 1836 | const struct amdgpu_ip_block_version sdma_v4_0_ip_block = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dma.c b/drivers/gpu/drm/amd/amdgpu/si_dma.c index fafaf259b17b..d4ceaf440f26 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dma.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dma.c | |||
| @@ -502,12 +502,12 @@ static int si_dma_sw_init(void *handle) | |||
| 502 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 502 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 503 | 503 | ||
| 504 | /* DMA0 trap event */ | 504 | /* DMA0 trap event */ |
| 505 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 224, &adev->sdma.trap_irq); | 505 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 224, &adev->sdma.trap_irq); |
| 506 | if (r) | 506 | if (r) |
| 507 | return r; | 507 | return r; |
| 508 | 508 | ||
| 509 | /* DMA1 trap event */ | 509 | /* DMA1 trap event */ |
| 510 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 244, &adev->sdma.trap_irq_1); | 510 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 244, &adev->sdma.trap_irq_1); |
| 511 | if (r) | 511 | if (r) |
| 512 | return r; | 512 | return r; |
| 513 | 513 | ||
| @@ -863,10 +863,8 @@ static const struct amdgpu_buffer_funcs si_dma_buffer_funcs = { | |||
| 863 | 863 | ||
| 864 | static void si_dma_set_buffer_funcs(struct amdgpu_device *adev) | 864 | static void si_dma_set_buffer_funcs(struct amdgpu_device *adev) |
| 865 | { | 865 | { |
| 866 | if (adev->mman.buffer_funcs == NULL) { | 866 | adev->mman.buffer_funcs = &si_dma_buffer_funcs; |
| 867 | adev->mman.buffer_funcs = &si_dma_buffer_funcs; | 867 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; |
| 868 | adev->mman.buffer_funcs_ring = &adev->sdma.instance[0].ring; | ||
| 869 | } | ||
| 870 | } | 868 | } |
| 871 | 869 | ||
| 872 | static const struct amdgpu_vm_pte_funcs si_dma_vm_pte_funcs = { | 870 | static const struct amdgpu_vm_pte_funcs si_dma_vm_pte_funcs = { |
| @@ -882,15 +880,13 @@ static void si_dma_set_vm_pte_funcs(struct amdgpu_device *adev) | |||
| 882 | struct drm_gpu_scheduler *sched; | 880 | struct drm_gpu_scheduler *sched; |
| 883 | unsigned i; | 881 | unsigned i; |
| 884 | 882 | ||
| 885 | if (adev->vm_manager.vm_pte_funcs == NULL) { | 883 | adev->vm_manager.vm_pte_funcs = &si_dma_vm_pte_funcs; |
| 886 | adev->vm_manager.vm_pte_funcs = &si_dma_vm_pte_funcs; | 884 | for (i = 0; i < adev->sdma.num_instances; i++) { |
| 887 | for (i = 0; i < adev->sdma.num_instances; i++) { | 885 | sched = &adev->sdma.instance[i].ring.sched; |
| 888 | sched = &adev->sdma.instance[i].ring.sched; | 886 | adev->vm_manager.vm_pte_rqs[i] = |
| 889 | adev->vm_manager.vm_pte_rqs[i] = | 887 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; |
| 890 | &sched->sched_rq[DRM_SCHED_PRIORITY_KERNEL]; | ||
| 891 | } | ||
| 892 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 893 | } | 888 | } |
| 889 | adev->vm_manager.vm_pte_num_rqs = adev->sdma.num_instances; | ||
| 894 | } | 890 | } |
| 895 | 891 | ||
| 896 | const struct amdgpu_ip_block_version si_dma_ip_block = | 892 | const struct amdgpu_ip_block_version si_dma_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c index 1de96995e690..da58040fdbdc 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c | |||
| @@ -7687,11 +7687,11 @@ static int si_dpm_sw_init(void *handle) | |||
| 7687 | int ret; | 7687 | int ret; |
| 7688 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 7688 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 7689 | 7689 | ||
| 7690 | ret = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 230, &adev->pm.dpm.thermal.irq); | 7690 | ret = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 230, &adev->pm.dpm.thermal.irq); |
| 7691 | if (ret) | 7691 | if (ret) |
| 7692 | return ret; | 7692 | return ret; |
| 7693 | 7693 | ||
| 7694 | ret = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 231, &adev->pm.dpm.thermal.irq); | 7694 | ret = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 231, &adev->pm.dpm.thermal.irq); |
| 7695 | if (ret) | 7695 | if (ret) |
| 7696 | return ret; | 7696 | return ret; |
| 7697 | 7697 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.c b/drivers/gpu/drm/amd/amdgpu/si_ih.c index 60dad63098a2..b3d7d9f83202 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/si_ih.c | |||
| @@ -142,7 +142,7 @@ static void si_ih_decode_iv(struct amdgpu_device *adev, | |||
| 142 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); | 142 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); |
| 143 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); | 143 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); |
| 144 | 144 | ||
| 145 | entry->client_id = AMDGPU_IH_CLIENTID_LEGACY; | 145 | entry->client_id = AMDGPU_IRQ_CLIENTID_LEGACY; |
| 146 | entry->src_id = dw[0] & 0xff; | 146 | entry->src_id = dw[0] & 0xff; |
| 147 | entry->src_data[0] = dw[1] & 0xfffffff; | 147 | entry->src_data[0] = dw[1] & 0xfffffff; |
| 148 | entry->ring_id = dw[2] & 0xff; | 148 | entry->ring_id = dw[2] & 0xff; |
| @@ -170,7 +170,7 @@ static int si_ih_sw_init(void *handle) | |||
| 170 | int r; | 170 | int r; |
| 171 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 171 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 172 | 172 | ||
| 173 | r = amdgpu_ih_ring_init(adev, 64 * 1024, false); | 173 | r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 64 * 1024, false); |
| 174 | if (r) | 174 | if (r) |
| 175 | return r; | 175 | return r; |
| 176 | 176 | ||
| @@ -182,7 +182,7 @@ static int si_ih_sw_fini(void *handle) | |||
| 182 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 182 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 183 | 183 | ||
| 184 | amdgpu_irq_fini(adev); | 184 | amdgpu_irq_fini(adev); |
| 185 | amdgpu_ih_ring_fini(adev); | 185 | amdgpu_ih_ring_fini(adev, &adev->irq.ih); |
| 186 | 186 | ||
| 187 | return 0; | 187 | return 0; |
| 188 | } | 188 | } |
| @@ -308,8 +308,7 @@ static const struct amdgpu_ih_funcs si_ih_funcs = { | |||
| 308 | 308 | ||
| 309 | static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev) | 309 | static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev) |
| 310 | { | 310 | { |
| 311 | if (adev->irq.ih_funcs == NULL) | 311 | adev->irq.ih_funcs = &si_ih_funcs; |
| 312 | adev->irq.ih_funcs = &si_ih_funcs; | ||
| 313 | } | 312 | } |
| 314 | 313 | ||
| 315 | const struct amdgpu_ip_block_version si_ih_ip_block = | 314 | const struct amdgpu_ip_block_version si_ih_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index 138c4810a3de..fb26039beeba 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c | |||
| @@ -739,7 +739,8 @@ static int soc15_common_early_init(void *handle) | |||
| 739 | 739 | ||
| 740 | adev->pg_flags = AMD_PG_SUPPORT_SDMA | | 740 | adev->pg_flags = AMD_PG_SUPPORT_SDMA | |
| 741 | AMD_PG_SUPPORT_MMHUB | | 741 | AMD_PG_SUPPORT_MMHUB | |
| 742 | AMD_PG_SUPPORT_VCN; | 742 | AMD_PG_SUPPORT_VCN | |
| 743 | AMD_PG_SUPPORT_VCN_DPG; | ||
| 743 | } else { | 744 | } else { |
| 744 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | | 745 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | |
| 745 | AMD_CG_SUPPORT_GFX_MGLS | | 746 | AMD_CG_SUPPORT_GFX_MGLS | |
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15_common.h b/drivers/gpu/drm/amd/amdgpu/soc15_common.h index f5d602540673..958b10a57073 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15_common.h +++ b/drivers/gpu/drm/amd/amdgpu/soc15_common.h | |||
| @@ -57,13 +57,33 @@ | |||
| 57 | loop--; \ | 57 | loop--; \ |
| 58 | if (!loop) { \ | 58 | if (!loop) { \ |
| 59 | DRM_ERROR("Register(%d) [%s] failed to reach value 0x%08x != 0x%08x\n", \ | 59 | DRM_ERROR("Register(%d) [%s] failed to reach value 0x%08x != 0x%08x\n", \ |
| 60 | inst, #reg, expected_value, (tmp_ & (mask))); \ | 60 | inst, #reg, (unsigned)expected_value, (unsigned)(tmp_ & (mask))); \ |
| 61 | ret = -ETIMEDOUT; \ | 61 | ret = -ETIMEDOUT; \ |
| 62 | break; \ | 62 | break; \ |
| 63 | } \ | 63 | } \ |
| 64 | } \ | 64 | } \ |
| 65 | } while (0) | 65 | } while (0) |
| 66 | 66 | ||
| 67 | #define RREG32_SOC15_DPG_MODE(ip, inst, reg, mask, sram_sel) \ | ||
| 68 | ({ WREG32_SOC15(ip, inst, mmUVD_DPG_LMA_MASK, mask); \ | ||
| 69 | WREG32_SOC15(ip, inst, mmUVD_DPG_LMA_CTL, \ | ||
| 70 | UVD_DPG_LMA_CTL__MASK_EN_MASK | \ | ||
| 71 | ((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) \ | ||
| 72 | << UVD_DPG_LMA_CTL__READ_WRITE_ADDR__SHIFT) | \ | ||
| 73 | (sram_sel << UVD_DPG_LMA_CTL__SRAM_SEL__SHIFT)); \ | ||
| 74 | RREG32_SOC15(ip, inst, mmUVD_DPG_LMA_DATA); }) | ||
| 75 | |||
| 76 | #define WREG32_SOC15_DPG_MODE(ip, inst, reg, value, mask, sram_sel) \ | ||
| 77 | do { \ | ||
| 78 | WREG32_SOC15(ip, inst, mmUVD_DPG_LMA_DATA, value); \ | ||
| 79 | WREG32_SOC15(ip, inst, mmUVD_DPG_LMA_MASK, mask); \ | ||
| 80 | WREG32_SOC15(ip, inst, mmUVD_DPG_LMA_CTL, \ | ||
| 81 | UVD_DPG_LMA_CTL__READ_WRITE_MASK | \ | ||
| 82 | ((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) \ | ||
| 83 | << UVD_DPG_LMA_CTL__READ_WRITE_ADDR__SHIFT) | \ | ||
| 84 | (sram_sel << UVD_DPG_LMA_CTL__SRAM_SEL__SHIFT)); \ | ||
| 85 | } while (0) | ||
| 86 | |||
| 67 | #endif | 87 | #endif |
| 68 | 88 | ||
| 69 | 89 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c index 52853d8a8fdd..3abffd06b5c7 100644 --- a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c | |||
| @@ -266,7 +266,7 @@ static void tonga_ih_decode_iv(struct amdgpu_device *adev, | |||
| 266 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); | 266 | dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]); |
| 267 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); | 267 | dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]); |
| 268 | 268 | ||
| 269 | entry->client_id = AMDGPU_IH_CLIENTID_LEGACY; | 269 | entry->client_id = AMDGPU_IRQ_CLIENTID_LEGACY; |
| 270 | entry->src_id = dw[0] & 0xff; | 270 | entry->src_id = dw[0] & 0xff; |
| 271 | entry->src_data[0] = dw[1] & 0xfffffff; | 271 | entry->src_data[0] = dw[1] & 0xfffffff; |
| 272 | entry->ring_id = dw[2] & 0xff; | 272 | entry->ring_id = dw[2] & 0xff; |
| @@ -317,7 +317,7 @@ static int tonga_ih_sw_init(void *handle) | |||
| 317 | int r; | 317 | int r; |
| 318 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 318 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 319 | 319 | ||
| 320 | r = amdgpu_ih_ring_init(adev, 64 * 1024, true); | 320 | r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 64 * 1024, true); |
| 321 | if (r) | 321 | if (r) |
| 322 | return r; | 322 | return r; |
| 323 | 323 | ||
| @@ -334,7 +334,7 @@ static int tonga_ih_sw_fini(void *handle) | |||
| 334 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 334 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 335 | 335 | ||
| 336 | amdgpu_irq_fini(adev); | 336 | amdgpu_irq_fini(adev); |
| 337 | amdgpu_ih_ring_fini(adev); | 337 | amdgpu_ih_ring_fini(adev, &adev->irq.ih); |
| 338 | amdgpu_irq_remove_domain(adev); | 338 | amdgpu_irq_remove_domain(adev); |
| 339 | 339 | ||
| 340 | return 0; | 340 | return 0; |
| @@ -513,8 +513,7 @@ static const struct amdgpu_ih_funcs tonga_ih_funcs = { | |||
| 513 | 513 | ||
| 514 | static void tonga_ih_set_interrupt_funcs(struct amdgpu_device *adev) | 514 | static void tonga_ih_set_interrupt_funcs(struct amdgpu_device *adev) |
| 515 | { | 515 | { |
| 516 | if (adev->irq.ih_funcs == NULL) | 516 | adev->irq.ih_funcs = &tonga_ih_funcs; |
| 517 | adev->irq.ih_funcs = &tonga_ih_funcs; | ||
| 518 | } | 517 | } |
| 519 | 518 | ||
| 520 | const struct amdgpu_ip_block_version tonga_ih_ip_block = | 519 | const struct amdgpu_ip_block_version tonga_ih_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c index 8a926d1df939..1fc17bf39fed 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | |||
| @@ -108,7 +108,7 @@ static int uvd_v4_2_sw_init(void *handle) | |||
| 108 | int r; | 108 | int r; |
| 109 | 109 | ||
| 110 | /* UVD TRAP */ | 110 | /* UVD TRAP */ |
| 111 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 124, &adev->uvd.inst->irq); | 111 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 124, &adev->uvd.inst->irq); |
| 112 | if (r) | 112 | if (r) |
| 113 | return r; | 113 | return r; |
| 114 | 114 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c index 50248059412e..fde6ad5ac9ab 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | |||
| @@ -105,7 +105,7 @@ static int uvd_v5_0_sw_init(void *handle) | |||
| 105 | int r; | 105 | int r; |
| 106 | 106 | ||
| 107 | /* UVD TRAP */ | 107 | /* UVD TRAP */ |
| 108 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_UVD_SYSTEM_MESSAGE, &adev->uvd.inst->irq); | 108 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_UVD_SYSTEM_MESSAGE, &adev->uvd.inst->irq); |
| 109 | if (r) | 109 | if (r) |
| 110 | return r; | 110 | return r; |
| 111 | 111 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index 6ae82cc2e55e..8ef4a5392112 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
| @@ -393,14 +393,14 @@ static int uvd_v6_0_sw_init(void *handle) | |||
| 393 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 393 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 394 | 394 | ||
| 395 | /* UVD TRAP */ | 395 | /* UVD TRAP */ |
| 396 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_UVD_SYSTEM_MESSAGE, &adev->uvd.inst->irq); | 396 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_UVD_SYSTEM_MESSAGE, &adev->uvd.inst->irq); |
| 397 | if (r) | 397 | if (r) |
| 398 | return r; | 398 | return r; |
| 399 | 399 | ||
| 400 | /* UVD ENC TRAP */ | 400 | /* UVD ENC TRAP */ |
| 401 | if (uvd_v6_0_enc_support(adev)) { | 401 | if (uvd_v6_0_enc_support(adev)) { |
| 402 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { | 402 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { |
| 403 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, i + VISLANDS30_IV_SRCID_UVD_ENC_GEN_PURP, &adev->uvd.inst->irq); | 403 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, i + VISLANDS30_IV_SRCID_UVD_ENC_GEN_PURP, &adev->uvd.inst->irq); |
| 404 | if (r) | 404 | if (r) |
| 405 | return r; | 405 | return r; |
| 406 | } | 406 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c index 7eaa54ba016b..ea28828360d3 100644 --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | |||
| @@ -417,7 +417,7 @@ static int vce_v2_0_sw_init(void *handle) | |||
| 417 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 417 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 418 | 418 | ||
| 419 | /* VCE */ | 419 | /* VCE */ |
| 420 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 167, &adev->vce.irq); | 420 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 167, &adev->vce.irq); |
| 421 | if (r) | 421 | if (r) |
| 422 | return r; | 422 | return r; |
| 423 | 423 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c index c8390f9adfd6..6dbd39730070 100644 --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | |||
| @@ -423,7 +423,7 @@ static int vce_v3_0_sw_init(void *handle) | |||
| 423 | int r, i; | 423 | int r, i; |
| 424 | 424 | ||
| 425 | /* VCE */ | 425 | /* VCE */ |
| 426 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_VCE_TRAP, &adev->vce.irq); | 426 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_VCE_TRAP, &adev->vce.irq); |
| 427 | if (r) | 427 | if (r) |
| 428 | return r; | 428 | return r; |
| 429 | 429 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c index 2664bb2c47c3..63d7f97e81b7 100644 --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | |||
| @@ -198,7 +198,8 @@ static int vcn_v1_0_hw_init(void *handle) | |||
| 198 | 198 | ||
| 199 | done: | 199 | done: |
| 200 | if (!r) | 200 | if (!r) |
| 201 | DRM_INFO("VCN decode and encode initialized successfully.\n"); | 201 | DRM_INFO("VCN decode and encode initialized successfully(under %s).\n", |
| 202 | (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG)?"DPG Mode":"SPG Mode"); | ||
| 202 | 203 | ||
| 203 | return r; | 204 | return r; |
| 204 | } | 205 | } |
| @@ -266,13 +267,13 @@ static int vcn_v1_0_resume(void *handle) | |||
| 266 | } | 267 | } |
| 267 | 268 | ||
| 268 | /** | 269 | /** |
| 269 | * vcn_v1_0_mc_resume - memory controller programming | 270 | * vcn_v1_0_mc_resume_spg_mode - memory controller programming |
| 270 | * | 271 | * |
| 271 | * @adev: amdgpu_device pointer | 272 | * @adev: amdgpu_device pointer |
| 272 | * | 273 | * |
| 273 | * Let the VCN memory controller know it's offsets | 274 | * Let the VCN memory controller know it's offsets |
| 274 | */ | 275 | */ |
| 275 | static void vcn_v1_0_mc_resume(struct amdgpu_device *adev) | 276 | static void vcn_v1_0_mc_resume_spg_mode(struct amdgpu_device *adev) |
| 276 | { | 277 | { |
| 277 | uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); | 278 | uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); |
| 278 | uint32_t offset; | 279 | uint32_t offset; |
| @@ -319,6 +320,65 @@ static void vcn_v1_0_mc_resume(struct amdgpu_device *adev) | |||
| 319 | adev->gfx.config.gb_addr_config); | 320 | adev->gfx.config.gb_addr_config); |
| 320 | } | 321 | } |
| 321 | 322 | ||
| 323 | static void vcn_v1_0_mc_resume_dpg_mode(struct amdgpu_device *adev) | ||
| 324 | { | ||
| 325 | uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); | ||
| 326 | uint32_t offset; | ||
| 327 | |||
| 328 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { | ||
| 329 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, | ||
| 330 | (adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].tmr_mc_addr_lo), | ||
| 331 | 0xFFFFFFFF, 0); | ||
| 332 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, | ||
| 333 | (adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].tmr_mc_addr_hi), | ||
| 334 | 0xFFFFFFFF, 0); | ||
| 335 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET0, 0, | ||
| 336 | 0xFFFFFFFF, 0); | ||
| 337 | offset = 0; | ||
| 338 | } else { | ||
| 339 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, | ||
| 340 | lower_32_bits(adev->vcn.gpu_addr), 0xFFFFFFFF, 0); | ||
| 341 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, | ||
| 342 | upper_32_bits(adev->vcn.gpu_addr), 0xFFFFFFFF, 0); | ||
| 343 | offset = size; | ||
| 344 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET0, | ||
| 345 | AMDGPU_UVD_FIRMWARE_OFFSET >> 3, 0xFFFFFFFF, 0); | ||
| 346 | } | ||
| 347 | |||
| 348 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE0, size, 0xFFFFFFFF, 0); | ||
| 349 | |||
| 350 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, | ||
| 351 | lower_32_bits(adev->vcn.gpu_addr + offset), 0xFFFFFFFF, 0); | ||
| 352 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, | ||
| 353 | upper_32_bits(adev->vcn.gpu_addr + offset), 0xFFFFFFFF, 0); | ||
| 354 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1, 0, | ||
| 355 | 0xFFFFFFFF, 0); | ||
| 356 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_HEAP_SIZE, | ||
| 357 | 0xFFFFFFFF, 0); | ||
| 358 | |||
| 359 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, | ||
| 360 | lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE), | ||
| 361 | 0xFFFFFFFF, 0); | ||
| 362 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, | ||
| 363 | upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE), | ||
| 364 | 0xFFFFFFFF, 0); | ||
| 365 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2, 0, 0xFFFFFFFF, 0); | ||
| 366 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, | ||
| 367 | AMDGPU_VCN_STACK_SIZE + (AMDGPU_VCN_SESSION_SIZE * 40), | ||
| 368 | 0xFFFFFFFF, 0); | ||
| 369 | |||
| 370 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_UDEC_ADDR_CONFIG, | ||
| 371 | adev->gfx.config.gb_addr_config, 0xFFFFFFFF, 0); | ||
| 372 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_UDEC_DB_ADDR_CONFIG, | ||
| 373 | adev->gfx.config.gb_addr_config, 0xFFFFFFFF, 0); | ||
| 374 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_UDEC_DBW_ADDR_CONFIG, | ||
| 375 | adev->gfx.config.gb_addr_config, 0xFFFFFFFF, 0); | ||
| 376 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_JPEG_ADDR_CONFIG, | ||
| 377 | adev->gfx.config.gb_addr_config, 0xFFFFFFFF, 0); | ||
| 378 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_JPEG_UV_ADDR_CONFIG, | ||
| 379 | adev->gfx.config.gb_addr_config, 0xFFFFFFFF, 0); | ||
| 380 | } | ||
| 381 | |||
| 322 | /** | 382 | /** |
| 323 | * vcn_v1_0_disable_clock_gating - disable VCN clock gating | 383 | * vcn_v1_0_disable_clock_gating - disable VCN clock gating |
| 324 | * | 384 | * |
| @@ -519,6 +579,62 @@ static void vcn_v1_0_enable_clock_gating(struct amdgpu_device *adev) | |||
| 519 | WREG32_SOC15(VCN, 0, mmUVD_SUVD_CGC_CTRL, data); | 579 | WREG32_SOC15(VCN, 0, mmUVD_SUVD_CGC_CTRL, data); |
| 520 | } | 580 | } |
| 521 | 581 | ||
| 582 | static void vcn_v1_0_clock_gating_dpg_mode(struct amdgpu_device *adev, uint8_t sram_sel) | ||
| 583 | { | ||
| 584 | uint32_t reg_data = 0; | ||
| 585 | |||
| 586 | /* disable JPEG CGC */ | ||
| 587 | if (adev->cg_flags & AMD_CG_SUPPORT_VCN_MGCG) | ||
| 588 | reg_data = 1 << JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | ||
| 589 | else | ||
| 590 | reg_data = 0 << JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | ||
| 591 | reg_data |= 1 << JPEG_CGC_CTRL__CLK_GATE_DLY_TIMER__SHIFT; | ||
| 592 | reg_data |= 4 << JPEG_CGC_CTRL__CLK_OFF_DELAY__SHIFT; | ||
| 593 | WREG32_SOC15_DPG_MODE(UVD, 0, mmJPEG_CGC_CTRL, reg_data, 0xFFFFFFFF, sram_sel); | ||
| 594 | |||
| 595 | WREG32_SOC15_DPG_MODE(UVD, 0, mmJPEG_CGC_GATE, 0, 0xFFFFFFFF, sram_sel); | ||
| 596 | |||
| 597 | /* enable sw clock gating control */ | ||
| 598 | if (adev->cg_flags & AMD_CG_SUPPORT_VCN_MGCG) | ||
| 599 | reg_data = 1 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | ||
| 600 | else | ||
| 601 | reg_data = 0 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | ||
| 602 | reg_data |= 1 << UVD_CGC_CTRL__CLK_GATE_DLY_TIMER__SHIFT; | ||
| 603 | reg_data |= 4 << UVD_CGC_CTRL__CLK_OFF_DELAY__SHIFT; | ||
| 604 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_CGC_CTRL, reg_data, 0xFFFFFFFF, sram_sel); | ||
| 605 | |||
| 606 | reg_data &= ~(UVD_CGC_CTRL__UDEC_RE_MODE_MASK | | ||
| 607 | UVD_CGC_CTRL__UDEC_CM_MODE_MASK | | ||
| 608 | UVD_CGC_CTRL__UDEC_IT_MODE_MASK | | ||
| 609 | UVD_CGC_CTRL__UDEC_DB_MODE_MASK | | ||
| 610 | UVD_CGC_CTRL__UDEC_MP_MODE_MASK | | ||
| 611 | UVD_CGC_CTRL__SYS_MODE_MASK | | ||
| 612 | UVD_CGC_CTRL__UDEC_MODE_MASK | | ||
| 613 | UVD_CGC_CTRL__MPEG2_MODE_MASK | | ||
| 614 | UVD_CGC_CTRL__REGS_MODE_MASK | | ||
| 615 | UVD_CGC_CTRL__RBC_MODE_MASK | | ||
| 616 | UVD_CGC_CTRL__LMI_MC_MODE_MASK | | ||
| 617 | UVD_CGC_CTRL__LMI_UMC_MODE_MASK | | ||
| 618 | UVD_CGC_CTRL__IDCT_MODE_MASK | | ||
| 619 | UVD_CGC_CTRL__MPRD_MODE_MASK | | ||
| 620 | UVD_CGC_CTRL__MPC_MODE_MASK | | ||
| 621 | UVD_CGC_CTRL__LBSI_MODE_MASK | | ||
| 622 | UVD_CGC_CTRL__LRBBM_MODE_MASK | | ||
| 623 | UVD_CGC_CTRL__WCB_MODE_MASK | | ||
| 624 | UVD_CGC_CTRL__VCPU_MODE_MASK | | ||
| 625 | UVD_CGC_CTRL__SCPU_MODE_MASK); | ||
| 626 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_CGC_CTRL, reg_data, 0xFFFFFFFF, sram_sel); | ||
| 627 | |||
| 628 | /* turn off clock gating */ | ||
| 629 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_CGC_GATE, 0, 0xFFFFFFFF, sram_sel); | ||
| 630 | |||
| 631 | /* turn on SUVD clock gating */ | ||
| 632 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_SUVD_CGC_GATE, 1, 0xFFFFFFFF, sram_sel); | ||
| 633 | |||
| 634 | /* turn on sw mode in UVD_SUVD_CGC_CTRL */ | ||
| 635 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_SUVD_CGC_CTRL, 0, 0xFFFFFFFF, sram_sel); | ||
| 636 | } | ||
| 637 | |||
| 522 | static void vcn_1_0_disable_static_power_gating(struct amdgpu_device *adev) | 638 | static void vcn_1_0_disable_static_power_gating(struct amdgpu_device *adev) |
| 523 | { | 639 | { |
| 524 | uint32_t data = 0; | 640 | uint32_t data = 0; |
| @@ -614,7 +730,7 @@ static void vcn_1_0_enable_static_power_gating(struct amdgpu_device *adev) | |||
| 614 | * | 730 | * |
| 615 | * Setup and start the VCN block | 731 | * Setup and start the VCN block |
| 616 | */ | 732 | */ |
| 617 | static int vcn_v1_0_start(struct amdgpu_device *adev) | 733 | static int vcn_v1_0_start_spg_mode(struct amdgpu_device *adev) |
| 618 | { | 734 | { |
| 619 | struct amdgpu_ring *ring = &adev->vcn.ring_dec; | 735 | struct amdgpu_ring *ring = &adev->vcn.ring_dec; |
| 620 | uint32_t rb_bufsz, tmp; | 736 | uint32_t rb_bufsz, tmp; |
| @@ -628,7 +744,7 @@ static int vcn_v1_0_start(struct amdgpu_device *adev) | |||
| 628 | /* disable clock gating */ | 744 | /* disable clock gating */ |
| 629 | vcn_v1_0_disable_clock_gating(adev); | 745 | vcn_v1_0_disable_clock_gating(adev); |
| 630 | 746 | ||
| 631 | vcn_v1_0_mc_resume(adev); | 747 | vcn_v1_0_mc_resume_spg_mode(adev); |
| 632 | 748 | ||
| 633 | /* disable interupt */ | 749 | /* disable interupt */ |
| 634 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_MASTINT_EN), 0, | 750 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_MASTINT_EN), 0, |
| @@ -799,6 +915,170 @@ static int vcn_v1_0_start(struct amdgpu_device *adev) | |||
| 799 | return 0; | 915 | return 0; |
| 800 | } | 916 | } |
| 801 | 917 | ||
| 918 | static int vcn_v1_0_start_dpg_mode(struct amdgpu_device *adev) | ||
| 919 | { | ||
| 920 | struct amdgpu_ring *ring = &adev->vcn.ring_dec; | ||
| 921 | uint32_t rb_bufsz, tmp, reg_data; | ||
| 922 | uint32_t lmi_swap_cntl; | ||
| 923 | |||
| 924 | /* disable byte swapping */ | ||
| 925 | lmi_swap_cntl = 0; | ||
| 926 | |||
| 927 | vcn_1_0_enable_static_power_gating(adev); | ||
| 928 | |||
| 929 | /* enable dynamic power gating mode */ | ||
| 930 | reg_data = RREG32_SOC15(UVD, 0, mmUVD_POWER_STATUS); | ||
| 931 | reg_data |= UVD_POWER_STATUS__UVD_PG_MODE_MASK; | ||
| 932 | reg_data |= UVD_POWER_STATUS__UVD_PG_EN_MASK; | ||
| 933 | WREG32_SOC15(UVD, 0, mmUVD_POWER_STATUS, reg_data); | ||
| 934 | |||
| 935 | /* enable clock gating */ | ||
| 936 | vcn_v1_0_clock_gating_dpg_mode(adev, 0); | ||
| 937 | |||
| 938 | /* enable VCPU clock */ | ||
| 939 | reg_data = (0xFF << UVD_VCPU_CNTL__PRB_TIMEOUT_VAL__SHIFT); | ||
| 940 | reg_data |= UVD_VCPU_CNTL__CLK_EN_MASK; | ||
| 941 | reg_data |= UVD_VCPU_CNTL__MIF_WR_LOW_THRESHOLD_BP_MASK; | ||
| 942 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CNTL, reg_data, 0xFFFFFFFF, 0); | ||
| 943 | |||
| 944 | /* disable interupt */ | ||
| 945 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_MASTINT_EN, | ||
| 946 | 0, UVD_MASTINT_EN__VCPU_EN_MASK, 0); | ||
| 947 | |||
| 948 | /* stall UMC and register bus before resetting VCPU */ | ||
| 949 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_CTRL2, | ||
| 950 | UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, 0); | ||
| 951 | |||
| 952 | /* put LMI, VCPU, RBC etc... into reset */ | ||
| 953 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_SOFT_RESET, | ||
| 954 | UVD_SOFT_RESET__LMI_SOFT_RESET_MASK | | ||
| 955 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK | | ||
| 956 | UVD_SOFT_RESET__LBSI_SOFT_RESET_MASK | | ||
| 957 | UVD_SOFT_RESET__RBC_SOFT_RESET_MASK | | ||
| 958 | UVD_SOFT_RESET__CSM_SOFT_RESET_MASK | | ||
| 959 | UVD_SOFT_RESET__CXW_SOFT_RESET_MASK | | ||
| 960 | UVD_SOFT_RESET__TAP_SOFT_RESET_MASK | | ||
| 961 | UVD_SOFT_RESET__LMI_UMC_SOFT_RESET_MASK, | ||
| 962 | 0xFFFFFFFF, 0); | ||
| 963 | |||
| 964 | /* initialize VCN memory controller */ | ||
| 965 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_CTRL, | ||
| 966 | (0x40 << UVD_LMI_CTRL__WRITE_CLEAN_TIMER__SHIFT) | | ||
| 967 | UVD_LMI_CTRL__WRITE_CLEAN_TIMER_EN_MASK | | ||
| 968 | UVD_LMI_CTRL__DATA_COHERENCY_EN_MASK | | ||
| 969 | UVD_LMI_CTRL__VCPU_DATA_COHERENCY_EN_MASK | | ||
| 970 | UVD_LMI_CTRL__REQ_MODE_MASK | | ||
| 971 | 0x00100000L, 0xFFFFFFFF, 0); | ||
| 972 | |||
| 973 | #ifdef __BIG_ENDIAN | ||
| 974 | /* swap (8 in 32) RB and IB */ | ||
| 975 | lmi_swap_cntl = 0xa; | ||
| 976 | #endif | ||
| 977 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_SWAP_CNTL, lmi_swap_cntl, 0xFFFFFFFF, 0); | ||
| 978 | |||
| 979 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_MPC_SET_MUXA0, 0x40c2040, 0xFFFFFFFF, 0); | ||
| 980 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_MPC_SET_MUXA1, 0x0, 0xFFFFFFFF, 0); | ||
| 981 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_MPC_SET_MUXB0, 0x40c2040, 0xFFFFFFFF, 0); | ||
| 982 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_MPC_SET_MUXB1, 0x0, 0xFFFFFFFF, 0); | ||
| 983 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_MPC_SET_ALU, 0, 0xFFFFFFFF, 0); | ||
| 984 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_MPC_SET_MUX, 0x88, 0xFFFFFFFF, 0); | ||
| 985 | |||
| 986 | vcn_v1_0_mc_resume_dpg_mode(adev); | ||
| 987 | |||
| 988 | /* take all subblocks out of reset, except VCPU */ | ||
| 989 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_SOFT_RESET, | ||
| 990 | UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK, 0xFFFFFFFF, 0); | ||
| 991 | |||
| 992 | /* enable VCPU clock */ | ||
| 993 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CNTL, | ||
| 994 | UVD_VCPU_CNTL__CLK_EN_MASK, 0xFFFFFFFF, 0); | ||
| 995 | |||
| 996 | /* enable UMC */ | ||
| 997 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_CTRL2, | ||
| 998 | 0, UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, 0); | ||
| 999 | |||
| 1000 | /* boot up the VCPU */ | ||
| 1001 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_SOFT_RESET, 0, 0xFFFFFFFF, 0); | ||
| 1002 | |||
| 1003 | /* enable master interrupt */ | ||
| 1004 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_MASTINT_EN, | ||
| 1005 | (UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK), | ||
| 1006 | (UVD_MASTINT_EN__VCPU_EN_MASK|UVD_MASTINT_EN__SYS_EN_MASK), 0); | ||
| 1007 | |||
| 1008 | vcn_v1_0_clock_gating_dpg_mode(adev, 1); | ||
| 1009 | /* setup mmUVD_LMI_CTRL */ | ||
| 1010 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_CTRL, | ||
| 1011 | (UVD_LMI_CTRL__WRITE_CLEAN_TIMER_EN_MASK | | ||
| 1012 | UVD_LMI_CTRL__CRC_RESET_MASK | | ||
| 1013 | UVD_LMI_CTRL__MASK_MC_URGENT_MASK | | ||
| 1014 | UVD_LMI_CTRL__DATA_COHERENCY_EN_MASK | | ||
| 1015 | UVD_LMI_CTRL__VCPU_DATA_COHERENCY_EN_MASK | | ||
| 1016 | (8 << UVD_LMI_CTRL__WRITE_CLEAN_TIMER__SHIFT) | | ||
| 1017 | 0x00100000L), 0xFFFFFFFF, 1); | ||
| 1018 | |||
| 1019 | tmp = adev->gfx.config.gb_addr_config; | ||
| 1020 | /* setup VCN global tiling registers */ | ||
| 1021 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_JPEG_ADDR_CONFIG, tmp, 0xFFFFFFFF, 1); | ||
| 1022 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_JPEG_UV_ADDR_CONFIG, tmp, 0xFFFFFFFF, 1); | ||
| 1023 | |||
| 1024 | /* enable System Interrupt for JRBC */ | ||
| 1025 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_SYS_INT_EN, | ||
| 1026 | UVD_SYS_INT_EN__UVD_JRBC_EN_MASK, 0xFFFFFFFF, 1); | ||
| 1027 | |||
| 1028 | /* force RBC into idle state */ | ||
| 1029 | rb_bufsz = order_base_2(ring->ring_size); | ||
| 1030 | tmp = REG_SET_FIELD(0, UVD_RBC_RB_CNTL, RB_BUFSZ, rb_bufsz); | ||
| 1031 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_BLKSZ, 1); | ||
| 1032 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_FETCH, 1); | ||
| 1033 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_WPTR_POLL_EN, 0); | ||
| 1034 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_UPDATE, 1); | ||
| 1035 | tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_RPTR_WR_EN, 1); | ||
| 1036 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_CNTL, tmp); | ||
| 1037 | |||
| 1038 | /* set the write pointer delay */ | ||
| 1039 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR_CNTL, 0); | ||
| 1040 | |||
| 1041 | /* set the wb address */ | ||
| 1042 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR_ADDR, | ||
| 1043 | (upper_32_bits(ring->gpu_addr) >> 2)); | ||
| 1044 | |||
| 1045 | /* programm the RB_BASE for ring buffer */ | ||
| 1046 | WREG32_SOC15(UVD, 0, mmUVD_LMI_RBC_RB_64BIT_BAR_LOW, | ||
| 1047 | lower_32_bits(ring->gpu_addr)); | ||
| 1048 | WREG32_SOC15(UVD, 0, mmUVD_LMI_RBC_RB_64BIT_BAR_HIGH, | ||
| 1049 | upper_32_bits(ring->gpu_addr)); | ||
| 1050 | |||
| 1051 | /* Initialize the ring buffer's read and write pointers */ | ||
| 1052 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR, 0); | ||
| 1053 | |||
| 1054 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); | ||
| 1055 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, | ||
| 1056 | lower_32_bits(ring->wptr)); | ||
| 1057 | |||
| 1058 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_RBC_RB_CNTL), 0, | ||
| 1059 | ~UVD_RBC_RB_CNTL__RB_NO_FETCH_MASK); | ||
| 1060 | |||
| 1061 | /* initialize wptr */ | ||
| 1062 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR); | ||
| 1063 | |||
| 1064 | /* copy patch commands to the jpeg ring */ | ||
| 1065 | vcn_v1_0_jpeg_ring_set_patch_ring(ring, | ||
| 1066 | (ring->wptr + ring->max_dw * amdgpu_sched_hw_submission)); | ||
| 1067 | |||
| 1068 | return 0; | ||
| 1069 | } | ||
| 1070 | |||
| 1071 | static int vcn_v1_0_start(struct amdgpu_device *adev) | ||
| 1072 | { | ||
| 1073 | int r; | ||
| 1074 | |||
| 1075 | if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) | ||
| 1076 | r = vcn_v1_0_start_dpg_mode(adev); | ||
| 1077 | else | ||
| 1078 | r = vcn_v1_0_start_spg_mode(adev); | ||
| 1079 | return r; | ||
| 1080 | } | ||
| 1081 | |||
| 802 | /** | 1082 | /** |
| 803 | * vcn_v1_0_stop - stop VCN block | 1083 | * vcn_v1_0_stop - stop VCN block |
| 804 | * | 1084 | * |
| @@ -806,7 +1086,7 @@ static int vcn_v1_0_start(struct amdgpu_device *adev) | |||
| 806 | * | 1086 | * |
| 807 | * stop the VCN block | 1087 | * stop the VCN block |
| 808 | */ | 1088 | */ |
| 809 | static int vcn_v1_0_stop(struct amdgpu_device *adev) | 1089 | static int vcn_v1_0_stop_spg_mode(struct amdgpu_device *adev) |
| 810 | { | 1090 | { |
| 811 | /* force RBC into idle state */ | 1091 | /* force RBC into idle state */ |
| 812 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_CNTL, 0x11010101); | 1092 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_CNTL, 0x11010101); |
| @@ -836,6 +1116,33 @@ static int vcn_v1_0_stop(struct amdgpu_device *adev) | |||
| 836 | return 0; | 1116 | return 0; |
| 837 | } | 1117 | } |
| 838 | 1118 | ||
| 1119 | static int vcn_v1_0_stop_dpg_mode(struct amdgpu_device *adev) | ||
| 1120 | { | ||
| 1121 | int ret_code; | ||
| 1122 | |||
| 1123 | /* Wait for power status to be 1 */ | ||
| 1124 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, 0x1, | ||
| 1125 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); | ||
| 1126 | |||
| 1127 | /* disable dynamic power gating mode */ | ||
| 1128 | WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_POWER_STATUS), 0, | ||
| 1129 | ~UVD_POWER_STATUS__UVD_PG_MODE_MASK); | ||
| 1130 | |||
| 1131 | return 0; | ||
| 1132 | } | ||
| 1133 | |||
| 1134 | static int vcn_v1_0_stop(struct amdgpu_device *adev) | ||
| 1135 | { | ||
| 1136 | int r; | ||
| 1137 | |||
| 1138 | if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) | ||
| 1139 | r = vcn_v1_0_stop_dpg_mode(adev); | ||
| 1140 | else | ||
| 1141 | r = vcn_v1_0_stop_spg_mode(adev); | ||
| 1142 | |||
| 1143 | return r; | ||
| 1144 | } | ||
| 1145 | |||
| 839 | static bool vcn_v1_0_is_idle(void *handle) | 1146 | static bool vcn_v1_0_is_idle(void *handle) |
| 840 | { | 1147 | { |
| 841 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1148 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| @@ -1633,12 +1940,20 @@ static int vcn_v1_0_set_powergating_state(void *handle, | |||
| 1633 | * revisit this when there is a cleaner line between | 1940 | * revisit this when there is a cleaner line between |
| 1634 | * the smc and the hw blocks | 1941 | * the smc and the hw blocks |
| 1635 | */ | 1942 | */ |
| 1943 | int ret; | ||
| 1636 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1944 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1637 | 1945 | ||
| 1946 | if(state == adev->vcn.cur_state) | ||
| 1947 | return 0; | ||
| 1948 | |||
| 1638 | if (state == AMD_PG_STATE_GATE) | 1949 | if (state == AMD_PG_STATE_GATE) |
| 1639 | return vcn_v1_0_stop(adev); | 1950 | ret = vcn_v1_0_stop(adev); |
| 1640 | else | 1951 | else |
| 1641 | return vcn_v1_0_start(adev); | 1952 | ret = vcn_v1_0_start(adev); |
| 1953 | |||
| 1954 | if(!ret) | ||
| 1955 | adev->vcn.cur_state = state; | ||
| 1956 | return ret; | ||
| 1642 | } | 1957 | } |
| 1643 | 1958 | ||
| 1644 | static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { | 1959 | static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c index acbe5a770207..a99f71797aa3 100644 --- a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c | |||
| @@ -380,7 +380,7 @@ static int vega10_ih_sw_init(void *handle) | |||
| 380 | int r; | 380 | int r; |
| 381 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 381 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 382 | 382 | ||
| 383 | r = amdgpu_ih_ring_init(adev, 256 * 1024, true); | 383 | r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 256 * 1024, true); |
| 384 | if (r) | 384 | if (r) |
| 385 | return r; | 385 | return r; |
| 386 | 386 | ||
| @@ -397,7 +397,7 @@ static int vega10_ih_sw_fini(void *handle) | |||
| 397 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 397 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 398 | 398 | ||
| 399 | amdgpu_irq_fini(adev); | 399 | amdgpu_irq_fini(adev); |
| 400 | amdgpu_ih_ring_fini(adev); | 400 | amdgpu_ih_ring_fini(adev, &adev->irq.ih); |
| 401 | 401 | ||
| 402 | return 0; | 402 | return 0; |
| 403 | } | 403 | } |
| @@ -494,8 +494,7 @@ static const struct amdgpu_ih_funcs vega10_ih_funcs = { | |||
| 494 | 494 | ||
| 495 | static void vega10_ih_set_interrupt_funcs(struct amdgpu_device *adev) | 495 | static void vega10_ih_set_interrupt_funcs(struct amdgpu_device *adev) |
| 496 | { | 496 | { |
| 497 | if (adev->irq.ih_funcs == NULL) | 497 | adev->irq.ih_funcs = &vega10_ih_funcs; |
| 498 | adev->irq.ih_funcs = &vega10_ih_funcs; | ||
| 499 | } | 498 | } |
| 500 | 499 | ||
| 501 | const struct amdgpu_ip_block_version vega10_ih_ip_block = | 500 | const struct amdgpu_ip_block_version vega10_ih_ip_block = |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 758398bdb39b..14d5b5fa822d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | |||
| @@ -447,6 +447,24 @@ static int kfd_ioctl_set_cu_mask(struct file *filp, struct kfd_process *p, | |||
| 447 | return retval; | 447 | return retval; |
| 448 | } | 448 | } |
| 449 | 449 | ||
| 450 | static int kfd_ioctl_get_queue_wave_state(struct file *filep, | ||
| 451 | struct kfd_process *p, void *data) | ||
| 452 | { | ||
| 453 | struct kfd_ioctl_get_queue_wave_state_args *args = data; | ||
| 454 | int r; | ||
| 455 | |||
| 456 | mutex_lock(&p->mutex); | ||
| 457 | |||
| 458 | r = pqm_get_wave_state(&p->pqm, args->queue_id, | ||
| 459 | (void __user *)args->ctl_stack_address, | ||
| 460 | &args->ctl_stack_used_size, | ||
| 461 | &args->save_area_used_size); | ||
| 462 | |||
| 463 | mutex_unlock(&p->mutex); | ||
| 464 | |||
| 465 | return r; | ||
| 466 | } | ||
| 467 | |||
| 450 | static int kfd_ioctl_set_memory_policy(struct file *filep, | 468 | static int kfd_ioctl_set_memory_policy(struct file *filep, |
| 451 | struct kfd_process *p, void *data) | 469 | struct kfd_process *p, void *data) |
| 452 | { | 470 | { |
| @@ -1615,6 +1633,9 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = { | |||
| 1615 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_CU_MASK, | 1633 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_CU_MASK, |
| 1616 | kfd_ioctl_set_cu_mask, 0), | 1634 | kfd_ioctl_set_cu_mask, 0), |
| 1617 | 1635 | ||
| 1636 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_QUEUE_WAVE_STATE, | ||
| 1637 | kfd_ioctl_get_queue_wave_state, 0) | ||
| 1638 | |||
| 1618 | }; | 1639 | }; |
| 1619 | 1640 | ||
| 1620 | #define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls) | 1641 | #define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls) |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c index d4560f1869bd..56412b0e7e1c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c | |||
| @@ -647,6 +647,7 @@ static int kfd_fill_gpu_cache_info(struct kfd_dev *kdev, | |||
| 647 | num_of_cache_types = ARRAY_SIZE(polaris11_cache_info); | 647 | num_of_cache_types = ARRAY_SIZE(polaris11_cache_info); |
| 648 | break; | 648 | break; |
| 649 | case CHIP_VEGA10: | 649 | case CHIP_VEGA10: |
| 650 | case CHIP_VEGA20: | ||
| 650 | pcache_info = vega10_cache_info; | 651 | pcache_info = vega10_cache_info; |
| 651 | num_of_cache_types = ARRAY_SIZE(vega10_cache_info); | 652 | num_of_cache_types = ARRAY_SIZE(vega10_cache_info); |
| 652 | break; | 653 | break; |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c index 9b4e6ad4a7df..a9f18ea7e354 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c | |||
| @@ -53,6 +53,7 @@ static const struct kfd_device_info kaveri_device_info = { | |||
| 53 | .needs_iommu_device = true, | 53 | .needs_iommu_device = true, |
| 54 | .needs_pci_atomics = false, | 54 | .needs_pci_atomics = false, |
| 55 | .num_sdma_engines = 2, | 55 | .num_sdma_engines = 2, |
| 56 | .num_sdma_queues_per_engine = 2, | ||
| 56 | }; | 57 | }; |
| 57 | 58 | ||
| 58 | static const struct kfd_device_info carrizo_device_info = { | 59 | static const struct kfd_device_info carrizo_device_info = { |
| @@ -69,6 +70,7 @@ static const struct kfd_device_info carrizo_device_info = { | |||
| 69 | .needs_iommu_device = true, | 70 | .needs_iommu_device = true, |
| 70 | .needs_pci_atomics = false, | 71 | .needs_pci_atomics = false, |
| 71 | .num_sdma_engines = 2, | 72 | .num_sdma_engines = 2, |
| 73 | .num_sdma_queues_per_engine = 2, | ||
| 72 | }; | 74 | }; |
| 73 | 75 | ||
| 74 | static const struct kfd_device_info raven_device_info = { | 76 | static const struct kfd_device_info raven_device_info = { |
| @@ -84,6 +86,7 @@ static const struct kfd_device_info raven_device_info = { | |||
| 84 | .needs_iommu_device = true, | 86 | .needs_iommu_device = true, |
| 85 | .needs_pci_atomics = true, | 87 | .needs_pci_atomics = true, |
| 86 | .num_sdma_engines = 1, | 88 | .num_sdma_engines = 1, |
| 89 | .num_sdma_queues_per_engine = 2, | ||
| 87 | }; | 90 | }; |
| 88 | #endif | 91 | #endif |
| 89 | 92 | ||
| @@ -101,6 +104,7 @@ static const struct kfd_device_info hawaii_device_info = { | |||
| 101 | .needs_iommu_device = false, | 104 | .needs_iommu_device = false, |
| 102 | .needs_pci_atomics = false, | 105 | .needs_pci_atomics = false, |
| 103 | .num_sdma_engines = 2, | 106 | .num_sdma_engines = 2, |
| 107 | .num_sdma_queues_per_engine = 2, | ||
| 104 | }; | 108 | }; |
| 105 | 109 | ||
| 106 | static const struct kfd_device_info tonga_device_info = { | 110 | static const struct kfd_device_info tonga_device_info = { |
| @@ -116,21 +120,7 @@ static const struct kfd_device_info tonga_device_info = { | |||
| 116 | .needs_iommu_device = false, | 120 | .needs_iommu_device = false, |
| 117 | .needs_pci_atomics = true, | 121 | .needs_pci_atomics = true, |
| 118 | .num_sdma_engines = 2, | 122 | .num_sdma_engines = 2, |
| 119 | }; | 123 | .num_sdma_queues_per_engine = 2, |
| 120 | |||
| 121 | static const struct kfd_device_info tonga_vf_device_info = { | ||
| 122 | .asic_family = CHIP_TONGA, | ||
| 123 | .max_pasid_bits = 16, | ||
| 124 | .max_no_of_hqd = 24, | ||
| 125 | .doorbell_size = 4, | ||
| 126 | .ih_ring_entry_size = 4 * sizeof(uint32_t), | ||
| 127 | .event_interrupt_class = &event_interrupt_class_cik, | ||
| 128 | .num_of_watch_points = 4, | ||
| 129 | .mqd_size_aligned = MQD_SIZE_ALIGNED, | ||
| 130 | .supports_cwsr = false, | ||
| 131 | .needs_iommu_device = false, | ||
| 132 | .needs_pci_atomics = false, | ||
| 133 | .num_sdma_engines = 2, | ||
| 134 | }; | 124 | }; |
| 135 | 125 | ||
| 136 | static const struct kfd_device_info fiji_device_info = { | 126 | static const struct kfd_device_info fiji_device_info = { |
| @@ -146,6 +136,7 @@ static const struct kfd_device_info fiji_device_info = { | |||
| 146 | .needs_iommu_device = false, | 136 | .needs_iommu_device = false, |
| 147 | .needs_pci_atomics = true, | 137 | .needs_pci_atomics = true, |
| 148 | .num_sdma_engines = 2, | 138 | .num_sdma_engines = 2, |
| 139 | .num_sdma_queues_per_engine = 2, | ||
| 149 | }; | 140 | }; |
| 150 | 141 | ||
| 151 | static const struct kfd_device_info fiji_vf_device_info = { | 142 | static const struct kfd_device_info fiji_vf_device_info = { |
| @@ -161,6 +152,7 @@ static const struct kfd_device_info fiji_vf_device_info = { | |||
| 161 | .needs_iommu_device = false, | 152 | .needs_iommu_device = false, |
| 162 | .needs_pci_atomics = false, | 153 | .needs_pci_atomics = false, |
| 163 | .num_sdma_engines = 2, | 154 | .num_sdma_engines = 2, |
| 155 | .num_sdma_queues_per_engine = 2, | ||
| 164 | }; | 156 | }; |
| 165 | 157 | ||
| 166 | 158 | ||
| @@ -177,6 +169,7 @@ static const struct kfd_device_info polaris10_device_info = { | |||
| 177 | .needs_iommu_device = false, | 169 | .needs_iommu_device = false, |
| 178 | .needs_pci_atomics = true, | 170 | .needs_pci_atomics = true, |
| 179 | .num_sdma_engines = 2, | 171 | .num_sdma_engines = 2, |
| 172 | .num_sdma_queues_per_engine = 2, | ||
| 180 | }; | 173 | }; |
| 181 | 174 | ||
| 182 | static const struct kfd_device_info polaris10_vf_device_info = { | 175 | static const struct kfd_device_info polaris10_vf_device_info = { |
| @@ -192,6 +185,7 @@ static const struct kfd_device_info polaris10_vf_device_info = { | |||
| 192 | .needs_iommu_device = false, | 185 | .needs_iommu_device = false, |
| 193 | .needs_pci_atomics = false, | 186 | .needs_pci_atomics = false, |
| 194 | .num_sdma_engines = 2, | 187 | .num_sdma_engines = 2, |
| 188 | .num_sdma_queues_per_engine = 2, | ||
| 195 | }; | 189 | }; |
| 196 | 190 | ||
| 197 | static const struct kfd_device_info polaris11_device_info = { | 191 | static const struct kfd_device_info polaris11_device_info = { |
| @@ -207,6 +201,7 @@ static const struct kfd_device_info polaris11_device_info = { | |||
| 207 | .needs_iommu_device = false, | 201 | .needs_iommu_device = false, |
| 208 | .needs_pci_atomics = true, | 202 | .needs_pci_atomics = true, |
| 209 | .num_sdma_engines = 2, | 203 | .num_sdma_engines = 2, |
| 204 | .num_sdma_queues_per_engine = 2, | ||
| 210 | }; | 205 | }; |
| 211 | 206 | ||
| 212 | static const struct kfd_device_info vega10_device_info = { | 207 | static const struct kfd_device_info vega10_device_info = { |
| @@ -222,6 +217,7 @@ static const struct kfd_device_info vega10_device_info = { | |||
| 222 | .needs_iommu_device = false, | 217 | .needs_iommu_device = false, |
| 223 | .needs_pci_atomics = false, | 218 | .needs_pci_atomics = false, |
| 224 | .num_sdma_engines = 2, | 219 | .num_sdma_engines = 2, |
| 220 | .num_sdma_queues_per_engine = 2, | ||
| 225 | }; | 221 | }; |
| 226 | 222 | ||
| 227 | static const struct kfd_device_info vega10_vf_device_info = { | 223 | static const struct kfd_device_info vega10_vf_device_info = { |
| @@ -237,8 +233,24 @@ static const struct kfd_device_info vega10_vf_device_info = { | |||
| 237 | .needs_iommu_device = false, | 233 | .needs_iommu_device = false, |
| 238 | .needs_pci_atomics = false, | 234 | .needs_pci_atomics = false, |
| 239 | .num_sdma_engines = 2, | 235 | .num_sdma_engines = 2, |
| 236 | .num_sdma_queues_per_engine = 2, | ||
| 240 | }; | 237 | }; |
| 241 | 238 | ||
| 239 | static const struct kfd_device_info vega20_device_info = { | ||
| 240 | .asic_family = CHIP_VEGA20, | ||
| 241 | .max_pasid_bits = 16, | ||
| 242 | .max_no_of_hqd = 24, | ||
| 243 | .doorbell_size = 8, | ||
| 244 | .ih_ring_entry_size = 8 * sizeof(uint32_t), | ||
| 245 | .event_interrupt_class = &event_interrupt_class_v9, | ||
| 246 | .num_of_watch_points = 4, | ||
| 247 | .mqd_size_aligned = MQD_SIZE_ALIGNED, | ||
| 248 | .supports_cwsr = true, | ||
| 249 | .needs_iommu_device = false, | ||
| 250 | .needs_pci_atomics = false, | ||
| 251 | .num_sdma_engines = 2, | ||
| 252 | .num_sdma_queues_per_engine = 8, | ||
| 253 | }; | ||
| 242 | 254 | ||
| 243 | struct kfd_deviceid { | 255 | struct kfd_deviceid { |
| 244 | unsigned short did; | 256 | unsigned short did; |
| @@ -293,7 +305,6 @@ static const struct kfd_deviceid supported_devices[] = { | |||
| 293 | { 0x6928, &tonga_device_info }, /* Tonga */ | 305 | { 0x6928, &tonga_device_info }, /* Tonga */ |
| 294 | { 0x6929, &tonga_device_info }, /* Tonga */ | 306 | { 0x6929, &tonga_device_info }, /* Tonga */ |
| 295 | { 0x692B, &tonga_device_info }, /* Tonga */ | 307 | { 0x692B, &tonga_device_info }, /* Tonga */ |
| 296 | { 0x692F, &tonga_vf_device_info }, /* Tonga vf */ | ||
| 297 | { 0x6938, &tonga_device_info }, /* Tonga */ | 308 | { 0x6938, &tonga_device_info }, /* Tonga */ |
| 298 | { 0x6939, &tonga_device_info }, /* Tonga */ | 309 | { 0x6939, &tonga_device_info }, /* Tonga */ |
| 299 | { 0x7300, &fiji_device_info }, /* Fiji */ | 310 | { 0x7300, &fiji_device_info }, /* Fiji */ |
| @@ -328,6 +339,12 @@ static const struct kfd_deviceid supported_devices[] = { | |||
| 328 | { 0x6868, &vega10_device_info }, /* Vega10 */ | 339 | { 0x6868, &vega10_device_info }, /* Vega10 */ |
| 329 | { 0x686C, &vega10_vf_device_info }, /* Vega10 vf*/ | 340 | { 0x686C, &vega10_vf_device_info }, /* Vega10 vf*/ |
| 330 | { 0x687F, &vega10_device_info }, /* Vega10 */ | 341 | { 0x687F, &vega10_device_info }, /* Vega10 */ |
| 342 | { 0x66a0, &vega20_device_info }, /* Vega20 */ | ||
| 343 | { 0x66a1, &vega20_device_info }, /* Vega20 */ | ||
| 344 | { 0x66a2, &vega20_device_info }, /* Vega20 */ | ||
| 345 | { 0x66a3, &vega20_device_info }, /* Vega20 */ | ||
| 346 | { 0x66a7, &vega20_device_info }, /* Vega20 */ | ||
| 347 | { 0x66af, &vega20_device_info } /* Vega20 */ | ||
| 331 | }; | 348 | }; |
| 332 | 349 | ||
| 333 | static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size, | 350 | static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size, |
| @@ -366,6 +383,10 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, | |||
| 366 | return NULL; | 383 | return NULL; |
| 367 | } | 384 | } |
| 368 | 385 | ||
| 386 | kfd = kzalloc(sizeof(*kfd), GFP_KERNEL); | ||
| 387 | if (!kfd) | ||
| 388 | return NULL; | ||
| 389 | |||
| 369 | /* Allow BIF to recode atomics to PCIe 3.0 AtomicOps. | 390 | /* Allow BIF to recode atomics to PCIe 3.0 AtomicOps. |
| 370 | * 32 and 64-bit requests are possible and must be | 391 | * 32 and 64-bit requests are possible and must be |
| 371 | * supported. | 392 | * supported. |
| @@ -377,12 +398,10 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, | |||
| 377 | dev_info(kfd_device, | 398 | dev_info(kfd_device, |
| 378 | "skipped device %x:%x, PCI rejects atomics\n", | 399 | "skipped device %x:%x, PCI rejects atomics\n", |
| 379 | pdev->vendor, pdev->device); | 400 | pdev->vendor, pdev->device); |
| 401 | kfree(kfd); | ||
| 380 | return NULL; | 402 | return NULL; |
| 381 | } | 403 | } else if (!ret) |
| 382 | 404 | kfd->pci_atomic_requested = true; | |
| 383 | kfd = kzalloc(sizeof(*kfd), GFP_KERNEL); | ||
| 384 | if (!kfd) | ||
| 385 | return NULL; | ||
| 386 | 405 | ||
| 387 | kfd->kgd = kgd; | 406 | kfd->kgd = kgd; |
| 388 | kfd->device_info = device_info; | 407 | kfd->device_info = device_info; |
| @@ -419,6 +438,10 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, | |||
| 419 | { | 438 | { |
| 420 | unsigned int size; | 439 | unsigned int size; |
| 421 | 440 | ||
| 441 | kfd->mec_fw_version = kfd->kfd2kgd->get_fw_version(kfd->kgd, | ||
| 442 | KGD_ENGINE_MEC1); | ||
| 443 | kfd->sdma_fw_version = kfd->kfd2kgd->get_fw_version(kfd->kgd, | ||
| 444 | KGD_ENGINE_SDMA1); | ||
| 422 | kfd->shared_resources = *gpu_resources; | 445 | kfd->shared_resources = *gpu_resources; |
| 423 | 446 | ||
| 424 | kfd->vm_info.first_vmid_kfd = ffs(gpu_resources->compute_vmid_bitmap)-1; | 447 | kfd->vm_info.first_vmid_kfd = ffs(gpu_resources->compute_vmid_bitmap)-1; |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index ec0d62a16e53..d6af31ccf0ee 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | |||
| @@ -109,7 +109,7 @@ static unsigned int get_num_sdma_engines(struct device_queue_manager *dqm) | |||
| 109 | unsigned int get_num_sdma_queues(struct device_queue_manager *dqm) | 109 | unsigned int get_num_sdma_queues(struct device_queue_manager *dqm) |
| 110 | { | 110 | { |
| 111 | return dqm->dev->device_info->num_sdma_engines | 111 | return dqm->dev->device_info->num_sdma_engines |
| 112 | * KFD_SDMA_QUEUES_PER_ENGINE; | 112 | * dqm->dev->device_info->num_sdma_queues_per_engine; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | void program_sh_mem_settings(struct device_queue_manager *dqm, | 115 | void program_sh_mem_settings(struct device_queue_manager *dqm, |
| @@ -656,7 +656,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, | |||
| 656 | struct queue *q; | 656 | struct queue *q; |
| 657 | struct mqd_manager *mqd_mgr; | 657 | struct mqd_manager *mqd_mgr; |
| 658 | struct kfd_process_device *pdd; | 658 | struct kfd_process_device *pdd; |
| 659 | uint32_t pd_base; | 659 | uint64_t pd_base; |
| 660 | int retval = 0; | 660 | int retval = 0; |
| 661 | 661 | ||
| 662 | pdd = qpd_to_pdd(qpd); | 662 | pdd = qpd_to_pdd(qpd); |
| @@ -676,7 +676,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, | |||
| 676 | 676 | ||
| 677 | /* Update PD Base in QPD */ | 677 | /* Update PD Base in QPD */ |
| 678 | qpd->page_table_base = pd_base; | 678 | qpd->page_table_base = pd_base; |
| 679 | pr_debug("Updated PD address to 0x%08x\n", pd_base); | 679 | pr_debug("Updated PD address to 0x%llx\n", pd_base); |
| 680 | 680 | ||
| 681 | if (!list_empty(&qpd->queues_list)) { | 681 | if (!list_empty(&qpd->queues_list)) { |
| 682 | dqm->dev->kfd2kgd->set_vm_context_page_table_base( | 682 | dqm->dev->kfd2kgd->set_vm_context_page_table_base( |
| @@ -717,7 +717,7 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm, | |||
| 717 | { | 717 | { |
| 718 | struct queue *q; | 718 | struct queue *q; |
| 719 | struct kfd_process_device *pdd; | 719 | struct kfd_process_device *pdd; |
| 720 | uint32_t pd_base; | 720 | uint64_t pd_base; |
| 721 | int retval = 0; | 721 | int retval = 0; |
| 722 | 722 | ||
| 723 | pdd = qpd_to_pdd(qpd); | 723 | pdd = qpd_to_pdd(qpd); |
| @@ -737,7 +737,7 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm, | |||
| 737 | 737 | ||
| 738 | /* Update PD Base in QPD */ | 738 | /* Update PD Base in QPD */ |
| 739 | qpd->page_table_base = pd_base; | 739 | qpd->page_table_base = pd_base; |
| 740 | pr_debug("Updated PD address to 0x%08x\n", pd_base); | 740 | pr_debug("Updated PD address to 0x%llx\n", pd_base); |
| 741 | 741 | ||
| 742 | /* activate all active queues on the qpd */ | 742 | /* activate all active queues on the qpd */ |
| 743 | list_for_each_entry(q, &qpd->queues_list, list) { | 743 | list_for_each_entry(q, &qpd->queues_list, list) { |
| @@ -761,7 +761,7 @@ static int register_process(struct device_queue_manager *dqm, | |||
| 761 | { | 761 | { |
| 762 | struct device_process_node *n; | 762 | struct device_process_node *n; |
| 763 | struct kfd_process_device *pdd; | 763 | struct kfd_process_device *pdd; |
| 764 | uint32_t pd_base; | 764 | uint64_t pd_base; |
| 765 | int retval; | 765 | int retval; |
| 766 | 766 | ||
| 767 | n = kzalloc(sizeof(*n), GFP_KERNEL); | 767 | n = kzalloc(sizeof(*n), GFP_KERNEL); |
| @@ -779,6 +779,7 @@ static int register_process(struct device_queue_manager *dqm, | |||
| 779 | 779 | ||
| 780 | /* Update PD Base in QPD */ | 780 | /* Update PD Base in QPD */ |
| 781 | qpd->page_table_base = pd_base; | 781 | qpd->page_table_base = pd_base; |
| 782 | pr_debug("Updated PD address to 0x%llx\n", pd_base); | ||
| 782 | 783 | ||
| 783 | retval = dqm->asic_ops.update_qpd(dqm, qpd); | 784 | retval = dqm->asic_ops.update_qpd(dqm, qpd); |
| 784 | 785 | ||
| @@ -1528,6 +1529,41 @@ static int process_termination_nocpsch(struct device_queue_manager *dqm, | |||
| 1528 | return retval; | 1529 | return retval; |
| 1529 | } | 1530 | } |
| 1530 | 1531 | ||
| 1532 | static int get_wave_state(struct device_queue_manager *dqm, | ||
| 1533 | struct queue *q, | ||
| 1534 | void __user *ctl_stack, | ||
| 1535 | u32 *ctl_stack_used_size, | ||
| 1536 | u32 *save_area_used_size) | ||
| 1537 | { | ||
| 1538 | struct mqd_manager *mqd; | ||
| 1539 | int r; | ||
| 1540 | |||
| 1541 | dqm_lock(dqm); | ||
| 1542 | |||
| 1543 | if (q->properties.type != KFD_QUEUE_TYPE_COMPUTE || | ||
| 1544 | q->properties.is_active || !q->device->cwsr_enabled) { | ||
| 1545 | r = -EINVAL; | ||
| 1546 | goto dqm_unlock; | ||
| 1547 | } | ||
| 1548 | |||
| 1549 | mqd = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE); | ||
| 1550 | if (!mqd) { | ||
| 1551 | r = -ENOMEM; | ||
| 1552 | goto dqm_unlock; | ||
| 1553 | } | ||
| 1554 | |||
| 1555 | if (!mqd->get_wave_state) { | ||
| 1556 | r = -EINVAL; | ||
| 1557 | goto dqm_unlock; | ||
| 1558 | } | ||
| 1559 | |||
| 1560 | r = mqd->get_wave_state(mqd, q->mqd, ctl_stack, ctl_stack_used_size, | ||
| 1561 | save_area_used_size); | ||
| 1562 | |||
| 1563 | dqm_unlock: | ||
| 1564 | dqm_unlock(dqm); | ||
| 1565 | return r; | ||
| 1566 | } | ||
| 1531 | 1567 | ||
| 1532 | static int process_termination_cpsch(struct device_queue_manager *dqm, | 1568 | static int process_termination_cpsch(struct device_queue_manager *dqm, |
| 1533 | struct qcm_process_device *qpd) | 1569 | struct qcm_process_device *qpd) |
| @@ -1649,6 +1685,7 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) | |||
| 1649 | dqm->ops.process_termination = process_termination_cpsch; | 1685 | dqm->ops.process_termination = process_termination_cpsch; |
| 1650 | dqm->ops.evict_process_queues = evict_process_queues_cpsch; | 1686 | dqm->ops.evict_process_queues = evict_process_queues_cpsch; |
| 1651 | dqm->ops.restore_process_queues = restore_process_queues_cpsch; | 1687 | dqm->ops.restore_process_queues = restore_process_queues_cpsch; |
| 1688 | dqm->ops.get_wave_state = get_wave_state; | ||
| 1652 | break; | 1689 | break; |
| 1653 | case KFD_SCHED_POLICY_NO_HWS: | 1690 | case KFD_SCHED_POLICY_NO_HWS: |
| 1654 | /* initialize dqm for no cp scheduling */ | 1691 | /* initialize dqm for no cp scheduling */ |
| @@ -1668,6 +1705,7 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) | |||
| 1668 | dqm->ops.evict_process_queues = evict_process_queues_nocpsch; | 1705 | dqm->ops.evict_process_queues = evict_process_queues_nocpsch; |
| 1669 | dqm->ops.restore_process_queues = | 1706 | dqm->ops.restore_process_queues = |
| 1670 | restore_process_queues_nocpsch; | 1707 | restore_process_queues_nocpsch; |
| 1708 | dqm->ops.get_wave_state = get_wave_state; | ||
| 1671 | break; | 1709 | break; |
| 1672 | default: | 1710 | default: |
| 1673 | pr_err("Invalid scheduling policy %d\n", dqm->sched_policy); | 1711 | pr_err("Invalid scheduling policy %d\n", dqm->sched_policy); |
| @@ -1695,6 +1733,7 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) | |||
| 1695 | break; | 1733 | break; |
| 1696 | 1734 | ||
| 1697 | case CHIP_VEGA10: | 1735 | case CHIP_VEGA10: |
| 1736 | case CHIP_VEGA20: | ||
| 1698 | case CHIP_RAVEN: | 1737 | case CHIP_RAVEN: |
| 1699 | device_queue_manager_init_v9(&dqm->asic_ops); | 1738 | device_queue_manager_init_v9(&dqm->asic_ops); |
| 1700 | break; | 1739 | break; |
| @@ -1806,7 +1845,9 @@ int dqm_debugfs_hqds(struct seq_file *m, void *data) | |||
| 1806 | } | 1845 | } |
| 1807 | 1846 | ||
| 1808 | for (pipe = 0; pipe < get_num_sdma_engines(dqm); pipe++) { | 1847 | for (pipe = 0; pipe < get_num_sdma_engines(dqm); pipe++) { |
| 1809 | for (queue = 0; queue < KFD_SDMA_QUEUES_PER_ENGINE; queue++) { | 1848 | for (queue = 0; |
| 1849 | queue < dqm->dev->device_info->num_sdma_queues_per_engine; | ||
| 1850 | queue++) { | ||
| 1810 | r = dqm->dev->kfd2kgd->hqd_sdma_dump( | 1851 | r = dqm->dev->kfd2kgd->hqd_sdma_dump( |
| 1811 | dqm->dev->kgd, pipe, queue, &dump, &n_regs); | 1852 | dqm->dev->kgd, pipe, queue, &dump, &n_regs); |
| 1812 | if (r) | 1853 | if (r) |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h index 00da3169a004..70e38a2e23b9 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | 33 | ||
| 34 | #define KFD_UNMAP_LATENCY_MS (4000) | 34 | #define KFD_UNMAP_LATENCY_MS (4000) |
| 35 | #define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS (2 * KFD_UNMAP_LATENCY_MS + 1000) | 35 | #define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS (2 * KFD_UNMAP_LATENCY_MS + 1000) |
| 36 | #define KFD_SDMA_QUEUES_PER_ENGINE (2) | ||
| 37 | 36 | ||
| 38 | struct device_process_node { | 37 | struct device_process_node { |
| 39 | struct qcm_process_device *qpd; | 38 | struct qcm_process_device *qpd; |
| @@ -82,6 +81,8 @@ struct device_process_node { | |||
| 82 | * | 81 | * |
| 83 | * @restore_process_queues: Restore all evicted queues queues of a process | 82 | * @restore_process_queues: Restore all evicted queues queues of a process |
| 84 | * | 83 | * |
| 84 | * @get_wave_state: Retrieves context save state and optionally copies the | ||
| 85 | * control stack, if kept in the MQD, to the given userspace address. | ||
| 85 | */ | 86 | */ |
| 86 | 87 | ||
| 87 | struct device_queue_manager_ops { | 88 | struct device_queue_manager_ops { |
| @@ -137,6 +138,12 @@ struct device_queue_manager_ops { | |||
| 137 | struct qcm_process_device *qpd); | 138 | struct qcm_process_device *qpd); |
| 138 | int (*restore_process_queues)(struct device_queue_manager *dqm, | 139 | int (*restore_process_queues)(struct device_queue_manager *dqm, |
| 139 | struct qcm_process_device *qpd); | 140 | struct qcm_process_device *qpd); |
| 141 | |||
| 142 | int (*get_wave_state)(struct device_queue_manager *dqm, | ||
| 143 | struct queue *q, | ||
| 144 | void __user *ctl_stack, | ||
| 145 | u32 *ctl_stack_used_size, | ||
| 146 | u32 *save_area_used_size); | ||
| 140 | }; | 147 | }; |
| 141 | 148 | ||
| 142 | struct device_queue_manager_asic_ops { | 149 | struct device_queue_manager_asic_ops { |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c index 97d5423c5673..3d66cec414af 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | |||
| @@ -400,6 +400,7 @@ int kfd_init_apertures(struct kfd_process *process) | |||
| 400 | kfd_init_apertures_vi(pdd, id); | 400 | kfd_init_apertures_vi(pdd, id); |
| 401 | break; | 401 | break; |
| 402 | case CHIP_VEGA10: | 402 | case CHIP_VEGA10: |
| 403 | case CHIP_VEGA20: | ||
| 403 | case CHIP_RAVEN: | 404 | case CHIP_RAVEN: |
| 404 | kfd_init_apertures_v9(pdd, id); | 405 | kfd_init_apertures_v9(pdd, id); |
| 405 | break; | 406 | break; |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c index 9f84b4d9fb88..6c31f7370193 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | |||
| @@ -322,6 +322,7 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev, | |||
| 322 | break; | 322 | break; |
| 323 | 323 | ||
| 324 | case CHIP_VEGA10: | 324 | case CHIP_VEGA10: |
| 325 | case CHIP_VEGA20: | ||
| 325 | case CHIP_RAVEN: | 326 | case CHIP_RAVEN: |
| 326 | kernel_queue_init_v9(&kq->ops_asic_specific); | 327 | kernel_queue_init_v9(&kq->ops_asic_specific); |
| 327 | break; | 328 | break; |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue_v9.c index 684a3bf07efd..33830b1a5a54 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue_v9.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue_v9.c | |||
| @@ -71,8 +71,7 @@ static int pm_map_process_v9(struct packet_manager *pm, | |||
| 71 | uint32_t *buffer, struct qcm_process_device *qpd) | 71 | uint32_t *buffer, struct qcm_process_device *qpd) |
| 72 | { | 72 | { |
| 73 | struct pm4_mes_map_process *packet; | 73 | struct pm4_mes_map_process *packet; |
| 74 | uint64_t vm_page_table_base_addr = | 74 | uint64_t vm_page_table_base_addr = qpd->page_table_base; |
| 75 | (uint64_t)(qpd->page_table_base) << 12; | ||
| 76 | 75 | ||
| 77 | packet = (struct pm4_mes_map_process *)buffer; | 76 | packet = (struct pm4_mes_map_process *)buffer; |
| 78 | memset(buffer, 0, sizeof(struct pm4_mes_map_process)); | 77 | memset(buffer, 0, sizeof(struct pm4_mes_map_process)); |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c index 3bc25ab84f34..e33019a7a883 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | |||
| @@ -39,6 +39,7 @@ struct mqd_manager *mqd_manager_init(enum KFD_MQD_TYPE type, | |||
| 39 | case CHIP_POLARIS11: | 39 | case CHIP_POLARIS11: |
| 40 | return mqd_manager_init_vi_tonga(type, dev); | 40 | return mqd_manager_init_vi_tonga(type, dev); |
| 41 | case CHIP_VEGA10: | 41 | case CHIP_VEGA10: |
| 42 | case CHIP_VEGA20: | ||
| 42 | case CHIP_RAVEN: | 43 | case CHIP_RAVEN: |
| 43 | return mqd_manager_init_v9(type, dev); | 44 | return mqd_manager_init_v9(type, dev); |
| 44 | default: | 45 | default: |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h index 4e84052d4e21..f8261313ae7b 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | |||
| @@ -43,6 +43,9 @@ | |||
| 43 | * | 43 | * |
| 44 | * @is_occupied: Checks if the relevant HQD slot is occupied. | 44 | * @is_occupied: Checks if the relevant HQD slot is occupied. |
| 45 | * | 45 | * |
| 46 | * @get_wave_state: Retrieves context save state and optionally copies the | ||
| 47 | * control stack, if kept in the MQD, to the given userspace address. | ||
| 48 | * | ||
| 46 | * @mqd_mutex: Mqd manager mutex. | 49 | * @mqd_mutex: Mqd manager mutex. |
| 47 | * | 50 | * |
| 48 | * @dev: The kfd device structure coupled with this module. | 51 | * @dev: The kfd device structure coupled with this module. |
| @@ -85,6 +88,11 @@ struct mqd_manager { | |||
| 85 | uint64_t queue_address, uint32_t pipe_id, | 88 | uint64_t queue_address, uint32_t pipe_id, |
| 86 | uint32_t queue_id); | 89 | uint32_t queue_id); |
| 87 | 90 | ||
| 91 | int (*get_wave_state)(struct mqd_manager *mm, void *mqd, | ||
| 92 | void __user *ctl_stack, | ||
| 93 | u32 *ctl_stack_used_size, | ||
| 94 | u32 *save_area_used_size); | ||
| 95 | |||
| 88 | #if defined(CONFIG_DEBUG_FS) | 96 | #if defined(CONFIG_DEBUG_FS) |
| 89 | int (*debugfs_show_mqd)(struct seq_file *m, void *data); | 97 | int (*debugfs_show_mqd)(struct seq_file *m, void *data); |
| 90 | #endif | 98 | #endif |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c index 0cedb37cf513..f381c1cb27bd 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | |||
| @@ -266,6 +266,28 @@ static bool is_occupied(struct mqd_manager *mm, void *mqd, | |||
| 266 | pipe_id, queue_id); | 266 | pipe_id, queue_id); |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | static int get_wave_state(struct mqd_manager *mm, void *mqd, | ||
| 270 | void __user *ctl_stack, | ||
| 271 | u32 *ctl_stack_used_size, | ||
| 272 | u32 *save_area_used_size) | ||
| 273 | { | ||
| 274 | struct v9_mqd *m; | ||
| 275 | |||
| 276 | /* Control stack is located one page after MQD. */ | ||
| 277 | void *mqd_ctl_stack = (void *)((uintptr_t)mqd + PAGE_SIZE); | ||
| 278 | |||
| 279 | m = get_mqd(mqd); | ||
| 280 | |||
| 281 | *ctl_stack_used_size = m->cp_hqd_cntl_stack_size - | ||
| 282 | m->cp_hqd_cntl_stack_offset; | ||
| 283 | *save_area_used_size = m->cp_hqd_wg_state_offset; | ||
| 284 | |||
| 285 | if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size)) | ||
| 286 | return -EFAULT; | ||
| 287 | |||
| 288 | return 0; | ||
| 289 | } | ||
| 290 | |||
| 269 | static int init_mqd_hiq(struct mqd_manager *mm, void **mqd, | 291 | static int init_mqd_hiq(struct mqd_manager *mm, void **mqd, |
| 270 | struct kfd_mem_obj **mqd_mem_obj, uint64_t *gart_addr, | 292 | struct kfd_mem_obj **mqd_mem_obj, uint64_t *gart_addr, |
| 271 | struct queue_properties *q) | 293 | struct queue_properties *q) |
| @@ -435,6 +457,7 @@ struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type, | |||
| 435 | mqd->update_mqd = update_mqd; | 457 | mqd->update_mqd = update_mqd; |
| 436 | mqd->destroy_mqd = destroy_mqd; | 458 | mqd->destroy_mqd = destroy_mqd; |
| 437 | mqd->is_occupied = is_occupied; | 459 | mqd->is_occupied = is_occupied; |
| 460 | mqd->get_wave_state = get_wave_state; | ||
| 438 | #if defined(CONFIG_DEBUG_FS) | 461 | #if defined(CONFIG_DEBUG_FS) |
| 439 | mqd->debugfs_show_mqd = debugfs_show_mqd; | 462 | mqd->debugfs_show_mqd = debugfs_show_mqd; |
| 440 | #endif | 463 | #endif |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c index b81fda3754da..6469b3456f00 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | |||
| @@ -269,6 +269,28 @@ static bool is_occupied(struct mqd_manager *mm, void *mqd, | |||
| 269 | pipe_id, queue_id); | 269 | pipe_id, queue_id); |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | static int get_wave_state(struct mqd_manager *mm, void *mqd, | ||
| 273 | void __user *ctl_stack, | ||
| 274 | u32 *ctl_stack_used_size, | ||
| 275 | u32 *save_area_used_size) | ||
| 276 | { | ||
| 277 | struct vi_mqd *m; | ||
| 278 | |||
| 279 | m = get_mqd(mqd); | ||
| 280 | |||
| 281 | *ctl_stack_used_size = m->cp_hqd_cntl_stack_size - | ||
| 282 | m->cp_hqd_cntl_stack_offset; | ||
| 283 | *save_area_used_size = m->cp_hqd_wg_state_offset - | ||
| 284 | m->cp_hqd_cntl_stack_size; | ||
| 285 | |||
| 286 | /* Control stack is not copied to user mode for GFXv8 because | ||
| 287 | * it's part of the context save area that is already | ||
| 288 | * accessible to user mode | ||
| 289 | */ | ||
| 290 | |||
| 291 | return 0; | ||
| 292 | } | ||
| 293 | |||
| 272 | static int init_mqd_hiq(struct mqd_manager *mm, void **mqd, | 294 | static int init_mqd_hiq(struct mqd_manager *mm, void **mqd, |
| 273 | struct kfd_mem_obj **mqd_mem_obj, uint64_t *gart_addr, | 295 | struct kfd_mem_obj **mqd_mem_obj, uint64_t *gart_addr, |
| 274 | struct queue_properties *q) | 296 | struct queue_properties *q) |
| @@ -436,6 +458,7 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type, | |||
| 436 | mqd->update_mqd = update_mqd; | 458 | mqd->update_mqd = update_mqd; |
| 437 | mqd->destroy_mqd = destroy_mqd; | 459 | mqd->destroy_mqd = destroy_mqd; |
| 438 | mqd->is_occupied = is_occupied; | 460 | mqd->is_occupied = is_occupied; |
| 461 | mqd->get_wave_state = get_wave_state; | ||
| 439 | #if defined(CONFIG_DEBUG_FS) | 462 | #if defined(CONFIG_DEBUG_FS) |
| 440 | mqd->debugfs_show_mqd = debugfs_show_mqd; | 463 | mqd->debugfs_show_mqd = debugfs_show_mqd; |
| 441 | #endif | 464 | #endif |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c index 1092631765cb..c6080ed3b6a7 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c | |||
| @@ -229,6 +229,7 @@ int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm) | |||
| 229 | pm->pmf = &kfd_vi_pm_funcs; | 229 | pm->pmf = &kfd_vi_pm_funcs; |
| 230 | break; | 230 | break; |
| 231 | case CHIP_VEGA10: | 231 | case CHIP_VEGA10: |
| 232 | case CHIP_VEGA20: | ||
| 232 | case CHIP_RAVEN: | 233 | case CHIP_RAVEN: |
| 233 | pm->pmf = &kfd_v9_pm_funcs; | 234 | pm->pmf = &kfd_v9_pm_funcs; |
| 234 | break; | 235 | break; |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index b0064b08aa11..53ff86d45d91 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h | |||
| @@ -176,6 +176,7 @@ struct kfd_device_info { | |||
| 176 | bool needs_iommu_device; | 176 | bool needs_iommu_device; |
| 177 | bool needs_pci_atomics; | 177 | bool needs_pci_atomics; |
| 178 | unsigned int num_sdma_engines; | 178 | unsigned int num_sdma_engines; |
| 179 | unsigned int num_sdma_queues_per_engine; | ||
| 179 | }; | 180 | }; |
| 180 | 181 | ||
| 181 | struct kfd_mem_obj { | 182 | struct kfd_mem_obj { |
| @@ -247,6 +248,10 @@ struct kfd_dev { | |||
| 247 | /* Debug manager */ | 248 | /* Debug manager */ |
| 248 | struct kfd_dbgmgr *dbgmgr; | 249 | struct kfd_dbgmgr *dbgmgr; |
| 249 | 250 | ||
| 251 | /* Firmware versions */ | ||
| 252 | uint16_t mec_fw_version; | ||
| 253 | uint16_t sdma_fw_version; | ||
| 254 | |||
| 250 | /* Maximum process number mapped to HW scheduler */ | 255 | /* Maximum process number mapped to HW scheduler */ |
| 251 | unsigned int max_proc_per_quantum; | 256 | unsigned int max_proc_per_quantum; |
| 252 | 257 | ||
| @@ -257,6 +262,8 @@ struct kfd_dev { | |||
| 257 | 262 | ||
| 258 | /* xGMI */ | 263 | /* xGMI */ |
| 259 | uint64_t hive_id; | 264 | uint64_t hive_id; |
| 265 | |||
| 266 | bool pci_atomic_requested; | ||
| 260 | }; | 267 | }; |
| 261 | 268 | ||
| 262 | /* KGD2KFD callbacks */ | 269 | /* KGD2KFD callbacks */ |
| @@ -500,11 +507,11 @@ struct qcm_process_device { | |||
| 500 | * All the memory management data should be here too | 507 | * All the memory management data should be here too |
| 501 | */ | 508 | */ |
| 502 | uint64_t gds_context_area; | 509 | uint64_t gds_context_area; |
| 510 | uint64_t page_table_base; | ||
| 503 | uint32_t sh_mem_config; | 511 | uint32_t sh_mem_config; |
| 504 | uint32_t sh_mem_bases; | 512 | uint32_t sh_mem_bases; |
| 505 | uint32_t sh_mem_ape1_base; | 513 | uint32_t sh_mem_ape1_base; |
| 506 | uint32_t sh_mem_ape1_limit; | 514 | uint32_t sh_mem_ape1_limit; |
| 507 | uint32_t page_table_base; | ||
| 508 | uint32_t gds_size; | 515 | uint32_t gds_size; |
| 509 | uint32_t num_gws; | 516 | uint32_t num_gws; |
| 510 | uint32_t num_oac; | 517 | uint32_t num_oac; |
| @@ -856,6 +863,11 @@ int pqm_set_cu_mask(struct process_queue_manager *pqm, unsigned int qid, | |||
| 856 | struct queue_properties *p); | 863 | struct queue_properties *p); |
| 857 | struct kernel_queue *pqm_get_kernel_queue(struct process_queue_manager *pqm, | 864 | struct kernel_queue *pqm_get_kernel_queue(struct process_queue_manager *pqm, |
| 858 | unsigned int qid); | 865 | unsigned int qid); |
| 866 | int pqm_get_wave_state(struct process_queue_manager *pqm, | ||
| 867 | unsigned int qid, | ||
| 868 | void __user *ctl_stack, | ||
| 869 | u32 *ctl_stack_used_size, | ||
| 870 | u32 *save_area_used_size); | ||
| 859 | 871 | ||
| 860 | int amdkfd_fence_wait_timeout(unsigned int *fence_addr, | 872 | int amdkfd_fence_wait_timeout(unsigned int *fence_addr, |
| 861 | unsigned int fence_value, | 873 | unsigned int fence_value, |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c index c8cad9c078ae..fcaaf93681ac 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | |||
| @@ -408,6 +408,28 @@ struct kernel_queue *pqm_get_kernel_queue( | |||
| 408 | return NULL; | 408 | return NULL; |
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | int pqm_get_wave_state(struct process_queue_manager *pqm, | ||
| 412 | unsigned int qid, | ||
| 413 | void __user *ctl_stack, | ||
| 414 | u32 *ctl_stack_used_size, | ||
| 415 | u32 *save_area_used_size) | ||
| 416 | { | ||
| 417 | struct process_queue_node *pqn; | ||
| 418 | |||
| 419 | pqn = get_queue_by_qid(pqm, qid); | ||
| 420 | if (!pqn) { | ||
| 421 | pr_debug("amdkfd: No queue %d exists for operation\n", | ||
| 422 | qid); | ||
| 423 | return -EFAULT; | ||
| 424 | } | ||
| 425 | |||
| 426 | return pqn->q->device->dqm->ops.get_wave_state(pqn->q->device->dqm, | ||
| 427 | pqn->q, | ||
| 428 | ctl_stack, | ||
| 429 | ctl_stack_used_size, | ||
| 430 | save_area_used_size); | ||
| 431 | } | ||
| 432 | |||
| 411 | #if defined(CONFIG_DEBUG_FS) | 433 | #if defined(CONFIG_DEBUG_FS) |
| 412 | 434 | ||
| 413 | int pqm_debugfs_mqds(struct seq_file *m, void *data) | 435 | int pqm_debugfs_mqds(struct seq_file *m, void *data) |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c index 0dff66be8d7a..e3843c5929ed 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c | |||
| @@ -482,11 +482,11 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr, | |||
| 482 | (unsigned long long int) 0); | 482 | (unsigned long long int) 0); |
| 483 | 483 | ||
| 484 | sysfs_show_32bit_prop(buffer, "fw_version", | 484 | sysfs_show_32bit_prop(buffer, "fw_version", |
| 485 | dev->gpu->kfd2kgd->get_fw_version( | 485 | dev->gpu->mec_fw_version); |
| 486 | dev->gpu->kgd, | ||
| 487 | KGD_ENGINE_MEC1)); | ||
| 488 | sysfs_show_32bit_prop(buffer, "capability", | 486 | sysfs_show_32bit_prop(buffer, "capability", |
| 489 | dev->node_props.capability); | 487 | dev->node_props.capability); |
| 488 | sysfs_show_32bit_prop(buffer, "sdma_fw_version", | ||
| 489 | dev->gpu->sdma_fw_version); | ||
| 490 | } | 490 | } |
| 491 | 491 | ||
| 492 | return sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute", | 492 | return sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute", |
| @@ -1127,17 +1127,40 @@ static void kfd_fill_mem_clk_max_info(struct kfd_topology_device *dev) | |||
| 1127 | 1127 | ||
| 1128 | static void kfd_fill_iolink_non_crat_info(struct kfd_topology_device *dev) | 1128 | static void kfd_fill_iolink_non_crat_info(struct kfd_topology_device *dev) |
| 1129 | { | 1129 | { |
| 1130 | struct kfd_iolink_properties *link; | 1130 | struct kfd_iolink_properties *link, *cpu_link; |
| 1131 | struct kfd_topology_device *cpu_dev; | ||
| 1132 | uint32_t cap; | ||
| 1133 | uint32_t cpu_flag = CRAT_IOLINK_FLAGS_ENABLED; | ||
| 1134 | uint32_t flag = CRAT_IOLINK_FLAGS_ENABLED; | ||
| 1131 | 1135 | ||
| 1132 | if (!dev || !dev->gpu) | 1136 | if (!dev || !dev->gpu) |
| 1133 | return; | 1137 | return; |
| 1134 | 1138 | ||
| 1135 | /* GPU only creates direck links so apply flags setting to all */ | 1139 | pcie_capability_read_dword(dev->gpu->pdev, |
| 1136 | if (dev->gpu->device_info->asic_family == CHIP_HAWAII) | 1140 | PCI_EXP_DEVCAP2, &cap); |
| 1137 | list_for_each_entry(link, &dev->io_link_props, list) | 1141 | |
| 1138 | link->flags = CRAT_IOLINK_FLAGS_ENABLED | | 1142 | if (!(cap & (PCI_EXP_DEVCAP2_ATOMIC_COMP32 | |
| 1139 | CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT | | 1143 | PCI_EXP_DEVCAP2_ATOMIC_COMP64))) |
| 1140 | CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT; | 1144 | cpu_flag |= CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT | |
| 1145 | CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT; | ||
| 1146 | |||
| 1147 | if (!dev->gpu->pci_atomic_requested || | ||
| 1148 | dev->gpu->device_info->asic_family == CHIP_HAWAII) | ||
| 1149 | flag |= CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT | | ||
| 1150 | CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT; | ||
| 1151 | |||
| 1152 | /* GPU only creates direct links so apply flags setting to all */ | ||
| 1153 | list_for_each_entry(link, &dev->io_link_props, list) { | ||
| 1154 | link->flags = flag; | ||
| 1155 | cpu_dev = kfd_topology_device_by_proximity_domain( | ||
| 1156 | link->node_to); | ||
| 1157 | if (cpu_dev) { | ||
| 1158 | list_for_each_entry(cpu_link, | ||
| 1159 | &cpu_dev->io_link_props, list) | ||
| 1160 | if (cpu_link->node_to == link->node_from) | ||
| 1161 | cpu_link->flags = cpu_flag; | ||
| 1162 | } | ||
| 1163 | } | ||
| 1141 | } | 1164 | } |
| 1142 | 1165 | ||
| 1143 | int kfd_topology_add_device(struct kfd_dev *gpu) | 1166 | int kfd_topology_add_device(struct kfd_dev *gpu) |
| @@ -1255,6 +1278,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu) | |||
| 1255 | HSA_CAP_DOORBELL_TYPE_TOTALBITS_MASK); | 1278 | HSA_CAP_DOORBELL_TYPE_TOTALBITS_MASK); |
| 1256 | break; | 1279 | break; |
| 1257 | case CHIP_VEGA10: | 1280 | case CHIP_VEGA10: |
| 1281 | case CHIP_VEGA20: | ||
| 1258 | case CHIP_RAVEN: | 1282 | case CHIP_RAVEN: |
| 1259 | dev->node_props.capability |= ((HSA_CAP_DOORBELL_TYPE_2_0 << | 1283 | dev->node_props.capability |= ((HSA_CAP_DOORBELL_TYPE_2_0 << |
| 1260 | HSA_CAP_DOORBELL_TYPE_TOTALBITS_SHIFT) & | 1284 | HSA_CAP_DOORBELL_TYPE_TOTALBITS_SHIFT) & |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 6c849e055038..715422bb30db 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |||
| @@ -338,14 +338,6 @@ static int dm_set_powergating_state(void *handle, | |||
| 338 | /* Prototypes of private functions */ | 338 | /* Prototypes of private functions */ |
| 339 | static int dm_early_init(void* handle); | 339 | static int dm_early_init(void* handle); |
| 340 | 340 | ||
| 341 | static void hotplug_notify_work_func(struct work_struct *work) | ||
| 342 | { | ||
| 343 | struct amdgpu_display_manager *dm = container_of(work, struct amdgpu_display_manager, mst_hotplug_work); | ||
| 344 | struct drm_device *dev = dm->ddev; | ||
| 345 | |||
| 346 | drm_kms_helper_hotplug_event(dev); | ||
| 347 | } | ||
| 348 | |||
| 349 | /* Allocate memory for FBC compressed data */ | 341 | /* Allocate memory for FBC compressed data */ |
| 350 | static void amdgpu_dm_fbc_init(struct drm_connector *connector) | 342 | static void amdgpu_dm_fbc_init(struct drm_connector *connector) |
| 351 | { | 343 | { |
| @@ -447,8 +439,6 @@ static int amdgpu_dm_init(struct amdgpu_device *adev) | |||
| 447 | goto error; | 439 | goto error; |
| 448 | } | 440 | } |
| 449 | 441 | ||
| 450 | INIT_WORK(&adev->dm.mst_hotplug_work, hotplug_notify_work_func); | ||
| 451 | |||
| 452 | adev->dm.freesync_module = mod_freesync_create(adev->dm.dc); | 442 | adev->dm.freesync_module = mod_freesync_create(adev->dm.dc); |
| 453 | if (!adev->dm.freesync_module) { | 443 | if (!adev->dm.freesync_module) { |
| 454 | DRM_ERROR( | 444 | DRM_ERROR( |
| @@ -1214,7 +1204,7 @@ static int dce110_register_irq_handlers(struct amdgpu_device *adev) | |||
| 1214 | struct dc_interrupt_params int_params = {0}; | 1204 | struct dc_interrupt_params int_params = {0}; |
| 1215 | int r; | 1205 | int r; |
| 1216 | int i; | 1206 | int i; |
| 1217 | unsigned client_id = AMDGPU_IH_CLIENTID_LEGACY; | 1207 | unsigned client_id = AMDGPU_IRQ_CLIENTID_LEGACY; |
| 1218 | 1208 | ||
| 1219 | if (adev->asic_type == CHIP_VEGA10 || | 1209 | if (adev->asic_type == CHIP_VEGA10 || |
| 1220 | adev->asic_type == CHIP_VEGA12 || | 1210 | adev->asic_type == CHIP_VEGA12 || |
| @@ -4079,6 +4069,7 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc, | |||
| 4079 | /* TODO eliminate or rename surface_update */ | 4069 | /* TODO eliminate or rename surface_update */ |
| 4080 | struct dc_surface_update surface_updates[1] = { {0} }; | 4070 | struct dc_surface_update surface_updates[1] = { {0} }; |
| 4081 | struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state); | 4071 | struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state); |
| 4072 | struct dc_stream_status *stream_status; | ||
| 4082 | 4073 | ||
| 4083 | 4074 | ||
| 4084 | /* Prepare wait for target vblank early - before the fence-waits */ | 4075 | /* Prepare wait for target vblank early - before the fence-waits */ |
| @@ -4134,7 +4125,19 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc, | |||
| 4134 | 4125 | ||
| 4135 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | 4126 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); |
| 4136 | 4127 | ||
| 4137 | surface_updates->surface = dc_stream_get_status(acrtc_state->stream)->plane_states[0]; | 4128 | stream_status = dc_stream_get_status(acrtc_state->stream); |
| 4129 | if (!stream_status) { | ||
| 4130 | DRM_ERROR("No stream status for CRTC: id=%d\n", | ||
| 4131 | acrtc->crtc_id); | ||
| 4132 | return; | ||
| 4133 | } | ||
| 4134 | |||
| 4135 | surface_updates->surface = stream_status->plane_states[0]; | ||
| 4136 | if (!surface_updates->surface) { | ||
| 4137 | DRM_ERROR("No surface for CRTC: id=%d\n", | ||
| 4138 | acrtc->crtc_id); | ||
| 4139 | return; | ||
| 4140 | } | ||
| 4138 | surface_updates->flip_addr = &addr; | 4141 | surface_updates->flip_addr = &addr; |
| 4139 | 4142 | ||
| 4140 | dc_commit_updates_for_stream(adev->dm.dc, | 4143 | dc_commit_updates_for_stream(adev->dm.dc, |
| @@ -4797,6 +4800,8 @@ void set_freesync_on_stream(struct amdgpu_display_manager *dm, | |||
| 4797 | mod_freesync_build_vrr_infopacket(dm->freesync_module, | 4800 | mod_freesync_build_vrr_infopacket(dm->freesync_module, |
| 4798 | new_stream, | 4801 | new_stream, |
| 4799 | &vrr, | 4802 | &vrr, |
| 4803 | packet_type_fs1, | ||
| 4804 | NULL, | ||
| 4800 | &vrr_infopacket); | 4805 | &vrr_infopacket); |
| 4801 | 4806 | ||
| 4802 | new_crtc_state->adjust = vrr.adjust; | 4807 | new_crtc_state->adjust = vrr.adjust; |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index d4f1bdf93207..978b34a5011c 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | |||
| @@ -108,8 +108,6 @@ struct amdgpu_display_manager { | |||
| 108 | 108 | ||
| 109 | const struct dc_link *backlight_link; | 109 | const struct dc_link *backlight_link; |
| 110 | 110 | ||
| 111 | struct work_struct mst_hotplug_work; | ||
| 112 | |||
| 113 | struct mod_freesync *freesync_module; | 111 | struct mod_freesync *freesync_module; |
| 114 | 112 | ||
| 115 | /** | 113 | /** |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c index 6d16b4a0353d..0fab64a2a915 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | |||
| @@ -105,6 +105,8 @@ bool dm_pp_apply_display_requirements( | |||
| 105 | adev->powerplay.pp_funcs->display_configuration_change( | 105 | adev->powerplay.pp_funcs->display_configuration_change( |
| 106 | adev->powerplay.pp_handle, | 106 | adev->powerplay.pp_handle, |
| 107 | &adev->pm.pm_display_cfg); | 107 | &adev->pm.pm_display_cfg); |
| 108 | |||
| 109 | amdgpu_pm_compute_clocks(adev); | ||
| 108 | } | 110 | } |
| 109 | 111 | ||
| 110 | return true; | 112 | return true; |
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c index 5e2ea12fbb73..d0fc54f8fb1c 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c | |||
| @@ -1625,11 +1625,11 @@ void dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performan | |||
| 1625 | else { | 1625 | else { |
| 1626 | v->dsty_after_scaler = 0.0; | 1626 | v->dsty_after_scaler = 0.0; |
| 1627 | } | 1627 | } |
| 1628 | v->v_update_offset_pix =dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0); | 1628 | v->v_update_offset_pix[k] = dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0); |
| 1629 | v->total_repeater_delay_time = v->max_inter_dcn_tile_repeaters * (2.0 / v->dppclk + 3.0 / v->dispclk); | 1629 | v->total_repeater_delay_time = v->max_inter_dcn_tile_repeaters * (2.0 / v->dppclk + 3.0 / v->dispclk); |
| 1630 | v->v_update_width_pix = (14.0 / v->dcf_clk_deep_sleep + 12.0 / v->dppclk + v->total_repeater_delay_time) * v->pixel_clock[k]; | 1630 | v->v_update_width_pix[k] = (14.0 / v->dcf_clk_deep_sleep + 12.0 / v->dppclk + v->total_repeater_delay_time) * v->pixel_clock[k]; |
| 1631 | v->v_ready_offset_pix =dcn_bw_max2(150.0 / v->dppclk, v->total_repeater_delay_time + 20.0 / v->dcf_clk_deep_sleep + 10.0 / v->dppclk) * v->pixel_clock[k]; | 1631 | v->v_ready_offset_pix[k] = dcn_bw_max2(150.0 / v->dppclk, v->total_repeater_delay_time + 20.0 / v->dcf_clk_deep_sleep + 10.0 / v->dppclk) * v->pixel_clock[k]; |
| 1632 | v->t_setup = (v->v_update_offset_pix + v->v_update_width_pix + v->v_ready_offset_pix) / v->pixel_clock[k]; | 1632 | v->t_setup = (v->v_update_offset_pix[k] + v->v_update_width_pix[k] + v->v_ready_offset_pix[k]) / v->pixel_clock[k]; |
| 1633 | v->v_startup[k] =dcn_bw_min2(v->v_startup_lines, v->max_vstartup_lines[k]); | 1633 | v->v_startup[k] =dcn_bw_min2(v->v_startup_lines, v->max_vstartup_lines[k]); |
| 1634 | if (v->prefetch_mode == 0.0) { | 1634 | if (v->prefetch_mode == 0.0) { |
| 1635 | v->t_wait =dcn_bw_max3(v->dram_clock_change_latency + v->urgent_latency, v->sr_enter_plus_exit_time, v->urgent_latency); | 1635 | v->t_wait =dcn_bw_max3(v->dram_clock_change_latency + v->urgent_latency, v->sr_enter_plus_exit_time, v->urgent_latency); |
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c index 80ec09eef44f..3208188b7ed4 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c | |||
| @@ -1096,9 +1096,9 @@ bool dcn_validate_bandwidth( | |||
| 1096 | if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) | 1096 | if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) |
| 1097 | continue; | 1097 | continue; |
| 1098 | 1098 | ||
| 1099 | pipe->pipe_dlg_param.vupdate_width = v->v_update_width[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; | 1099 | pipe->pipe_dlg_param.vupdate_width = v->v_update_width_pix[input_idx]; |
| 1100 | pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; | 1100 | pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset_pix[input_idx]; |
| 1101 | pipe->pipe_dlg_param.vready_offset = v->v_ready_offset[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; | 1101 | pipe->pipe_dlg_param.vready_offset = v->v_ready_offset_pix[input_idx]; |
| 1102 | pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx]; | 1102 | pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx]; |
| 1103 | 1103 | ||
| 1104 | pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total; | 1104 | pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total; |
| @@ -1137,9 +1137,9 @@ bool dcn_validate_bandwidth( | |||
| 1137 | TIMING_3D_FORMAT_SIDE_BY_SIDE))) { | 1137 | TIMING_3D_FORMAT_SIDE_BY_SIDE))) { |
| 1138 | if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) { | 1138 | if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) { |
| 1139 | /* update previously split pipe */ | 1139 | /* update previously split pipe */ |
| 1140 | hsplit_pipe->pipe_dlg_param.vupdate_width = v->v_update_width[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; | 1140 | hsplit_pipe->pipe_dlg_param.vupdate_width = v->v_update_width_pix[input_idx]; |
| 1141 | hsplit_pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; | 1141 | hsplit_pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset_pix[input_idx]; |
| 1142 | hsplit_pipe->pipe_dlg_param.vready_offset = v->v_ready_offset[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; | 1142 | hsplit_pipe->pipe_dlg_param.vready_offset = v->v_ready_offset_pix[input_idx]; |
| 1143 | hsplit_pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx]; | 1143 | hsplit_pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx]; |
| 1144 | 1144 | ||
| 1145 | hsplit_pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total; | 1145 | hsplit_pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total; |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 1c438eedf77a..76fe5a9af3bf 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c | |||
| @@ -460,9 +460,25 @@ void dc_link_set_preferred_link_settings(struct dc *dc, | |||
| 460 | struct dc_link_settings *link_setting, | 460 | struct dc_link_settings *link_setting, |
| 461 | struct dc_link *link) | 461 | struct dc_link *link) |
| 462 | { | 462 | { |
| 463 | int i; | ||
| 464 | struct pipe_ctx *pipe; | ||
| 465 | struct dc_stream_state *link_stream; | ||
| 463 | struct dc_link_settings store_settings = *link_setting; | 466 | struct dc_link_settings store_settings = *link_setting; |
| 464 | struct dc_stream_state *link_stream = | 467 | |
| 465 | link->dc->current_state->res_ctx.pipe_ctx[0].stream; | 468 | for (i = 0; i < MAX_PIPES; i++) { |
| 469 | pipe = &dc->current_state->res_ctx.pipe_ctx[i]; | ||
| 470 | if (pipe->stream && pipe->stream->sink | ||
| 471 | && pipe->stream->sink->link) { | ||
| 472 | if (pipe->stream->sink->link == link) | ||
| 473 | break; | ||
| 474 | } | ||
| 475 | } | ||
| 476 | |||
| 477 | /* Stream not found */ | ||
| 478 | if (i == MAX_PIPES) | ||
| 479 | return; | ||
| 480 | |||
| 481 | link_stream = link->dc->current_state->res_ctx.pipe_ctx[i].stream; | ||
| 466 | 482 | ||
| 467 | link->preferred_link_setting = store_settings; | 483 | link->preferred_link_setting = store_settings; |
| 468 | if (link_stream) | 484 | if (link_stream) |
| @@ -1160,9 +1176,6 @@ static enum surface_update_type get_plane_info_update_type(const struct dc_surfa | |||
| 1160 | */ | 1176 | */ |
| 1161 | update_flags->bits.bpp_change = 1; | 1177 | update_flags->bits.bpp_change = 1; |
| 1162 | 1178 | ||
| 1163 | if (u->gamma && dce_use_lut(u->plane_info->format)) | ||
| 1164 | update_flags->bits.gamma_change = 1; | ||
| 1165 | |||
| 1166 | if (memcmp(&u->plane_info->tiling_info, &u->surface->tiling_info, | 1179 | if (memcmp(&u->plane_info->tiling_info, &u->surface->tiling_info, |
| 1167 | sizeof(union dc_tiling_info)) != 0) { | 1180 | sizeof(union dc_tiling_info)) != 0) { |
| 1168 | update_flags->bits.swizzle_change = 1; | 1181 | update_flags->bits.swizzle_change = 1; |
| @@ -1179,7 +1192,6 @@ static enum surface_update_type get_plane_info_update_type(const struct dc_surfa | |||
| 1179 | if (update_flags->bits.rotation_change | 1192 | if (update_flags->bits.rotation_change |
| 1180 | || update_flags->bits.stereo_format_change | 1193 | || update_flags->bits.stereo_format_change |
| 1181 | || update_flags->bits.pixel_format_change | 1194 | || update_flags->bits.pixel_format_change |
| 1182 | || update_flags->bits.gamma_change | ||
| 1183 | || update_flags->bits.bpp_change | 1195 | || update_flags->bits.bpp_change |
| 1184 | || update_flags->bits.bandwidth_change | 1196 | || update_flags->bits.bandwidth_change |
| 1185 | || update_flags->bits.output_tf_change) | 1197 | || update_flags->bits.output_tf_change) |
| @@ -1269,13 +1281,26 @@ static enum surface_update_type det_surface_update(const struct dc *dc, | |||
| 1269 | if (u->coeff_reduction_factor) | 1281 | if (u->coeff_reduction_factor) |
| 1270 | update_flags->bits.coeff_reduction_change = 1; | 1282 | update_flags->bits.coeff_reduction_change = 1; |
| 1271 | 1283 | ||
| 1284 | if (u->gamma) { | ||
| 1285 | enum surface_pixel_format format = SURFACE_PIXEL_FORMAT_GRPH_BEGIN; | ||
| 1286 | |||
| 1287 | if (u->plane_info) | ||
| 1288 | format = u->plane_info->format; | ||
| 1289 | else if (u->surface) | ||
| 1290 | format = u->surface->format; | ||
| 1291 | |||
| 1292 | if (dce_use_lut(format)) | ||
| 1293 | update_flags->bits.gamma_change = 1; | ||
| 1294 | } | ||
| 1295 | |||
| 1272 | if (update_flags->bits.in_transfer_func_change) { | 1296 | if (update_flags->bits.in_transfer_func_change) { |
| 1273 | type = UPDATE_TYPE_MED; | 1297 | type = UPDATE_TYPE_MED; |
| 1274 | elevate_update_type(&overall_type, type); | 1298 | elevate_update_type(&overall_type, type); |
| 1275 | } | 1299 | } |
| 1276 | 1300 | ||
| 1277 | if (update_flags->bits.input_csc_change | 1301 | if (update_flags->bits.input_csc_change |
| 1278 | || update_flags->bits.coeff_reduction_change) { | 1302 | || update_flags->bits.coeff_reduction_change |
| 1303 | || update_flags->bits.gamma_change) { | ||
| 1279 | type = UPDATE_TYPE_FULL; | 1304 | type = UPDATE_TYPE_FULL; |
| 1280 | elevate_update_type(&overall_type, type); | 1305 | elevate_update_type(&overall_type, type); |
| 1281 | } | 1306 | } |
| @@ -1379,7 +1404,7 @@ static void notify_display_count_to_smu( | |||
| 1379 | * sent as part of pplib_apply_display_requirements. | 1404 | * sent as part of pplib_apply_display_requirements. |
| 1380 | * So just return. | 1405 | * So just return. |
| 1381 | */ | 1406 | */ |
| 1382 | if (!pp_smu->set_display_count) | 1407 | if (!pp_smu || !pp_smu->set_display_count) |
| 1383 | return; | 1408 | return; |
| 1384 | 1409 | ||
| 1385 | display_count = 0; | 1410 | display_count = 0; |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index bd58dbae7d3e..9f9503a9b9aa 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c | |||
| @@ -2559,23 +2559,24 @@ void core_link_enable_stream( | |||
| 2559 | pipe_ctx->stream_res.stream_enc, | 2559 | pipe_ctx->stream_res.stream_enc, |
| 2560 | &stream->timing); | 2560 | &stream->timing); |
| 2561 | 2561 | ||
| 2562 | resource_build_info_frame(pipe_ctx); | 2562 | if (!IS_FPGA_MAXIMUS_DC(core_dc->ctx->dce_environment)) { |
| 2563 | core_dc->hwss.update_info_frame(pipe_ctx); | 2563 | resource_build_info_frame(pipe_ctx); |
| 2564 | 2564 | core_dc->hwss.update_info_frame(pipe_ctx); | |
| 2565 | /* eDP lit up by bios already, no need to enable again. */ | 2565 | |
| 2566 | if (pipe_ctx->stream->signal == SIGNAL_TYPE_EDP && | 2566 | /* eDP lit up by bios already, no need to enable again. */ |
| 2567 | pipe_ctx->stream->apply_edp_fast_boot_optimization) { | 2567 | if (pipe_ctx->stream->signal == SIGNAL_TYPE_EDP && |
| 2568 | pipe_ctx->stream->apply_edp_fast_boot_optimization = false; | 2568 | pipe_ctx->stream->apply_edp_fast_boot_optimization) { |
| 2569 | pipe_ctx->stream->dpms_off = false; | 2569 | pipe_ctx->stream->apply_edp_fast_boot_optimization = false; |
| 2570 | return; | 2570 | pipe_ctx->stream->dpms_off = false; |
| 2571 | } | 2571 | return; |
| 2572 | } | ||
| 2572 | 2573 | ||
| 2573 | if (pipe_ctx->stream->dpms_off) | 2574 | if (pipe_ctx->stream->dpms_off) |
| 2574 | return; | 2575 | return; |
| 2575 | 2576 | ||
| 2576 | status = enable_link(state, pipe_ctx); | 2577 | status = enable_link(state, pipe_ctx); |
| 2577 | 2578 | ||
| 2578 | if (status != DC_OK) { | 2579 | if (status != DC_OK) { |
| 2579 | DC_LOG_WARNING("enabling link %u failed: %d\n", | 2580 | DC_LOG_WARNING("enabling link %u failed: %d\n", |
| 2580 | pipe_ctx->stream->sink->link->link_index, | 2581 | pipe_ctx->stream->sink->link->link_index, |
| 2581 | status); | 2582 | status); |
| @@ -2590,23 +2591,26 @@ void core_link_enable_stream( | |||
| 2590 | BREAK_TO_DEBUGGER(); | 2591 | BREAK_TO_DEBUGGER(); |
| 2591 | return; | 2592 | return; |
| 2592 | } | 2593 | } |
| 2593 | } | 2594 | } |
| 2594 | 2595 | ||
| 2595 | core_dc->hwss.enable_audio_stream(pipe_ctx); | 2596 | core_dc->hwss.enable_audio_stream(pipe_ctx); |
| 2596 | 2597 | ||
| 2597 | /* turn off otg test pattern if enable */ | 2598 | /* turn off otg test pattern if enable */ |
| 2598 | if (pipe_ctx->stream_res.tg->funcs->set_test_pattern) | 2599 | if (pipe_ctx->stream_res.tg->funcs->set_test_pattern) |
| 2599 | pipe_ctx->stream_res.tg->funcs->set_test_pattern(pipe_ctx->stream_res.tg, | 2600 | pipe_ctx->stream_res.tg->funcs->set_test_pattern(pipe_ctx->stream_res.tg, |
| 2600 | CONTROLLER_DP_TEST_PATTERN_VIDEOMODE, | 2601 | CONTROLLER_DP_TEST_PATTERN_VIDEOMODE, |
| 2601 | COLOR_DEPTH_UNDEFINED); | 2602 | COLOR_DEPTH_UNDEFINED); |
| 2602 | 2603 | ||
| 2603 | core_dc->hwss.enable_stream(pipe_ctx); | 2604 | core_dc->hwss.enable_stream(pipe_ctx); |
| 2604 | 2605 | ||
| 2605 | if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) | 2606 | if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) |
| 2606 | allocate_mst_payload(pipe_ctx); | 2607 | allocate_mst_payload(pipe_ctx); |
| 2608 | |||
| 2609 | core_dc->hwss.unblank_stream(pipe_ctx, | ||
| 2610 | &pipe_ctx->stream->sink->link->cur_link_settings); | ||
| 2611 | |||
| 2612 | } | ||
| 2607 | 2613 | ||
| 2608 | core_dc->hwss.unblank_stream(pipe_ctx, | ||
| 2609 | &pipe_ctx->stream->sink->link->cur_link_settings); | ||
| 2610 | } | 2614 | } |
| 2611 | 2615 | ||
| 2612 | void core_link_disable_stream(struct pipe_ctx *pipe_ctx, int option) | 2616 | void core_link_disable_stream(struct pipe_ctx *pipe_ctx, int option) |
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 7691139363a9..11ea2a226952 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | #include "inc/compressor.h" | 38 | #include "inc/compressor.h" |
| 39 | #include "dml/display_mode_lib.h" | 39 | #include "dml/display_mode_lib.h" |
| 40 | 40 | ||
| 41 | #define DC_VER "3.1.66" | 41 | #define DC_VER "3.1.67" |
| 42 | 42 | ||
| 43 | #define MAX_SURFACES 3 | 43 | #define MAX_SURFACES 3 |
| 44 | #define MAX_STREAMS 6 | 44 | #define MAX_STREAMS 6 |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c index bf6261a1584b..d42afa081452 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | |||
| @@ -468,6 +468,9 @@ static void dce12_update_clocks(struct dccg *dccg, | |||
| 468 | { | 468 | { |
| 469 | struct dm_pp_clock_for_voltage_req clock_voltage_req = {0}; | 469 | struct dm_pp_clock_for_voltage_req clock_voltage_req = {0}; |
| 470 | 470 | ||
| 471 | /* TODO: Investigate why this is needed to fix display corruption. */ | ||
| 472 | new_clocks->dispclk_khz = new_clocks->dispclk_khz * 115 / 100; | ||
| 473 | |||
| 471 | if (should_set_clock(safe_to_lower, new_clocks->dispclk_khz, dccg->clks.dispclk_khz)) { | 474 | if (should_set_clock(safe_to_lower, new_clocks->dispclk_khz, dccg->clks.dispclk_khz)) { |
| 472 | clock_voltage_req.clk_type = DM_PP_CLOCK_TYPE_DISPLAY_CLK; | 475 | clock_voltage_req.clk_type = DM_PP_CLOCK_TYPE_DISPLAY_CLK; |
| 473 | clock_voltage_req.clocks_in_khz = new_clocks->dispclk_khz; | 476 | clock_voltage_req.clocks_in_khz = new_clocks->dispclk_khz; |
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index dc1eed5ba996..6b7cccc486d8 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | |||
| @@ -1377,26 +1377,13 @@ static enum dc_status apply_single_controller_ctx_to_hw( | |||
| 1377 | /* */ | 1377 | /* */ |
| 1378 | dc->hwss.enable_stream_timing(pipe_ctx, context, dc); | 1378 | dc->hwss.enable_stream_timing(pipe_ctx, context, dc); |
| 1379 | 1379 | ||
| 1380 | /* FPGA does not program backend */ | ||
| 1381 | if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) { | ||
| 1382 | pipe_ctx->stream_res.opp->funcs->opp_set_dyn_expansion( | ||
| 1383 | pipe_ctx->stream_res.opp, | ||
| 1384 | COLOR_SPACE_YCBCR601, | ||
| 1385 | stream->timing.display_color_depth, | ||
| 1386 | pipe_ctx->stream->signal); | ||
| 1387 | |||
| 1388 | pipe_ctx->stream_res.opp->funcs->opp_program_fmt( | ||
| 1389 | pipe_ctx->stream_res.opp, | ||
| 1390 | &stream->bit_depth_params, | ||
| 1391 | &stream->clamping); | ||
| 1392 | return DC_OK; | ||
| 1393 | } | ||
| 1394 | /* TODO: move to stream encoder */ | 1380 | /* TODO: move to stream encoder */ |
| 1395 | if (pipe_ctx->stream->signal != SIGNAL_TYPE_VIRTUAL) | 1381 | if (pipe_ctx->stream->signal != SIGNAL_TYPE_VIRTUAL) |
| 1396 | if (DC_OK != bios_parser_crtc_source_select(pipe_ctx)) { | 1382 | if (DC_OK != bios_parser_crtc_source_select(pipe_ctx)) { |
| 1397 | BREAK_TO_DEBUGGER(); | 1383 | BREAK_TO_DEBUGGER(); |
| 1398 | return DC_ERROR_UNEXPECTED; | 1384 | return DC_ERROR_UNEXPECTED; |
| 1399 | } | 1385 | } |
| 1386 | |||
| 1400 | pipe_ctx->stream_res.opp->funcs->opp_set_dyn_expansion( | 1387 | pipe_ctx->stream_res.opp->funcs->opp_set_dyn_expansion( |
| 1401 | pipe_ctx->stream_res.opp, | 1388 | pipe_ctx->stream_res.opp, |
| 1402 | COLOR_SPACE_YCBCR601, | 1389 | COLOR_SPACE_YCBCR601, |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 6bd4ec39f869..a881ff5559ec 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #include "dcn10_hubp.h" | 44 | #include "dcn10_hubp.h" |
| 45 | #include "dcn10_hubbub.h" | 45 | #include "dcn10_hubbub.h" |
| 46 | #include "dcn10_cm_common.h" | 46 | #include "dcn10_cm_common.h" |
| 47 | #include "dc_link_dp.h" | ||
| 47 | 48 | ||
| 48 | #define DC_LOGGER_INIT(logger) | 49 | #define DC_LOGGER_INIT(logger) |
| 49 | 50 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/inc/dcn_calcs.h b/drivers/gpu/drm/amd/display/dc/inc/dcn_calcs.h index ddbb673caa08..e688eb9b975c 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/dcn_calcs.h +++ b/drivers/gpu/drm/amd/display/dc/inc/dcn_calcs.h | |||
| @@ -504,10 +504,10 @@ struct dcn_bw_internal_vars { | |||
| 504 | float prefetch_mode; | 504 | float prefetch_mode; |
| 505 | float dstx_after_scaler; | 505 | float dstx_after_scaler; |
| 506 | float dsty_after_scaler; | 506 | float dsty_after_scaler; |
| 507 | float v_update_offset_pix; | 507 | float v_update_offset_pix[number_of_planes_minus_one + 1]; |
| 508 | float total_repeater_delay_time; | 508 | float total_repeater_delay_time; |
| 509 | float v_update_width_pix; | 509 | float v_update_width_pix[number_of_planes_minus_one + 1]; |
| 510 | float v_ready_offset_pix; | 510 | float v_ready_offset_pix[number_of_planes_minus_one + 1]; |
| 511 | float t_setup; | 511 | float t_setup; |
| 512 | float t_wait; | 512 | float t_wait; |
| 513 | float bandwidth_available_for_immediate_flip; | 513 | float bandwidth_available_for_immediate_flip; |
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index e1688902a1b0..4018c7180d00 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c | |||
| @@ -480,22 +480,11 @@ bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync, | |||
| 480 | return false; | 480 | return false; |
| 481 | } | 481 | } |
| 482 | 482 | ||
| 483 | void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, | 483 | static void build_vrr_infopacket_header_v1(enum signal_type signal, |
| 484 | const struct dc_stream_state *stream, | 484 | struct dc_info_packet *infopacket, |
| 485 | const struct mod_vrr_params *vrr, | 485 | unsigned int *payload_size) |
| 486 | struct dc_info_packet *infopacket) | ||
| 487 | { | 486 | { |
| 488 | /* SPD info packet for FreeSync */ | 487 | if (dc_is_hdmi_signal(signal)) { |
| 489 | unsigned char checksum = 0; | ||
| 490 | unsigned int idx, payload_size = 0; | ||
| 491 | |||
| 492 | /* Check if Freesync is supported. Return if false. If true, | ||
| 493 | * set the corresponding bit in the info packet | ||
| 494 | */ | ||
| 495 | if (!vrr->supported || !vrr->send_vsif) | ||
| 496 | return; | ||
| 497 | |||
| 498 | if (dc_is_hdmi_signal(stream->signal)) { | ||
| 499 | 488 | ||
| 500 | /* HEADER */ | 489 | /* HEADER */ |
| 501 | 490 | ||
| @@ -510,9 +499,9 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, | |||
| 510 | /* HB2 = [Bits 7:5 = 0] [Bits 4:0 = Length = 0x08] */ | 499 | /* HB2 = [Bits 7:5 = 0] [Bits 4:0 = Length = 0x08] */ |
| 511 | infopacket->hb2 = 0x08; | 500 | infopacket->hb2 = 0x08; |
| 512 | 501 | ||
| 513 | payload_size = 0x08; | 502 | *payload_size = 0x08; |
| 514 | 503 | ||
| 515 | } else if (dc_is_dp_signal(stream->signal)) { | 504 | } else if (dc_is_dp_signal(signal)) { |
| 516 | 505 | ||
| 517 | /* HEADER */ | 506 | /* HEADER */ |
| 518 | 507 | ||
| @@ -536,9 +525,62 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, | |||
| 536 | */ | 525 | */ |
| 537 | infopacket->hb3 = 0x04; | 526 | infopacket->hb3 = 0x04; |
| 538 | 527 | ||
| 539 | payload_size = 0x1B; | 528 | *payload_size = 0x1B; |
| 540 | } | 529 | } |
| 530 | } | ||
| 531 | |||
| 532 | static void build_vrr_infopacket_header_v2(enum signal_type signal, | ||
| 533 | struct dc_info_packet *infopacket, | ||
| 534 | unsigned int *payload_size) | ||
| 535 | { | ||
| 536 | if (dc_is_hdmi_signal(signal)) { | ||
| 537 | |||
| 538 | /* HEADER */ | ||
| 539 | |||
| 540 | /* HB0 = Packet Type = 0x83 (Source Product | ||
| 541 | * Descriptor InfoFrame) | ||
| 542 | */ | ||
| 543 | infopacket->hb0 = DC_HDMI_INFOFRAME_TYPE_SPD; | ||
| 544 | |||
| 545 | /* HB1 = Version = 0x02 */ | ||
| 546 | infopacket->hb1 = 0x02; | ||
| 547 | |||
| 548 | /* HB2 = [Bits 7:5 = 0] [Bits 4:0 = Length = 0x09] */ | ||
| 549 | infopacket->hb2 = 0x09; | ||
| 550 | |||
| 551 | *payload_size = 0x0A; | ||
| 541 | 552 | ||
| 553 | } else if (dc_is_dp_signal(signal)) { | ||
| 554 | |||
| 555 | /* HEADER */ | ||
| 556 | |||
| 557 | /* HB0 = Secondary-data Packet ID = 0 - Only non-zero | ||
| 558 | * when used to associate audio related info packets | ||
| 559 | */ | ||
| 560 | infopacket->hb0 = 0x00; | ||
| 561 | |||
| 562 | /* HB1 = Packet Type = 0x83 (Source Product | ||
| 563 | * Descriptor InfoFrame) | ||
| 564 | */ | ||
| 565 | infopacket->hb1 = DC_HDMI_INFOFRAME_TYPE_SPD; | ||
| 566 | |||
| 567 | /* HB2 = [Bits 7:0 = Least significant eight bits - | ||
| 568 | * For INFOFRAME, the value must be 1Bh] | ||
| 569 | */ | ||
| 570 | infopacket->hb2 = 0x1B; | ||
| 571 | |||
| 572 | /* HB3 = [Bits 7:2 = INFOFRAME SDP Version Number = 0x2] | ||
| 573 | * [Bits 1:0 = Most significant two bits = 0x00] | ||
| 574 | */ | ||
| 575 | infopacket->hb3 = 0x08; | ||
| 576 | |||
| 577 | *payload_size = 0x1B; | ||
| 578 | } | ||
| 579 | } | ||
| 580 | |||
| 581 | static void build_vrr_infopacket_data(const struct mod_vrr_params *vrr, | ||
| 582 | struct dc_info_packet *infopacket) | ||
| 583 | { | ||
| 542 | /* PB1 = 0x1A (24bit AMD IEEE OUI (0x00001A) - Byte 0) */ | 584 | /* PB1 = 0x1A (24bit AMD IEEE OUI (0x00001A) - Byte 0) */ |
| 543 | infopacket->sb[1] = 0x1A; | 585 | infopacket->sb[1] = 0x1A; |
| 544 | 586 | ||
| @@ -576,15 +618,39 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, | |||
| 576 | */ | 618 | */ |
| 577 | infopacket->sb[8] = (unsigned char)(vrr->max_refresh_in_uhz / 1000000); | 619 | infopacket->sb[8] = (unsigned char)(vrr->max_refresh_in_uhz / 1000000); |
| 578 | 620 | ||
| 579 | /* PB9 - PB27 = Reserved */ | ||
| 580 | 621 | ||
| 622 | //FreeSync HDR | ||
| 623 | infopacket->sb[9] = 0; | ||
| 624 | infopacket->sb[10] = 0; | ||
| 625 | } | ||
| 626 | |||
| 627 | static void build_vrr_infopacket_fs2_data(enum color_transfer_func app_tf, | ||
| 628 | struct dc_info_packet *infopacket) | ||
| 629 | { | ||
| 630 | if (app_tf != transfer_func_unknown) { | ||
| 631 | infopacket->valid = true; | ||
| 632 | |||
| 633 | infopacket->sb[6] |= 0x08; // PB6 = [Bit 3 = Native Color Active] | ||
| 634 | |||
| 635 | if (app_tf == transfer_func_gamma_22) { | ||
| 636 | infopacket->sb[9] |= 0x04; // PB6 = [Bit 2 = Gamma 2.2 EOTF Active] | ||
| 637 | } | ||
| 638 | } | ||
| 639 | } | ||
| 640 | |||
| 641 | static void build_vrr_infopacket_checksum(unsigned int *payload_size, | ||
| 642 | struct dc_info_packet *infopacket) | ||
| 643 | { | ||
| 581 | /* Calculate checksum */ | 644 | /* Calculate checksum */ |
| 645 | unsigned int idx = 0; | ||
| 646 | unsigned char checksum = 0; | ||
| 647 | |||
| 582 | checksum += infopacket->hb0; | 648 | checksum += infopacket->hb0; |
| 583 | checksum += infopacket->hb1; | 649 | checksum += infopacket->hb1; |
| 584 | checksum += infopacket->hb2; | 650 | checksum += infopacket->hb2; |
| 585 | checksum += infopacket->hb3; | 651 | checksum += infopacket->hb3; |
| 586 | 652 | ||
| 587 | for (idx = 1; idx <= payload_size; idx++) | 653 | for (idx = 1; idx <= *payload_size; idx++) |
| 588 | checksum += infopacket->sb[idx]; | 654 | checksum += infopacket->sb[idx]; |
| 589 | 655 | ||
| 590 | /* PB0 = Checksum (one byte complement) */ | 656 | /* PB0 = Checksum (one byte complement) */ |
| @@ -593,6 +659,64 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, | |||
| 593 | infopacket->valid = true; | 659 | infopacket->valid = true; |
| 594 | } | 660 | } |
| 595 | 661 | ||
| 662 | static void build_vrr_infopacket_v1(enum signal_type signal, | ||
| 663 | const struct mod_vrr_params *vrr, | ||
| 664 | struct dc_info_packet *infopacket) | ||
| 665 | { | ||
| 666 | /* SPD info packet for FreeSync */ | ||
| 667 | unsigned int payload_size = 0; | ||
| 668 | |||
| 669 | build_vrr_infopacket_header_v1(signal, infopacket, &payload_size); | ||
| 670 | build_vrr_infopacket_data(vrr, infopacket); | ||
| 671 | build_vrr_infopacket_checksum(&payload_size, infopacket); | ||
| 672 | |||
| 673 | infopacket->valid = true; | ||
| 674 | } | ||
| 675 | |||
| 676 | static void build_vrr_infopacket_v2(enum signal_type signal, | ||
| 677 | const struct mod_vrr_params *vrr, | ||
| 678 | const enum color_transfer_func *app_tf, | ||
| 679 | struct dc_info_packet *infopacket) | ||
| 680 | { | ||
| 681 | unsigned int payload_size = 0; | ||
| 682 | |||
| 683 | build_vrr_infopacket_header_v2(signal, infopacket, &payload_size); | ||
| 684 | build_vrr_infopacket_data(vrr, infopacket); | ||
| 685 | |||
| 686 | if (app_tf != NULL) | ||
| 687 | build_vrr_infopacket_fs2_data(*app_tf, infopacket); | ||
| 688 | |||
| 689 | build_vrr_infopacket_checksum(&payload_size, infopacket); | ||
| 690 | |||
| 691 | infopacket->valid = true; | ||
| 692 | } | ||
| 693 | |||
| 694 | void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, | ||
| 695 | const struct dc_stream_state *stream, | ||
| 696 | const struct mod_vrr_params *vrr, | ||
| 697 | enum vrr_packet_type packet_type, | ||
| 698 | const enum color_transfer_func *app_tf, | ||
| 699 | struct dc_info_packet *infopacket) | ||
| 700 | { | ||
| 701 | /* SPD info packet for FreeSync */ | ||
| 702 | |||
| 703 | /* Check if Freesync is supported. Return if false. If true, | ||
| 704 | * set the corresponding bit in the info packet | ||
| 705 | */ | ||
| 706 | if (!vrr->supported || !vrr->send_vsif) | ||
| 707 | return; | ||
| 708 | |||
| 709 | switch (packet_type) { | ||
| 710 | case packet_type_fs2: | ||
| 711 | build_vrr_infopacket_v2(stream->signal, vrr, app_tf, infopacket); | ||
| 712 | break; | ||
| 713 | case packet_type_vrr: | ||
| 714 | case packet_type_fs1: | ||
| 715 | default: | ||
| 716 | build_vrr_infopacket_v1(stream->signal, vrr, infopacket); | ||
| 717 | } | ||
| 718 | } | ||
| 719 | |||
| 596 | void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync, | 720 | void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync, |
| 597 | const struct dc_stream_state *stream, | 721 | const struct dc_stream_state *stream, |
| 598 | struct mod_freesync_config *in_config, | 722 | struct mod_freesync_config *in_config, |
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h index a0f32cde721c..949a8b62aa98 100644 --- a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h +++ b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | #ifndef MOD_FREESYNC_H_ | 54 | #ifndef MOD_FREESYNC_H_ |
| 55 | #define MOD_FREESYNC_H_ | 55 | #define MOD_FREESYNC_H_ |
| 56 | 56 | ||
| 57 | #include "dm_services.h" | 57 | #include "mod_shared.h" |
| 58 | 58 | ||
| 59 | // Access structures | 59 | // Access structures |
| 60 | struct mod_freesync { | 60 | struct mod_freesync { |
| @@ -144,6 +144,8 @@ void mod_freesync_get_settings(struct mod_freesync *mod_freesync, | |||
| 144 | void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, | 144 | void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, |
| 145 | const struct dc_stream_state *stream, | 145 | const struct dc_stream_state *stream, |
| 146 | const struct mod_vrr_params *vrr, | 146 | const struct mod_vrr_params *vrr, |
| 147 | enum vrr_packet_type packet_type, | ||
| 148 | const enum color_transfer_func *app_tf, | ||
| 147 | struct dc_info_packet *infopacket); | 149 | struct dc_info_packet *infopacket); |
| 148 | 150 | ||
| 149 | void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync, | 151 | void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync, |
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_shared.h b/drivers/gpu/drm/amd/display/modules/inc/mod_shared.h new file mode 100644 index 000000000000..238c431ae483 --- /dev/null +++ b/drivers/gpu/drm/amd/display/modules/inc/mod_shared.h | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2016 Advanced Micro Devices, Inc. | ||
| 3 | * | ||
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 5 | * copy of this software and associated documentation files (the "Software"), | ||
| 6 | * to deal in the Software without restriction, including without limitation | ||
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
| 9 | * Software is furnished to do so, subject to the following conditions: | ||
| 10 | * | ||
| 11 | * The above copyright notice and this permission notice shall be included in | ||
| 12 | * all copies or substantial portions of the Software. | ||
| 13 | * | ||
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| 20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
| 21 | * | ||
| 22 | * Authors: AMD | ||
| 23 | * | ||
| 24 | */ | ||
| 25 | |||
| 26 | |||
| 27 | #ifndef MOD_SHARED_H_ | ||
| 28 | #define MOD_SHARED_H_ | ||
| 29 | |||
| 30 | enum color_transfer_func { | ||
| 31 | transfer_func_unknown, | ||
| 32 | transfer_func_srgb, | ||
| 33 | transfer_func_bt709, | ||
| 34 | transfer_func_pq2084, | ||
| 35 | transfer_func_pq2084_interim, | ||
| 36 | transfer_func_linear_0_1, | ||
| 37 | transfer_func_linear_0_125, | ||
| 38 | transfer_func_dolbyvision, | ||
| 39 | transfer_func_gamma_22, | ||
| 40 | transfer_func_gamma_26 | ||
| 41 | }; | ||
| 42 | |||
| 43 | enum vrr_packet_type { | ||
| 44 | packet_type_vrr, | ||
| 45 | packet_type_fs1, | ||
| 46 | packet_type_fs2 | ||
| 47 | }; | ||
| 48 | |||
| 49 | #endif /* MOD_SHARED_H_ */ | ||
diff --git a/drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c b/drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c index 52378fc69079..ff8bfb9b43b0 100644 --- a/drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c +++ b/drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c | |||
| @@ -48,9 +48,12 @@ static void mod_build_vsc_infopacket(const struct dc_stream_state *stream, | |||
| 48 | unsigned int i; | 48 | unsigned int i; |
| 49 | unsigned int pixelEncoding = 0; | 49 | unsigned int pixelEncoding = 0; |
| 50 | unsigned int colorimetryFormat = 0; | 50 | unsigned int colorimetryFormat = 0; |
| 51 | bool stereo3dSupport = false; | ||
| 51 | 52 | ||
| 52 | if (stream->timing.timing_3d_format != TIMING_3D_FORMAT_NONE && stream->view_format != VIEW_3D_FORMAT_NONE) | 53 | if (stream->timing.timing_3d_format != TIMING_3D_FORMAT_NONE && stream->view_format != VIEW_3D_FORMAT_NONE) { |
| 53 | vscPacketRevision = 1; | 54 | vscPacketRevision = 1; |
| 55 | stereo3dSupport = true; | ||
| 56 | } | ||
| 54 | 57 | ||
| 55 | /*VSC packet set to 2 when DP revision >= 1.2*/ | 58 | /*VSC packet set to 2 when DP revision >= 1.2*/ |
| 56 | if (stream->psr_version != 0) | 59 | if (stream->psr_version != 0) |
| @@ -94,12 +97,59 @@ static void mod_build_vsc_infopacket(const struct dc_stream_state *stream, | |||
| 94 | info_packet->hb2 = 0x01; // 01h = Revision number. VSC SDP supporting 3D stereo only | 97 | info_packet->hb2 = 0x01; // 01h = Revision number. VSC SDP supporting 3D stereo only |
| 95 | info_packet->hb3 = 0x01; // 01h = VSC SDP supporting 3D stereo only (HB2 = 01h). | 98 | info_packet->hb3 = 0x01; // 01h = VSC SDP supporting 3D stereo only (HB2 = 01h). |
| 96 | 99 | ||
| 97 | if (stream->timing.timing_3d_format == TIMING_3D_FORMAT_INBAND_FA) | ||
| 98 | info_packet->sb[0] = 0x1; | ||
| 99 | |||
| 100 | info_packet->valid = true; | 100 | info_packet->valid = true; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | if (stereo3dSupport) { | ||
| 104 | /* ==============================================================================================================| | ||
| 105 | * A. STEREO 3D | ||
| 106 | * ==============================================================================================================| | ||
| 107 | * VSC Payload (1 byte) From DP1.2 spec | ||
| 108 | * | ||
| 109 | * Bits 3:0 (Stereo Interface Method Code) | Bits 7:4 (Stereo Interface Method Specific Parameter) | ||
| 110 | * ----------------------------------------------------------------------------------------------------- | ||
| 111 | * 0 = Non Stereo Video | Must be set to 0x0 | ||
| 112 | * ----------------------------------------------------------------------------------------------------- | ||
| 113 | * 1 = Frame/Field Sequential | 0x0: L + R view indication based on MISC1 bit 2:1 | ||
| 114 | * | 0x1: Right when Stereo Signal = 1 | ||
| 115 | * | 0x2: Left when Stereo Signal = 1 | ||
| 116 | * | (others reserved) | ||
| 117 | * ----------------------------------------------------------------------------------------------------- | ||
| 118 | * 2 = Stacked Frame | 0x0: Left view is on top and right view on bottom | ||
| 119 | * | (others reserved) | ||
| 120 | * ----------------------------------------------------------------------------------------------------- | ||
| 121 | * 3 = Pixel Interleaved | 0x0: horiz interleaved, right view pixels on even lines | ||
| 122 | * | 0x1: horiz interleaved, right view pixels on odd lines | ||
| 123 | * | 0x2: checker board, start with left view pixel | ||
| 124 | * | 0x3: vertical interleaved, start with left view pixels | ||
| 125 | * | 0x4: vertical interleaved, start with right view pixels | ||
| 126 | * | (others reserved) | ||
| 127 | * ----------------------------------------------------------------------------------------------------- | ||
| 128 | * 4 = Side-by-side | 0x0: left half represents left eye view | ||
| 129 | * | 0x1: left half represents right eye view | ||
| 130 | */ | ||
| 131 | switch (stream->timing.timing_3d_format) { | ||
| 132 | case TIMING_3D_FORMAT_HW_FRAME_PACKING: | ||
| 133 | case TIMING_3D_FORMAT_SW_FRAME_PACKING: | ||
| 134 | case TIMING_3D_FORMAT_TOP_AND_BOTTOM: | ||
| 135 | case TIMING_3D_FORMAT_TB_SW_PACKED: | ||
| 136 | info_packet->sb[0] = 0x02; // Stacked Frame, Left view is on top and right view on bottom. | ||
| 137 | break; | ||
| 138 | case TIMING_3D_FORMAT_DP_HDMI_INBAND_FA: | ||
| 139 | case TIMING_3D_FORMAT_INBAND_FA: | ||
| 140 | info_packet->sb[0] = 0x01; // Frame/Field Sequential, L + R view indication based on MISC1 bit 2:1 | ||
| 141 | break; | ||
| 142 | case TIMING_3D_FORMAT_SIDE_BY_SIDE: | ||
| 143 | case TIMING_3D_FORMAT_SBS_SW_PACKED: | ||
| 144 | info_packet->sb[0] = 0x04; // Side-by-side | ||
| 145 | break; | ||
| 146 | default: | ||
| 147 | info_packet->sb[0] = 0x00; // No Stereo Video, Shall be cleared to 0x0. | ||
| 148 | break; | ||
| 149 | } | ||
| 150 | |||
| 151 | } | ||
| 152 | |||
| 103 | /* 05h = VSC SDP supporting 3D stereo, PSR2, and Pixel Encoding/Colorimetry Format indication. | 153 | /* 05h = VSC SDP supporting 3D stereo, PSR2, and Pixel Encoding/Colorimetry Format indication. |
| 104 | * Added in DP1.3, a DP Source device is allowed to indicate the pixel encoding/colorimetry | 154 | * Added in DP1.3, a DP Source device is allowed to indicate the pixel encoding/colorimetry |
| 105 | * format to the DP Sink device with VSC SDP only when the DP Sink device supports it | 155 | * format to the DP Sink device with VSC SDP only when the DP Sink device supports it |
diff --git a/drivers/gpu/drm/amd/display/modules/stats/stats.c b/drivers/gpu/drm/amd/display/modules/stats/stats.c index 3d4c1b1ab8c4..03121ca64fe4 100644 --- a/drivers/gpu/drm/amd/display/modules/stats/stats.c +++ b/drivers/gpu/drm/amd/display/modules/stats/stats.c | |||
| @@ -186,12 +186,8 @@ void mod_stats_destroy(struct mod_stats *mod_stats) | |||
| 186 | if (mod_stats != NULL) { | 186 | if (mod_stats != NULL) { |
| 187 | struct core_stats *core_stats = MOD_STATS_TO_CORE(mod_stats); | 187 | struct core_stats *core_stats = MOD_STATS_TO_CORE(mod_stats); |
| 188 | 188 | ||
| 189 | if (core_stats->time != NULL) | 189 | kfree(core_stats->time); |
| 190 | kfree(core_stats->time); | 190 | kfree(core_stats->events); |
| 191 | |||
| 192 | if (core_stats->events != NULL) | ||
| 193 | kfree(core_stats->events); | ||
| 194 | |||
| 195 | kfree(core_stats); | 191 | kfree(core_stats); |
| 196 | } | 192 | } |
| 197 | } | 193 | } |
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h index 86b167ec9863..2083c308007c 100644 --- a/drivers/gpu/drm/amd/include/amd_shared.h +++ b/drivers/gpu/drm/amd/include/amd_shared.h | |||
| @@ -109,6 +109,7 @@ enum amd_powergating_state { | |||
| 109 | #define AMD_PG_SUPPORT_GFX_PIPELINE (1 << 12) | 109 | #define AMD_PG_SUPPORT_GFX_PIPELINE (1 << 12) |
| 110 | #define AMD_PG_SUPPORT_MMHUB (1 << 13) | 110 | #define AMD_PG_SUPPORT_MMHUB (1 << 13) |
| 111 | #define AMD_PG_SUPPORT_VCN (1 << 14) | 111 | #define AMD_PG_SUPPORT_VCN (1 << 14) |
| 112 | #define AMD_PG_SUPPORT_VCN_DPG (1 << 15) | ||
| 112 | 113 | ||
| 113 | enum PP_FEATURE_MASK { | 114 | enum PP_FEATURE_MASK { |
| 114 | PP_SCLK_DPM_MASK = 0x1, | 115 | PP_SCLK_DPM_MASK = 0x1, |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_offset.h b/drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_offset.h index 216a401028de..4b7da589e14a 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_offset.h +++ b/drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_offset.h | |||
| @@ -33,6 +33,14 @@ | |||
| 33 | #define mmUVD_POWER_STATUS_BASE_IDX 1 | 33 | #define mmUVD_POWER_STATUS_BASE_IDX 1 |
| 34 | #define mmCC_UVD_HARVESTING 0x00c7 | 34 | #define mmCC_UVD_HARVESTING 0x00c7 |
| 35 | #define mmCC_UVD_HARVESTING_BASE_IDX 1 | 35 | #define mmCC_UVD_HARVESTING_BASE_IDX 1 |
| 36 | #define mmUVD_DPG_LMA_CTL 0x00d1 | ||
| 37 | #define mmUVD_DPG_LMA_CTL_BASE_IDX 1 | ||
| 38 | #define mmUVD_DPG_LMA_DATA 0x00d2 | ||
| 39 | #define mmUVD_DPG_LMA_DATA_BASE_IDX 1 | ||
| 40 | #define mmUVD_DPG_LMA_MASK 0x00d3 | ||
| 41 | #define mmUVD_DPG_LMA_MASK_BASE_IDX 1 | ||
| 42 | #define mmUVD_DPG_PAUSE 0x00d4 | ||
| 43 | #define mmUVD_DPG_PAUSE_BASE_IDX 1 | ||
| 36 | #define mmUVD_SCRATCH1 0x00d5 | 44 | #define mmUVD_SCRATCH1 0x00d5 |
| 37 | #define mmUVD_SCRATCH1_BASE_IDX 1 | 45 | #define mmUVD_SCRATCH1_BASE_IDX 1 |
| 38 | #define mmUVD_SCRATCH2 0x00d6 | 46 | #define mmUVD_SCRATCH2 0x00d6 |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_sh_mask.h index 124383dac284..26382f5d5354 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_sh_mask.h +++ b/drivers/gpu/drm/amd/include/asic_reg/vcn/vcn_1_0_sh_mask.h | |||
| @@ -87,6 +87,26 @@ | |||
| 87 | //CC_UVD_HARVESTING | 87 | //CC_UVD_HARVESTING |
| 88 | #define CC_UVD_HARVESTING__UVD_DISABLE__SHIFT 0x1 | 88 | #define CC_UVD_HARVESTING__UVD_DISABLE__SHIFT 0x1 |
| 89 | #define CC_UVD_HARVESTING__UVD_DISABLE_MASK 0x00000002L | 89 | #define CC_UVD_HARVESTING__UVD_DISABLE_MASK 0x00000002L |
| 90 | //UVD_DPG_LMA_CTL | ||
| 91 | #define UVD_DPG_LMA_CTL__READ_WRITE__SHIFT 0x0 | ||
| 92 | #define UVD_DPG_LMA_CTL__MASK_EN__SHIFT 0x1 | ||
| 93 | #define UVD_DPG_LMA_CTL__ADDR_AUTO_INCREMENT__SHIFT 0x2 | ||
| 94 | #define UVD_DPG_LMA_CTL__SRAM_SEL__SHIFT 0x4 | ||
| 95 | #define UVD_DPG_LMA_CTL__READ_WRITE_ADDR__SHIFT 0x10 | ||
| 96 | #define UVD_DPG_LMA_CTL__READ_WRITE_MASK 0x00000001L | ||
| 97 | #define UVD_DPG_LMA_CTL__MASK_EN_MASK 0x00000002L | ||
| 98 | #define UVD_DPG_LMA_CTL__ADDR_AUTO_INCREMENT_MASK 0x00000004L | ||
| 99 | #define UVD_DPG_LMA_CTL__SRAM_SEL_MASK 0x00000010L | ||
| 100 | #define UVD_DPG_LMA_CTL__READ_WRITE_ADDR_MASK 0xFFFF0000L | ||
| 101 | //UVD_DPG_PAUSE | ||
| 102 | #define UVD_DPG_PAUSE__JPEG_PAUSE_DPG_REQ__SHIFT 0x0 | ||
| 103 | #define UVD_DPG_PAUSE__JPEG_PAUSE_DPG_ACK__SHIFT 0x1 | ||
| 104 | #define UVD_DPG_PAUSE__NJ_PAUSE_DPG_REQ__SHIFT 0x2 | ||
| 105 | #define UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK__SHIFT 0x3 | ||
| 106 | #define UVD_DPG_PAUSE__JPEG_PAUSE_DPG_REQ_MASK 0x00000001L | ||
| 107 | #define UVD_DPG_PAUSE__JPEG_PAUSE_DPG_ACK_MASK 0x00000002L | ||
| 108 | #define UVD_DPG_PAUSE__NJ_PAUSE_DPG_REQ_MASK 0x00000004L | ||
| 109 | #define UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK 0x00000008L | ||
| 90 | //UVD_SCRATCH1 | 110 | //UVD_SCRATCH1 |
| 91 | #define UVD_SCRATCH1__SCRATCH1_DATA__SHIFT 0x0 | 111 | #define UVD_SCRATCH1__SCRATCH1_DATA__SHIFT 0x0 |
| 92 | #define UVD_SCRATCH1__SCRATCH1_DATA_MASK 0xFFFFFFFFL | 112 | #define UVD_SCRATCH1__SCRATCH1_DATA_MASK 0xFFFFFFFFL |
| @@ -983,6 +1003,7 @@ | |||
| 983 | #define UVD_MASTINT_EN__SYS_EN_MASK 0x00000004L | 1003 | #define UVD_MASTINT_EN__SYS_EN_MASK 0x00000004L |
| 984 | #define UVD_MASTINT_EN__INT_OVERRUN_MASK 0x007FFFF0L | 1004 | #define UVD_MASTINT_EN__INT_OVERRUN_MASK 0x007FFFF0L |
| 985 | //UVD_SYS_INT_EN | 1005 | //UVD_SYS_INT_EN |
| 1006 | #define UVD_SYS_INT_EN__UVD_JRBC_EN__SHIFT 0x4 | ||
| 986 | #define UVD_SYS_INT_EN__UVD_JRBC_EN_MASK 0x00000010L | 1007 | #define UVD_SYS_INT_EN__UVD_JRBC_EN_MASK 0x00000010L |
| 987 | //JPEG_CGC_CTRL | 1008 | //JPEG_CGC_CTRL |
| 988 | #define JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT 0x0 | 1009 | #define JPEG_CGC_CTRL__DYN_CLOCK_MODE__SHIFT 0x0 |
| @@ -1138,7 +1159,11 @@ | |||
| 1138 | #define UVD_VCPU_CACHE_SIZE2__CACHE_SIZE2_MASK 0x001FFFFFL | 1159 | #define UVD_VCPU_CACHE_SIZE2__CACHE_SIZE2_MASK 0x001FFFFFL |
| 1139 | //UVD_VCPU_CNTL | 1160 | //UVD_VCPU_CNTL |
| 1140 | #define UVD_VCPU_CNTL__CLK_EN__SHIFT 0x9 | 1161 | #define UVD_VCPU_CNTL__CLK_EN__SHIFT 0x9 |
| 1162 | #define UVD_VCPU_CNTL__MIF_WR_LOW_THRESHOLD_BP__SHIFT 0x11 | ||
| 1163 | #define UVD_VCPU_CNTL__PRB_TIMEOUT_VAL__SHIFT 0x14 | ||
| 1141 | #define UVD_VCPU_CNTL__CLK_EN_MASK 0x00000200L | 1164 | #define UVD_VCPU_CNTL__CLK_EN_MASK 0x00000200L |
| 1165 | #define UVD_VCPU_CNTL__MIF_WR_LOW_THRESHOLD_BP_MASK 0x00020000L | ||
| 1166 | #define UVD_VCPU_CNTL__PRB_TIMEOUT_VAL_MASK 0x0FF00000L | ||
| 1142 | //UVD_SOFT_RESET | 1167 | //UVD_SOFT_RESET |
| 1143 | #define UVD_SOFT_RESET__RBC_SOFT_RESET__SHIFT 0x0 | 1168 | #define UVD_SOFT_RESET__RBC_SOFT_RESET__SHIFT 0x0 |
| 1144 | #define UVD_SOFT_RESET__LBSI_SOFT_RESET__SHIFT 0x1 | 1169 | #define UVD_SOFT_RESET__LBSI_SOFT_RESET__SHIFT 0x1 |
diff --git a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h index f43ed96cfa6c..64ecffd52126 100644 --- a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h +++ b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h | |||
| @@ -146,10 +146,10 @@ struct kgd2kfd_shared_resources { | |||
| 146 | * is reserved: (D & reserved_doorbell_mask) == reserved_doorbell_val | 146 | * is reserved: (D & reserved_doorbell_mask) == reserved_doorbell_val |
| 147 | * | 147 | * |
| 148 | * KFD currently uses 1024 (= 0x3ff) doorbells per process. If | 148 | * KFD currently uses 1024 (= 0x3ff) doorbells per process. If |
| 149 | * doorbells 0x0f0-0x0f7 and 0x2f-0x2f7 are reserved, that means | 149 | * doorbells 0x0e0-0x0ff and 0x2e0-0x2ff are reserved, that means |
| 150 | * mask would be set to 0x1f8 and val set to 0x0f0. | 150 | * mask would be set to 0x1e0 and val set to 0x0e0. |
| 151 | */ | 151 | */ |
| 152 | unsigned int sdma_doorbell[2][2]; | 152 | unsigned int sdma_doorbell[2][8]; |
| 153 | unsigned int reserved_doorbell_mask; | 153 | unsigned int reserved_doorbell_mask; |
| 154 | unsigned int reserved_doorbell_val; | 154 | unsigned int reserved_doorbell_val; |
| 155 | 155 | ||
| @@ -409,9 +409,9 @@ struct kfd2kgd_calls { | |||
| 409 | struct dma_fence **ef); | 409 | struct dma_fence **ef); |
| 410 | void (*destroy_process_vm)(struct kgd_dev *kgd, void *vm); | 410 | void (*destroy_process_vm)(struct kgd_dev *kgd, void *vm); |
| 411 | void (*release_process_vm)(struct kgd_dev *kgd, void *vm); | 411 | void (*release_process_vm)(struct kgd_dev *kgd, void *vm); |
| 412 | uint32_t (*get_process_page_dir)(void *vm); | 412 | uint64_t (*get_process_page_dir)(void *vm); |
| 413 | void (*set_vm_context_page_table_base)(struct kgd_dev *kgd, | 413 | void (*set_vm_context_page_table_base)(struct kgd_dev *kgd, |
| 414 | uint32_t vmid, uint32_t page_table_base); | 414 | uint32_t vmid, uint64_t page_table_base); |
| 415 | int (*alloc_memory_of_gpu)(struct kgd_dev *kgd, uint64_t va, | 415 | int (*alloc_memory_of_gpu)(struct kgd_dev *kgd, uint64_t va, |
| 416 | uint64_t size, void *vm, | 416 | uint64_t size, void *vm, |
| 417 | struct kgd_mem **mem, uint64_t *offset, | 417 | struct kgd_mem **mem, uint64_t *offset, |
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h index 448dee481a38..bd7404532029 100644 --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h | |||
| @@ -113,6 +113,7 @@ enum amd_pp_sensors { | |||
| 113 | AMDGPU_PP_SENSOR_GPU_POWER, | 113 | AMDGPU_PP_SENSOR_GPU_POWER, |
| 114 | AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK, | 114 | AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK, |
| 115 | AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK, | 115 | AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK, |
| 116 | AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK, | ||
| 116 | }; | 117 | }; |
| 117 | 118 | ||
| 118 | enum amd_pp_task { | 119 | enum amd_pp_task { |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c index d27c1c9df286..4588bddf8b33 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c | |||
| @@ -488,7 +488,8 @@ int pp_atomfwctrl_get_gpio_information(struct pp_hwmgr *hwmgr, | |||
| 488 | return 0; | 488 | return 0; |
| 489 | } | 489 | } |
| 490 | 490 | ||
| 491 | int pp_atomfwctrl_get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, BIOS_CLKID id, uint32_t *frequency) | 491 | int pp_atomfwctrl_get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, |
| 492 | uint8_t id, uint32_t *frequency) | ||
| 492 | { | 493 | { |
| 493 | struct amdgpu_device *adev = hwmgr->adev; | 494 | struct amdgpu_device *adev = hwmgr->adev; |
| 494 | struct atom_get_smu_clock_info_parameters_v3_1 parameters; | 495 | struct atom_get_smu_clock_info_parameters_v3_1 parameters; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h index 22e21668c93a..fe9e8ceef50e 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h | |||
| @@ -236,7 +236,7 @@ int pp_atomfwctrl_get_vbios_bootup_values(struct pp_hwmgr *hwmgr, | |||
| 236 | int pp_atomfwctrl_get_smc_dpm_information(struct pp_hwmgr *hwmgr, | 236 | int pp_atomfwctrl_get_smc_dpm_information(struct pp_hwmgr *hwmgr, |
| 237 | struct pp_atomfwctrl_smc_dpm_parameters *param); | 237 | struct pp_atomfwctrl_smc_dpm_parameters *param); |
| 238 | int pp_atomfwctrl_get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, | 238 | int pp_atomfwctrl_get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, |
| 239 | BIOS_CLKID id, uint32_t *frequency); | 239 | uint8_t id, uint32_t *frequency); |
| 240 | 240 | ||
| 241 | #endif | 241 | #endif |
| 242 | 242 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c index 9808bd48b386..5d1dae25a466 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | |||
| @@ -552,6 +552,8 @@ static int smu10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | |||
| 552 | { | 552 | { |
| 553 | struct smu10_hwmgr *data = hwmgr->backend; | 553 | struct smu10_hwmgr *data = hwmgr->backend; |
| 554 | struct amdgpu_device *adev = hwmgr->adev; | 554 | struct amdgpu_device *adev = hwmgr->adev; |
| 555 | uint32_t min_sclk = hwmgr->display_config->min_core_set_clock; | ||
| 556 | uint32_t min_mclk = hwmgr->display_config->min_mem_set_clock/100; | ||
| 555 | 557 | ||
| 556 | if (hwmgr->smu_version < 0x1E3700) { | 558 | if (hwmgr->smu_version < 0x1E3700) { |
| 557 | pr_info("smu firmware version too old, can not set dpm level\n"); | 559 | pr_info("smu firmware version too old, can not set dpm level\n"); |
| @@ -563,6 +565,13 @@ static int smu10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | |||
| 563 | (adev->rev_id >= 8)) | 565 | (adev->rev_id >= 8)) |
| 564 | return 0; | 566 | return 0; |
| 565 | 567 | ||
| 568 | if (min_sclk < data->gfx_min_freq_limit) | ||
| 569 | min_sclk = data->gfx_min_freq_limit; | ||
| 570 | |||
| 571 | min_sclk /= 100; /* transfer 10KHz to MHz */ | ||
| 572 | if (min_mclk < data->clock_table.FClocks[0].Freq) | ||
| 573 | min_mclk = data->clock_table.FClocks[0].Freq; | ||
| 574 | |||
| 566 | switch (level) { | 575 | switch (level) { |
| 567 | case AMD_DPM_FORCED_LEVEL_HIGH: | 576 | case AMD_DPM_FORCED_LEVEL_HIGH: |
| 568 | case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK: | 577 | case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK: |
| @@ -595,18 +604,18 @@ static int smu10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | |||
| 595 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK: | 604 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK: |
| 596 | smum_send_msg_to_smc_with_parameter(hwmgr, | 605 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 597 | PPSMC_MSG_SetHardMinGfxClk, | 606 | PPSMC_MSG_SetHardMinGfxClk, |
| 598 | data->gfx_min_freq_limit/100); | 607 | min_sclk); |
| 599 | smum_send_msg_to_smc_with_parameter(hwmgr, | 608 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 600 | PPSMC_MSG_SetSoftMaxGfxClk, | 609 | PPSMC_MSG_SetSoftMaxGfxClk, |
| 601 | data->gfx_min_freq_limit/100); | 610 | min_sclk); |
| 602 | break; | 611 | break; |
| 603 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK: | 612 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK: |
| 604 | smum_send_msg_to_smc_with_parameter(hwmgr, | 613 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 605 | PPSMC_MSG_SetHardMinFclkByFreq, | 614 | PPSMC_MSG_SetHardMinFclkByFreq, |
| 606 | SMU10_UMD_PSTATE_MIN_FCLK); | 615 | min_mclk); |
| 607 | smum_send_msg_to_smc_with_parameter(hwmgr, | 616 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 608 | PPSMC_MSG_SetSoftMaxFclkByFreq, | 617 | PPSMC_MSG_SetSoftMaxFclkByFreq, |
| 609 | SMU10_UMD_PSTATE_MIN_FCLK); | 618 | min_mclk); |
| 610 | break; | 619 | break; |
| 611 | case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD: | 620 | case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD: |
| 612 | smum_send_msg_to_smc_with_parameter(hwmgr, | 621 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| @@ -638,12 +647,12 @@ static int smu10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | |||
| 638 | case AMD_DPM_FORCED_LEVEL_AUTO: | 647 | case AMD_DPM_FORCED_LEVEL_AUTO: |
| 639 | smum_send_msg_to_smc_with_parameter(hwmgr, | 648 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 640 | PPSMC_MSG_SetHardMinGfxClk, | 649 | PPSMC_MSG_SetHardMinGfxClk, |
| 641 | data->gfx_min_freq_limit/100); | 650 | min_sclk); |
| 642 | smum_send_msg_to_smc_with_parameter(hwmgr, | 651 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 643 | PPSMC_MSG_SetHardMinFclkByFreq, | 652 | PPSMC_MSG_SetHardMinFclkByFreq, |
| 644 | hwmgr->display_config->num_display > 3 ? | 653 | hwmgr->display_config->num_display > 3 ? |
| 645 | SMU10_UMD_PSTATE_PEAK_FCLK : | 654 | SMU10_UMD_PSTATE_PEAK_FCLK : |
| 646 | SMU10_UMD_PSTATE_MIN_FCLK); | 655 | min_mclk); |
| 647 | 656 | ||
| 648 | smum_send_msg_to_smc_with_parameter(hwmgr, | 657 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 649 | PPSMC_MSG_SetHardMinSocclkByFreq, | 658 | PPSMC_MSG_SetHardMinSocclkByFreq, |
| @@ -674,10 +683,10 @@ static int smu10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | |||
| 674 | data->gfx_min_freq_limit/100); | 683 | data->gfx_min_freq_limit/100); |
| 675 | smum_send_msg_to_smc_with_parameter(hwmgr, | 684 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 676 | PPSMC_MSG_SetHardMinFclkByFreq, | 685 | PPSMC_MSG_SetHardMinFclkByFreq, |
| 677 | SMU10_UMD_PSTATE_MIN_FCLK); | 686 | min_mclk); |
| 678 | smum_send_msg_to_smc_with_parameter(hwmgr, | 687 | smum_send_msg_to_smc_with_parameter(hwmgr, |
| 679 | PPSMC_MSG_SetSoftMaxFclkByFreq, | 688 | PPSMC_MSG_SetSoftMaxFclkByFreq, |
| 680 | SMU10_UMD_PSTATE_MIN_FCLK); | 689 | min_mclk); |
| 681 | break; | 690 | break; |
| 682 | case AMD_DPM_FORCED_LEVEL_MANUAL: | 691 | case AMD_DPM_FORCED_LEVEL_MANUAL: |
| 683 | case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT: | 692 | case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT: |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c index 04b7da0e39a6..6c99cbf51c08 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | |||
| @@ -4106,17 +4106,17 @@ static int smu7_register_irq_handlers(struct pp_hwmgr *hwmgr) | |||
| 4106 | source->funcs = &smu7_irq_funcs; | 4106 | source->funcs = &smu7_irq_funcs; |
| 4107 | 4107 | ||
| 4108 | amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), | 4108 | amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), |
| 4109 | AMDGPU_IH_CLIENTID_LEGACY, | 4109 | AMDGPU_IRQ_CLIENTID_LEGACY, |
| 4110 | VISLANDS30_IV_SRCID_CG_TSS_THERMAL_LOW_TO_HIGH, | 4110 | VISLANDS30_IV_SRCID_CG_TSS_THERMAL_LOW_TO_HIGH, |
| 4111 | source); | 4111 | source); |
| 4112 | amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), | 4112 | amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), |
| 4113 | AMDGPU_IH_CLIENTID_LEGACY, | 4113 | AMDGPU_IRQ_CLIENTID_LEGACY, |
| 4114 | VISLANDS30_IV_SRCID_CG_TSS_THERMAL_HIGH_TO_LOW, | 4114 | VISLANDS30_IV_SRCID_CG_TSS_THERMAL_HIGH_TO_LOW, |
| 4115 | source); | 4115 | source); |
| 4116 | 4116 | ||
| 4117 | /* Register CTF(GPIO_19) interrupt */ | 4117 | /* Register CTF(GPIO_19) interrupt */ |
| 4118 | amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), | 4118 | amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), |
| 4119 | AMDGPU_IH_CLIENTID_LEGACY, | 4119 | AMDGPU_IRQ_CLIENTID_LEGACY, |
| 4120 | VISLANDS30_IV_SRCID_GPIO_19, | 4120 | VISLANDS30_IV_SRCID_GPIO_19, |
| 4121 | source); | 4121 | source); |
| 4122 | 4122 | ||
| @@ -5035,6 +5035,18 @@ static int smu7_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw | |||
| 5035 | return 0; | 5035 | return 0; |
| 5036 | } | 5036 | } |
| 5037 | 5037 | ||
| 5038 | static int smu7_power_off_asic(struct pp_hwmgr *hwmgr) | ||
| 5039 | { | ||
| 5040 | int result; | ||
| 5041 | |||
| 5042 | result = smu7_disable_dpm_tasks(hwmgr); | ||
| 5043 | PP_ASSERT_WITH_CODE((0 == result), | ||
| 5044 | "[disable_dpm_tasks] Failed to disable DPM!", | ||
| 5045 | ); | ||
| 5046 | |||
| 5047 | return result; | ||
| 5048 | } | ||
| 5049 | |||
| 5038 | static const struct pp_hwmgr_func smu7_hwmgr_funcs = { | 5050 | static const struct pp_hwmgr_func smu7_hwmgr_funcs = { |
| 5039 | .backend_init = &smu7_hwmgr_backend_init, | 5051 | .backend_init = &smu7_hwmgr_backend_init, |
| 5040 | .backend_fini = &smu7_hwmgr_backend_fini, | 5052 | .backend_fini = &smu7_hwmgr_backend_fini, |
| @@ -5092,6 +5104,7 @@ static const struct pp_hwmgr_func smu7_hwmgr_funcs = { | |||
| 5092 | .get_power_profile_mode = smu7_get_power_profile_mode, | 5104 | .get_power_profile_mode = smu7_get_power_profile_mode, |
| 5093 | .set_power_profile_mode = smu7_set_power_profile_mode, | 5105 | .set_power_profile_mode = smu7_set_power_profile_mode, |
| 5094 | .get_performance_level = smu7_get_performance_level, | 5106 | .get_performance_level = smu7_get_performance_level, |
| 5107 | .power_off_asic = smu7_power_off_asic, | ||
| 5095 | }; | 5108 | }; |
| 5096 | 5109 | ||
| 5097 | uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock, | 5110 | uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock, |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c index b8637049198d..53cf787560f7 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c | |||
| @@ -880,7 +880,7 @@ static int smu8_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input) | |||
| 880 | smu8_update_low_mem_pstate(hwmgr, input); | 880 | smu8_update_low_mem_pstate(hwmgr, input); |
| 881 | 881 | ||
| 882 | return 0; | 882 | return 0; |
| 883 | }; | 883 | } |
| 884 | 884 | ||
| 885 | 885 | ||
| 886 | static int smu8_setup_asic_task(struct pp_hwmgr *hwmgr) | 886 | static int smu8_setup_asic_task(struct pp_hwmgr *hwmgr) |
| @@ -934,14 +934,6 @@ static void smu8_reset_cc6_data(struct pp_hwmgr *hwmgr) | |||
| 934 | hw_data->cc6_settings.cpu_pstate_disable = false; | 934 | hw_data->cc6_settings.cpu_pstate_disable = false; |
| 935 | } | 935 | } |
| 936 | 936 | ||
| 937 | static int smu8_power_off_asic(struct pp_hwmgr *hwmgr) | ||
| 938 | { | ||
| 939 | smu8_power_up_display_clock_sys_pll(hwmgr); | ||
| 940 | smu8_clear_nb_dpm_flag(hwmgr); | ||
| 941 | smu8_reset_cc6_data(hwmgr); | ||
| 942 | return 0; | ||
| 943 | }; | ||
| 944 | |||
| 945 | static void smu8_program_voting_clients(struct pp_hwmgr *hwmgr) | 937 | static void smu8_program_voting_clients(struct pp_hwmgr *hwmgr) |
| 946 | { | 938 | { |
| 947 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, | 939 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, |
| @@ -1011,6 +1003,17 @@ static void smu8_reset_acp_boot_level(struct pp_hwmgr *hwmgr) | |||
| 1011 | data->acp_boot_level = 0xff; | 1003 | data->acp_boot_level = 0xff; |
| 1012 | } | 1004 | } |
| 1013 | 1005 | ||
| 1006 | static int smu8_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | ||
| 1007 | { | ||
| 1008 | smu8_program_voting_clients(hwmgr); | ||
| 1009 | if (smu8_start_dpm(hwmgr)) | ||
| 1010 | return -EINVAL; | ||
| 1011 | smu8_program_bootup_state(hwmgr); | ||
| 1012 | smu8_reset_acp_boot_level(hwmgr); | ||
| 1013 | |||
| 1014 | return 0; | ||
| 1015 | } | ||
| 1016 | |||
| 1014 | static int smu8_disable_dpm_tasks(struct pp_hwmgr *hwmgr) | 1017 | static int smu8_disable_dpm_tasks(struct pp_hwmgr *hwmgr) |
| 1015 | { | 1018 | { |
| 1016 | smu8_disable_nb_dpm(hwmgr); | 1019 | smu8_disable_nb_dpm(hwmgr); |
| @@ -1020,18 +1023,16 @@ static int smu8_disable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
| 1020 | return -EINVAL; | 1023 | return -EINVAL; |
| 1021 | 1024 | ||
| 1022 | return 0; | 1025 | return 0; |
| 1023 | }; | 1026 | } |
| 1024 | 1027 | ||
| 1025 | static int smu8_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | 1028 | static int smu8_power_off_asic(struct pp_hwmgr *hwmgr) |
| 1026 | { | 1029 | { |
| 1027 | smu8_program_voting_clients(hwmgr); | 1030 | smu8_disable_dpm_tasks(hwmgr); |
| 1028 | if (smu8_start_dpm(hwmgr)) | 1031 | smu8_power_up_display_clock_sys_pll(hwmgr); |
| 1029 | return -EINVAL; | 1032 | smu8_clear_nb_dpm_flag(hwmgr); |
| 1030 | smu8_program_bootup_state(hwmgr); | 1033 | smu8_reset_cc6_data(hwmgr); |
| 1031 | smu8_reset_acp_boot_level(hwmgr); | ||
| 1032 | |||
| 1033 | return 0; | 1034 | return 0; |
| 1034 | }; | 1035 | } |
| 1035 | 1036 | ||
| 1036 | static int smu8_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | 1037 | static int smu8_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, |
| 1037 | struct pp_power_state *prequest_ps, | 1038 | struct pp_power_state *prequest_ps, |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c index 2aab1b475945..8ad4e6960efd 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c | |||
| @@ -545,7 +545,7 @@ int phm_irq_process(struct amdgpu_device *adev, | |||
| 545 | uint32_t client_id = entry->client_id; | 545 | uint32_t client_id = entry->client_id; |
| 546 | uint32_t src_id = entry->src_id; | 546 | uint32_t src_id = entry->src_id; |
| 547 | 547 | ||
| 548 | if (client_id == AMDGPU_IH_CLIENTID_LEGACY) { | 548 | if (client_id == AMDGPU_IRQ_CLIENTID_LEGACY) { |
| 549 | if (src_id == VISLANDS30_IV_SRCID_CG_TSS_THERMAL_LOW_TO_HIGH) | 549 | if (src_id == VISLANDS30_IV_SRCID_CG_TSS_THERMAL_LOW_TO_HIGH) |
| 550 | pr_warn("GPU over temperature range detected on PCIe %d:%d.%d!\n", | 550 | pr_warn("GPU over temperature range detected on PCIe %d:%d.%d!\n", |
| 551 | PCI_BUS_NUM(adev->pdev->devfn), | 551 | PCI_BUS_NUM(adev->pdev->devfn), |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c index ca9be583fb62..419a1d77d661 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include "soc15_common.h" | 39 | #include "soc15_common.h" |
| 40 | #include "pppcielanes.h" | 40 | #include "pppcielanes.h" |
| 41 | #include "vega10_hwmgr.h" | 41 | #include "vega10_hwmgr.h" |
| 42 | #include "vega10_smumgr.h" | ||
| 42 | #include "vega10_processpptables.h" | 43 | #include "vega10_processpptables.h" |
| 43 | #include "vega10_pptable.h" | 44 | #include "vega10_pptable.h" |
| 44 | #include "vega10_thermal.h" | 45 | #include "vega10_thermal.h" |
| @@ -3713,6 +3714,11 @@ static int vega10_read_sensor(struct pp_hwmgr *hwmgr, int idx, | |||
| 3713 | SMUSVI0_PLANE0_CURRENTVID__CURRENT_SVI0_PLANE0_VID__SHIFT; | 3714 | SMUSVI0_PLANE0_CURRENTVID__CURRENT_SVI0_PLANE0_VID__SHIFT; |
| 3714 | *((uint32_t *)value) = (uint32_t)convert_to_vddc((uint8_t)val_vid); | 3715 | *((uint32_t *)value) = (uint32_t)convert_to_vddc((uint8_t)val_vid); |
| 3715 | return 0; | 3716 | return 0; |
| 3717 | case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK: | ||
| 3718 | ret = vega10_get_enabled_smc_features(hwmgr, (uint64_t *)value); | ||
| 3719 | if (!ret) | ||
| 3720 | *size = 8; | ||
| 3721 | break; | ||
| 3716 | default: | 3722 | default: |
| 3717 | ret = -EINVAL; | 3723 | ret = -EINVAL; |
| 3718 | break; | 3724 | break; |
| @@ -4940,16 +4946,6 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = { | |||
| 4940 | .get_performance_level = vega10_get_performance_level, | 4946 | .get_performance_level = vega10_get_performance_level, |
| 4941 | }; | 4947 | }; |
| 4942 | 4948 | ||
| 4943 | int vega10_enable_smc_features(struct pp_hwmgr *hwmgr, | ||
| 4944 | bool enable, uint32_t feature_mask) | ||
| 4945 | { | ||
| 4946 | int msg = enable ? PPSMC_MSG_EnableSmuFeatures : | ||
| 4947 | PPSMC_MSG_DisableSmuFeatures; | ||
| 4948 | |||
| 4949 | return smum_send_msg_to_smc_with_parameter(hwmgr, | ||
| 4950 | msg, feature_mask); | ||
| 4951 | } | ||
| 4952 | |||
| 4953 | int vega10_hwmgr_init(struct pp_hwmgr *hwmgr) | 4949 | int vega10_hwmgr_init(struct pp_hwmgr *hwmgr) |
| 4954 | { | 4950 | { |
| 4955 | hwmgr->hwmgr_func = &vega10_hwmgr_funcs; | 4951 | hwmgr->hwmgr_func = &vega10_hwmgr_funcs; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h index 339820da9e6a..89870556de1b 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h | |||
| @@ -441,7 +441,5 @@ int vega10_update_uvd_dpm(struct pp_hwmgr *hwmgr, bool bgate); | |||
| 441 | int vega10_update_samu_dpm(struct pp_hwmgr *hwmgr, bool bgate); | 441 | int vega10_update_samu_dpm(struct pp_hwmgr *hwmgr, bool bgate); |
| 442 | int vega10_update_acp_dpm(struct pp_hwmgr *hwmgr, bool bgate); | 442 | int vega10_update_acp_dpm(struct pp_hwmgr *hwmgr, bool bgate); |
| 443 | int vega10_enable_disable_vce_dpm(struct pp_hwmgr *hwmgr, bool enable); | 443 | int vega10_enable_disable_vce_dpm(struct pp_hwmgr *hwmgr, bool enable); |
| 444 | int vega10_enable_smc_features(struct pp_hwmgr *hwmgr, | ||
| 445 | bool enable, uint32_t feature_mask); | ||
| 446 | 444 | ||
| 447 | #endif /* _VEGA10_HWMGR_H_ */ | 445 | #endif /* _VEGA10_HWMGR_H_ */ |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c index 22364875a943..2d88abf97e7b 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | #include "hwmgr.h" | 24 | #include "hwmgr.h" |
| 25 | #include "vega10_hwmgr.h" | 25 | #include "vega10_hwmgr.h" |
| 26 | #include "vega10_smumgr.h" | ||
| 26 | #include "vega10_powertune.h" | 27 | #include "vega10_powertune.h" |
| 27 | #include "vega10_ppsmc.h" | 28 | #include "vega10_ppsmc.h" |
| 28 | #include "vega10_inc.h" | 29 | #include "vega10_inc.h" |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c index aa044c1955fe..407762b36901 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | #include "vega10_thermal.h" | 24 | #include "vega10_thermal.h" |
| 25 | #include "vega10_hwmgr.h" | 25 | #include "vega10_hwmgr.h" |
| 26 | #include "vega10_smumgr.h" | ||
| 26 | #include "vega10_ppsmc.h" | 27 | #include "vega10_ppsmc.h" |
| 27 | #include "vega10_inc.h" | 28 | #include "vega10_inc.h" |
| 28 | #include "soc15_common.h" | 29 | #include "soc15_common.h" |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c index 0789d64246ca..9600e2f226e9 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c | |||
| @@ -745,8 +745,8 @@ static int vega12_init_smc_table(struct pp_hwmgr *hwmgr) | |||
| 745 | 745 | ||
| 746 | memcpy(pp_table, pptable_information->smc_pptable, sizeof(PPTable_t)); | 746 | memcpy(pp_table, pptable_information->smc_pptable, sizeof(PPTable_t)); |
| 747 | 747 | ||
| 748 | result = vega12_copy_table_to_smc(hwmgr, | 748 | result = smum_smc_table_manager(hwmgr, |
| 749 | (uint8_t *)pp_table, TABLE_PPTABLE); | 749 | (uint8_t *)pp_table, TABLE_PPTABLE, false); |
| 750 | PP_ASSERT_WITH_CODE(!result, | 750 | PP_ASSERT_WITH_CODE(!result, |
| 751 | "Failed to upload PPtable!", return result); | 751 | "Failed to upload PPtable!", return result); |
| 752 | 752 | ||
| @@ -1317,7 +1317,11 @@ static int vega12_read_sensor(struct pp_hwmgr *hwmgr, int idx, | |||
| 1317 | break; | 1317 | break; |
| 1318 | case AMDGPU_PP_SENSOR_GPU_POWER: | 1318 | case AMDGPU_PP_SENSOR_GPU_POWER: |
| 1319 | ret = vega12_get_gpu_power(hwmgr, (uint32_t *)value); | 1319 | ret = vega12_get_gpu_power(hwmgr, (uint32_t *)value); |
| 1320 | 1320 | break; | |
| 1321 | case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK: | ||
| 1322 | ret = vega12_get_enabled_smc_features(hwmgr, (uint64_t *)value); | ||
| 1323 | if (!ret) | ||
| 1324 | *size = 8; | ||
| 1321 | break; | 1325 | break; |
| 1322 | default: | 1326 | default: |
| 1323 | ret = -EINVAL; | 1327 | ret = -EINVAL; |
| @@ -2103,8 +2107,8 @@ static int vega12_display_configuration_changed_task(struct pp_hwmgr *hwmgr) | |||
| 2103 | 2107 | ||
| 2104 | if ((data->water_marks_bitmap & WaterMarksExist) && | 2108 | if ((data->water_marks_bitmap & WaterMarksExist) && |
| 2105 | !(data->water_marks_bitmap & WaterMarksLoaded)) { | 2109 | !(data->water_marks_bitmap & WaterMarksLoaded)) { |
| 2106 | result = vega12_copy_table_to_smc(hwmgr, | 2110 | result = smum_smc_table_manager(hwmgr, |
| 2107 | (uint8_t *)wm_table, TABLE_WATERMARKS); | 2111 | (uint8_t *)wm_table, TABLE_WATERMARKS, false); |
| 2108 | PP_ASSERT_WITH_CODE(result, "Failed to update WMTABLE!", return EINVAL); | 2112 | PP_ASSERT_WITH_CODE(result, "Failed to update WMTABLE!", return EINVAL); |
| 2109 | data->water_marks_bitmap |= WaterMarksLoaded; | 2113 | data->water_marks_bitmap |= WaterMarksLoaded; |
| 2110 | } | 2114 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c index d45cbfe8e184..2a554f9edcda 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | |||
| @@ -461,7 +461,7 @@ static int vega20_get_number_of_dpm_level(struct pp_hwmgr *hwmgr, | |||
| 461 | "[GetNumOfDpmLevel] failed to get dpm levels!", | 461 | "[GetNumOfDpmLevel] failed to get dpm levels!", |
| 462 | return ret); | 462 | return ret); |
| 463 | 463 | ||
| 464 | vega20_read_arg_from_smc(hwmgr, num_of_levels); | 464 | *num_of_levels = smum_get_argument(hwmgr); |
| 465 | PP_ASSERT_WITH_CODE(*num_of_levels > 0, | 465 | PP_ASSERT_WITH_CODE(*num_of_levels > 0, |
| 466 | "[GetNumOfDpmLevel] number of clk levels is invalid!", | 466 | "[GetNumOfDpmLevel] number of clk levels is invalid!", |
| 467 | return -EINVAL); | 467 | return -EINVAL); |
| @@ -481,7 +481,7 @@ static int vega20_get_dpm_frequency_by_index(struct pp_hwmgr *hwmgr, | |||
| 481 | "[GetDpmFreqByIndex] failed to get dpm freq by index!", | 481 | "[GetDpmFreqByIndex] failed to get dpm freq by index!", |
| 482 | return ret); | 482 | return ret); |
| 483 | 483 | ||
| 484 | vega20_read_arg_from_smc(hwmgr, clk); | 484 | *clk = smum_get_argument(hwmgr); |
| 485 | PP_ASSERT_WITH_CODE(*clk, | 485 | PP_ASSERT_WITH_CODE(*clk, |
| 486 | "[GetDpmFreqByIndex] clk value is invalid!", | 486 | "[GetDpmFreqByIndex] clk value is invalid!", |
| 487 | return -EINVAL); | 487 | return -EINVAL); |
| @@ -743,8 +743,8 @@ static int vega20_init_smc_table(struct pp_hwmgr *hwmgr) | |||
| 743 | 743 | ||
| 744 | memcpy(pp_table, pptable_information->smc_pptable, sizeof(PPTable_t)); | 744 | memcpy(pp_table, pptable_information->smc_pptable, sizeof(PPTable_t)); |
| 745 | 745 | ||
| 746 | result = vega20_copy_table_to_smc(hwmgr, | 746 | result = smum_smc_table_manager(hwmgr, |
| 747 | (uint8_t *)pp_table, TABLE_PPTABLE); | 747 | (uint8_t *)pp_table, TABLE_PPTABLE, false); |
| 748 | PP_ASSERT_WITH_CODE(!result, | 748 | PP_ASSERT_WITH_CODE(!result, |
| 749 | "[InitSMCTable] Failed to upload PPtable!", | 749 | "[InitSMCTable] Failed to upload PPtable!", |
| 750 | return result); | 750 | return result); |
| @@ -1044,7 +1044,7 @@ static int vega20_od8_get_gfx_clock_base_voltage( | |||
| 1044 | "[GetBaseVoltage] failed to get GFXCLK AVFS voltage from SMU!", | 1044 | "[GetBaseVoltage] failed to get GFXCLK AVFS voltage from SMU!", |
| 1045 | return ret); | 1045 | return ret); |
| 1046 | 1046 | ||
| 1047 | vega20_read_arg_from_smc(hwmgr, voltage); | 1047 | *voltage = smum_get_argument(hwmgr); |
| 1048 | *voltage = *voltage / VOLTAGE_SCALE; | 1048 | *voltage = *voltage / VOLTAGE_SCALE; |
| 1049 | 1049 | ||
| 1050 | return 0; | 1050 | return 0; |
| @@ -1067,7 +1067,7 @@ static int vega20_od8_initialize_default_settings( | |||
| 1067 | vega20_od8_set_feature_id(hwmgr); | 1067 | vega20_od8_set_feature_id(hwmgr); |
| 1068 | 1068 | ||
| 1069 | /* Set default values */ | 1069 | /* Set default values */ |
| 1070 | ret = vega20_copy_table_from_smc(hwmgr, (uint8_t *)od_table, TABLE_OVERDRIVE); | 1070 | ret = smum_smc_table_manager(hwmgr, (uint8_t *)od_table, TABLE_OVERDRIVE, true); |
| 1071 | PP_ASSERT_WITH_CODE(!ret, | 1071 | PP_ASSERT_WITH_CODE(!ret, |
| 1072 | "Failed to export over drive table!", | 1072 | "Failed to export over drive table!", |
| 1073 | return ret); | 1073 | return ret); |
| @@ -1195,7 +1195,7 @@ static int vega20_od8_initialize_default_settings( | |||
| 1195 | } | 1195 | } |
| 1196 | } | 1196 | } |
| 1197 | 1197 | ||
| 1198 | ret = vega20_copy_table_to_smc(hwmgr, (uint8_t *)od_table, TABLE_OVERDRIVE); | 1198 | ret = smum_smc_table_manager(hwmgr, (uint8_t *)od_table, TABLE_OVERDRIVE, false); |
| 1199 | PP_ASSERT_WITH_CODE(!ret, | 1199 | PP_ASSERT_WITH_CODE(!ret, |
| 1200 | "Failed to import over drive table!", | 1200 | "Failed to import over drive table!", |
| 1201 | return ret); | 1201 | return ret); |
| @@ -1214,7 +1214,7 @@ static int vega20_od8_set_settings( | |||
| 1214 | struct vega20_od8_single_setting *od8_settings = | 1214 | struct vega20_od8_single_setting *od8_settings = |
| 1215 | data->od8_settings.od8_settings_array; | 1215 | data->od8_settings.od8_settings_array; |
| 1216 | 1216 | ||
| 1217 | ret = vega20_copy_table_from_smc(hwmgr, (uint8_t *)(&od_table), TABLE_OVERDRIVE); | 1217 | ret = smum_smc_table_manager(hwmgr, (uint8_t *)(&od_table), TABLE_OVERDRIVE, true); |
| 1218 | PP_ASSERT_WITH_CODE(!ret, | 1218 | PP_ASSERT_WITH_CODE(!ret, |
| 1219 | "Failed to export over drive table!", | 1219 | "Failed to export over drive table!", |
| 1220 | return ret); | 1220 | return ret); |
| @@ -1271,7 +1271,7 @@ static int vega20_od8_set_settings( | |||
| 1271 | break; | 1271 | break; |
| 1272 | } | 1272 | } |
| 1273 | 1273 | ||
| 1274 | ret = vega20_copy_table_to_smc(hwmgr, (uint8_t *)(&od_table), TABLE_OVERDRIVE); | 1274 | ret = smum_smc_table_manager(hwmgr, (uint8_t *)(&od_table), TABLE_OVERDRIVE, false); |
| 1275 | PP_ASSERT_WITH_CODE(!ret, | 1275 | PP_ASSERT_WITH_CODE(!ret, |
| 1276 | "Failed to import over drive table!", | 1276 | "Failed to import over drive table!", |
| 1277 | return ret); | 1277 | return ret); |
| @@ -1401,7 +1401,7 @@ static int vega20_get_max_sustainable_clock(struct pp_hwmgr *hwmgr, | |||
| 1401 | (clock_select << 16))) == 0, | 1401 | (clock_select << 16))) == 0, |
| 1402 | "[GetMaxSustainableClock] Failed to get max DC clock from SMC!", | 1402 | "[GetMaxSustainableClock] Failed to get max DC clock from SMC!", |
| 1403 | return ret); | 1403 | return ret); |
| 1404 | vega20_read_arg_from_smc(hwmgr, clock); | 1404 | *clock = smum_get_argument(hwmgr); |
| 1405 | 1405 | ||
| 1406 | /* if DC limit is zero, return AC limit */ | 1406 | /* if DC limit is zero, return AC limit */ |
| 1407 | if (*clock == 0) { | 1407 | if (*clock == 0) { |
| @@ -1410,7 +1410,7 @@ static int vega20_get_max_sustainable_clock(struct pp_hwmgr *hwmgr, | |||
| 1410 | (clock_select << 16))) == 0, | 1410 | (clock_select << 16))) == 0, |
| 1411 | "[GetMaxSustainableClock] failed to get max AC clock from SMC!", | 1411 | "[GetMaxSustainableClock] failed to get max AC clock from SMC!", |
| 1412 | return ret); | 1412 | return ret); |
| 1413 | vega20_read_arg_from_smc(hwmgr, clock); | 1413 | *clock = smum_get_argument(hwmgr); |
| 1414 | } | 1414 | } |
| 1415 | 1415 | ||
| 1416 | return 0; | 1416 | return 0; |
| @@ -1770,14 +1770,14 @@ static int vega20_get_clock_ranges(struct pp_hwmgr *hwmgr, | |||
| 1770 | PPSMC_MSG_GetMaxDpmFreq, (clock_select << 16))) == 0, | 1770 | PPSMC_MSG_GetMaxDpmFreq, (clock_select << 16))) == 0, |
| 1771 | "[GetClockRanges] Failed to get max clock from SMC!", | 1771 | "[GetClockRanges] Failed to get max clock from SMC!", |
| 1772 | return ret); | 1772 | return ret); |
| 1773 | vega20_read_arg_from_smc(hwmgr, clock); | 1773 | *clock = smum_get_argument(hwmgr); |
| 1774 | } else { | 1774 | } else { |
| 1775 | PP_ASSERT_WITH_CODE((ret = smum_send_msg_to_smc_with_parameter(hwmgr, | 1775 | PP_ASSERT_WITH_CODE((ret = smum_send_msg_to_smc_with_parameter(hwmgr, |
| 1776 | PPSMC_MSG_GetMinDpmFreq, | 1776 | PPSMC_MSG_GetMinDpmFreq, |
| 1777 | (clock_select << 16))) == 0, | 1777 | (clock_select << 16))) == 0, |
| 1778 | "[GetClockRanges] Failed to get min clock from SMC!", | 1778 | "[GetClockRanges] Failed to get min clock from SMC!", |
| 1779 | return ret); | 1779 | return ret); |
| 1780 | vega20_read_arg_from_smc(hwmgr, clock); | 1780 | *clock = smum_get_argument(hwmgr); |
| 1781 | } | 1781 | } |
| 1782 | 1782 | ||
| 1783 | return 0; | 1783 | return 0; |
| @@ -1841,7 +1841,7 @@ static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr, | |||
| 1841 | int ret = 0; | 1841 | int ret = 0; |
| 1842 | SmuMetrics_t metrics_table; | 1842 | SmuMetrics_t metrics_table; |
| 1843 | 1843 | ||
| 1844 | ret = vega20_copy_table_from_smc(hwmgr, (uint8_t *)&metrics_table, TABLE_SMU_METRICS); | 1844 | ret = smum_smc_table_manager(hwmgr, (uint8_t *)&metrics_table, TABLE_SMU_METRICS, true); |
| 1845 | PP_ASSERT_WITH_CODE(!ret, | 1845 | PP_ASSERT_WITH_CODE(!ret, |
| 1846 | "Failed to export SMU METRICS table!", | 1846 | "Failed to export SMU METRICS table!", |
| 1847 | return ret); | 1847 | return ret); |
| @@ -1862,7 +1862,7 @@ static int vega20_get_current_gfx_clk_freq(struct pp_hwmgr *hwmgr, uint32_t *gfx | |||
| 1862 | PPSMC_MSG_GetDpmClockFreq, (PPCLK_GFXCLK << 16))) == 0, | 1862 | PPSMC_MSG_GetDpmClockFreq, (PPCLK_GFXCLK << 16))) == 0, |
| 1863 | "[GetCurrentGfxClkFreq] Attempt to get Current GFXCLK Frequency Failed!", | 1863 | "[GetCurrentGfxClkFreq] Attempt to get Current GFXCLK Frequency Failed!", |
| 1864 | return ret); | 1864 | return ret); |
| 1865 | vega20_read_arg_from_smc(hwmgr, &gfx_clk); | 1865 | gfx_clk = smum_get_argument(hwmgr); |
| 1866 | 1866 | ||
| 1867 | *gfx_freq = gfx_clk * 100; | 1867 | *gfx_freq = gfx_clk * 100; |
| 1868 | 1868 | ||
| @@ -1880,7 +1880,7 @@ static int vega20_get_current_mclk_freq(struct pp_hwmgr *hwmgr, uint32_t *mclk_f | |||
| 1880 | PPSMC_MSG_GetDpmClockFreq, (PPCLK_UCLK << 16))) == 0, | 1880 | PPSMC_MSG_GetDpmClockFreq, (PPCLK_UCLK << 16))) == 0, |
| 1881 | "[GetCurrentMClkFreq] Attempt to get Current MCLK Frequency Failed!", | 1881 | "[GetCurrentMClkFreq] Attempt to get Current MCLK Frequency Failed!", |
| 1882 | return ret); | 1882 | return ret); |
| 1883 | vega20_read_arg_from_smc(hwmgr, &mem_clk); | 1883 | mem_clk = smum_get_argument(hwmgr); |
| 1884 | 1884 | ||
| 1885 | *mclk_freq = mem_clk * 100; | 1885 | *mclk_freq = mem_clk * 100; |
| 1886 | 1886 | ||
| @@ -1893,7 +1893,7 @@ static int vega20_get_current_activity_percent(struct pp_hwmgr *hwmgr, | |||
| 1893 | int ret = 0; | 1893 | int ret = 0; |
| 1894 | SmuMetrics_t metrics_table; | 1894 | SmuMetrics_t metrics_table; |
| 1895 | 1895 | ||
| 1896 | ret = vega20_copy_table_from_smc(hwmgr, (uint8_t *)&metrics_table, TABLE_SMU_METRICS); | 1896 | ret = smum_smc_table_manager(hwmgr, (uint8_t *)&metrics_table, TABLE_SMU_METRICS, true); |
| 1897 | PP_ASSERT_WITH_CODE(!ret, | 1897 | PP_ASSERT_WITH_CODE(!ret, |
| 1898 | "Failed to export SMU METRICS table!", | 1898 | "Failed to export SMU METRICS table!", |
| 1899 | return ret); | 1899 | return ret); |
| @@ -1941,6 +1941,11 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx, | |||
| 1941 | *size = 16; | 1941 | *size = 16; |
| 1942 | ret = vega20_get_gpu_power(hwmgr, (uint32_t *)value); | 1942 | ret = vega20_get_gpu_power(hwmgr, (uint32_t *)value); |
| 1943 | break; | 1943 | break; |
| 1944 | case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK: | ||
| 1945 | ret = vega20_get_enabled_smc_features(hwmgr, (uint64_t *)value); | ||
| 1946 | if (!ret) | ||
| 1947 | *size = 8; | ||
| 1948 | break; | ||
| 1944 | default: | 1949 | default: |
| 1945 | ret = -EINVAL; | 1950 | ret = -EINVAL; |
| 1946 | break; | 1951 | break; |
| @@ -2612,18 +2617,18 @@ static int vega20_odn_edit_dpm_table(struct pp_hwmgr *hwmgr, | |||
| 2612 | data->gfxclk_overdrive = false; | 2617 | data->gfxclk_overdrive = false; |
| 2613 | data->memclk_overdrive = false; | 2618 | data->memclk_overdrive = false; |
| 2614 | 2619 | ||
| 2615 | ret = vega20_copy_table_from_smc(hwmgr, | 2620 | ret = smum_smc_table_manager(hwmgr, |
| 2616 | (uint8_t *)od_table, | 2621 | (uint8_t *)od_table, |
| 2617 | TABLE_OVERDRIVE); | 2622 | TABLE_OVERDRIVE, true); |
| 2618 | PP_ASSERT_WITH_CODE(!ret, | 2623 | PP_ASSERT_WITH_CODE(!ret, |
| 2619 | "Failed to export overdrive table!", | 2624 | "Failed to export overdrive table!", |
| 2620 | return ret); | 2625 | return ret); |
| 2621 | break; | 2626 | break; |
| 2622 | 2627 | ||
| 2623 | case PP_OD_COMMIT_DPM_TABLE: | 2628 | case PP_OD_COMMIT_DPM_TABLE: |
| 2624 | ret = vega20_copy_table_to_smc(hwmgr, | 2629 | ret = smum_smc_table_manager(hwmgr, |
| 2625 | (uint8_t *)od_table, | 2630 | (uint8_t *)od_table, |
| 2626 | TABLE_OVERDRIVE); | 2631 | TABLE_OVERDRIVE, false); |
| 2627 | PP_ASSERT_WITH_CODE(!ret, | 2632 | PP_ASSERT_WITH_CODE(!ret, |
| 2628 | "Failed to import overdrive table!", | 2633 | "Failed to import overdrive table!", |
| 2629 | return ret); | 2634 | return ret); |
| @@ -2847,8 +2852,8 @@ static int vega20_display_configuration_changed_task(struct pp_hwmgr *hwmgr) | |||
| 2847 | 2852 | ||
| 2848 | if ((data->water_marks_bitmap & WaterMarksExist) && | 2853 | if ((data->water_marks_bitmap & WaterMarksExist) && |
| 2849 | !(data->water_marks_bitmap & WaterMarksLoaded)) { | 2854 | !(data->water_marks_bitmap & WaterMarksLoaded)) { |
| 2850 | result = vega20_copy_table_to_smc(hwmgr, | 2855 | result = smum_smc_table_manager(hwmgr, |
| 2851 | (uint8_t *)wm_table, TABLE_WATERMARKS); | 2856 | (uint8_t *)wm_table, TABLE_WATERMARKS, false); |
| 2852 | PP_ASSERT_WITH_CODE(!result, | 2857 | PP_ASSERT_WITH_CODE(!result, |
| 2853 | "Failed to update WMTABLE!", | 2858 | "Failed to update WMTABLE!", |
| 2854 | return result); | 2859 | return result); |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c index 2984ddd5428c..1c951a5d827d 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c | |||
| @@ -37,10 +37,7 @@ static int vega20_get_current_rpm(struct pp_hwmgr *hwmgr, uint32_t *current_rpm) | |||
| 37 | PPSMC_MSG_GetCurrentRpm)) == 0, | 37 | PPSMC_MSG_GetCurrentRpm)) == 0, |
| 38 | "Attempt to get current RPM from SMC Failed!", | 38 | "Attempt to get current RPM from SMC Failed!", |
| 39 | return ret); | 39 | return ret); |
| 40 | PP_ASSERT_WITH_CODE((ret = vega20_read_arg_from_smc(hwmgr, | 40 | *current_rpm = smum_get_argument(hwmgr); |
| 41 | current_rpm)) == 0, | ||
| 42 | "Attempt to read current RPM from SMC Failed!", | ||
| 43 | return ret); | ||
| 44 | 41 | ||
| 45 | return 0; | 42 | return 0; |
| 46 | } | 43 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c index f7e3bc22bb93..a74c5be1ec18 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c | |||
| @@ -724,11 +724,13 @@ static int smu8_start_smu(struct pp_hwmgr *hwmgr) | |||
| 724 | if (hwmgr->chip_id == CHIP_STONEY) | 724 | if (hwmgr->chip_id == CHIP_STONEY) |
| 725 | fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); | 725 | fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); |
| 726 | 726 | ||
| 727 | ret = smu8_request_smu_load_fw(hwmgr); | 727 | smu8_request_smu_load_fw(hwmgr); |
| 728 | if (ret) | ||
| 729 | pr_err("SMU firmware load failed\n"); | ||
| 730 | 728 | ||
| 731 | smu8_check_fw_load_finish(hwmgr, fw_to_check); | 729 | ret = smu8_check_fw_load_finish(hwmgr, fw_to_check); |
| 730 | if (ret) { | ||
| 731 | pr_err("SMU firmware load failed\n"); | ||
| 732 | return ret; | ||
| 733 | } | ||
| 732 | 734 | ||
| 733 | ret = smu8_load_mec_firmware(hwmgr); | 735 | ret = smu8_load_mec_firmware(hwmgr); |
| 734 | if (ret) | 736 | if (ret) |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c index 5d19115f410c..c81acc3192ad 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c | |||
| @@ -88,8 +88,18 @@ static int vega10_copy_table_to_smc(struct pp_hwmgr *hwmgr, | |||
| 88 | return 0; | 88 | return 0; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | static int vega10_get_smc_features(struct pp_hwmgr *hwmgr, | 91 | int vega10_enable_smc_features(struct pp_hwmgr *hwmgr, |
| 92 | uint32_t *features_enabled) | 92 | bool enable, uint32_t feature_mask) |
| 93 | { | ||
| 94 | int msg = enable ? PPSMC_MSG_EnableSmuFeatures : | ||
| 95 | PPSMC_MSG_DisableSmuFeatures; | ||
| 96 | |||
| 97 | return smum_send_msg_to_smc_with_parameter(hwmgr, | ||
| 98 | msg, feature_mask); | ||
| 99 | } | ||
| 100 | |||
| 101 | int vega10_get_enabled_smc_features(struct pp_hwmgr *hwmgr, | ||
| 102 | uint64_t *features_enabled) | ||
| 93 | { | 103 | { |
| 94 | if (features_enabled == NULL) | 104 | if (features_enabled == NULL) |
| 95 | return -EINVAL; | 105 | return -EINVAL; |
| @@ -102,9 +112,9 @@ static int vega10_get_smc_features(struct pp_hwmgr *hwmgr, | |||
| 102 | 112 | ||
| 103 | static bool vega10_is_dpm_running(struct pp_hwmgr *hwmgr) | 113 | static bool vega10_is_dpm_running(struct pp_hwmgr *hwmgr) |
| 104 | { | 114 | { |
| 105 | uint32_t features_enabled = 0; | 115 | uint64_t features_enabled = 0; |
| 106 | 116 | ||
| 107 | vega10_get_smc_features(hwmgr, &features_enabled); | 117 | vega10_get_enabled_smc_features(hwmgr, &features_enabled); |
| 108 | 118 | ||
| 109 | if (features_enabled & SMC_DPM_FEATURES) | 119 | if (features_enabled & SMC_DPM_FEATURES) |
| 110 | return true; | 120 | return true; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h index 424e868bc768..bad760f22624 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.h | |||
| @@ -42,6 +42,10 @@ struct vega10_smumgr { | |||
| 42 | struct smu_table_array smu_tables; | 42 | struct smu_table_array smu_tables; |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | int vega10_enable_smc_features(struct pp_hwmgr *hwmgr, | ||
| 46 | bool enable, uint32_t feature_mask); | ||
| 47 | int vega10_get_enabled_smc_features(struct pp_hwmgr *hwmgr, | ||
| 48 | uint64_t *features_enabled); | ||
| 45 | 49 | ||
| 46 | #endif | 50 | #endif |
| 47 | 51 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.c index 7f0e2109f40d..ddb801517667 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.c | |||
| @@ -37,8 +37,8 @@ | |||
| 37 | * @param hwmgr the address of the HW manager | 37 | * @param hwmgr the address of the HW manager |
| 38 | * @param table_id the driver's table ID to copy from | 38 | * @param table_id the driver's table ID to copy from |
| 39 | */ | 39 | */ |
| 40 | int vega12_copy_table_from_smc(struct pp_hwmgr *hwmgr, | 40 | static int vega12_copy_table_from_smc(struct pp_hwmgr *hwmgr, |
| 41 | uint8_t *table, int16_t table_id) | 41 | uint8_t *table, int16_t table_id) |
| 42 | { | 42 | { |
| 43 | struct vega12_smumgr *priv = | 43 | struct vega12_smumgr *priv = |
| 44 | (struct vega12_smumgr *)(hwmgr->smu_backend); | 44 | (struct vega12_smumgr *)(hwmgr->smu_backend); |
| @@ -75,8 +75,8 @@ int vega12_copy_table_from_smc(struct pp_hwmgr *hwmgr, | |||
| 75 | * @param hwmgr the address of the HW manager | 75 | * @param hwmgr the address of the HW manager |
| 76 | * @param table_id the table to copy from | 76 | * @param table_id the table to copy from |
| 77 | */ | 77 | */ |
| 78 | int vega12_copy_table_to_smc(struct pp_hwmgr *hwmgr, | 78 | static int vega12_copy_table_to_smc(struct pp_hwmgr *hwmgr, |
| 79 | uint8_t *table, int16_t table_id) | 79 | uint8_t *table, int16_t table_id) |
| 80 | { | 80 | { |
| 81 | struct vega12_smumgr *priv = | 81 | struct vega12_smumgr *priv = |
| 82 | (struct vega12_smumgr *)(hwmgr->smu_backend); | 82 | (struct vega12_smumgr *)(hwmgr->smu_backend); |
| @@ -351,6 +351,19 @@ static int vega12_start_smu(struct pp_hwmgr *hwmgr) | |||
| 351 | return 0; | 351 | return 0; |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | static int vega12_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, | ||
| 355 | uint16_t table_id, bool rw) | ||
| 356 | { | ||
| 357 | int ret; | ||
| 358 | |||
| 359 | if (rw) | ||
| 360 | ret = vega12_copy_table_from_smc(hwmgr, table, table_id); | ||
| 361 | else | ||
| 362 | ret = vega12_copy_table_to_smc(hwmgr, table, table_id); | ||
| 363 | |||
| 364 | return ret; | ||
| 365 | } | ||
| 366 | |||
| 354 | const struct pp_smumgr_func vega12_smu_funcs = { | 367 | const struct pp_smumgr_func vega12_smu_funcs = { |
| 355 | .smu_init = &vega12_smu_init, | 368 | .smu_init = &vega12_smu_init, |
| 356 | .smu_fini = &vega12_smu_fini, | 369 | .smu_fini = &vega12_smu_fini, |
| @@ -362,4 +375,5 @@ const struct pp_smumgr_func vega12_smu_funcs = { | |||
| 362 | .upload_pptable_settings = NULL, | 375 | .upload_pptable_settings = NULL, |
| 363 | .is_dpm_running = vega12_is_dpm_running, | 376 | .is_dpm_running = vega12_is_dpm_running, |
| 364 | .get_argument = smu9_get_argument, | 377 | .get_argument = smu9_get_argument, |
| 378 | .smc_table_manager = vega12_smc_table_manager, | ||
| 365 | }; | 379 | }; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.h index b285cbc04019..aeec965ce81f 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega12_smumgr.h | |||
| @@ -48,10 +48,6 @@ struct vega12_smumgr { | |||
| 48 | #define SMU_FEATURES_HIGH_MASK 0xFFFFFFFF00000000 | 48 | #define SMU_FEATURES_HIGH_MASK 0xFFFFFFFF00000000 |
| 49 | #define SMU_FEATURES_HIGH_SHIFT 32 | 49 | #define SMU_FEATURES_HIGH_SHIFT 32 |
| 50 | 50 | ||
| 51 | int vega12_copy_table_from_smc(struct pp_hwmgr *hwmgr, | ||
| 52 | uint8_t *table, int16_t table_id); | ||
| 53 | int vega12_copy_table_to_smc(struct pp_hwmgr *hwmgr, | ||
| 54 | uint8_t *table, int16_t table_id); | ||
| 55 | int vega12_enable_smc_features(struct pp_hwmgr *hwmgr, | 51 | int vega12_enable_smc_features(struct pp_hwmgr *hwmgr, |
| 56 | bool enable, uint64_t feature_mask); | 52 | bool enable, uint64_t feature_mask); |
| 57 | int vega12_get_enabled_smc_features(struct pp_hwmgr *hwmgr, | 53 | int vega12_get_enabled_smc_features(struct pp_hwmgr *hwmgr, |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.c index fe7f71079e0e..b7ff7d4d6f44 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.c | |||
| @@ -148,19 +148,11 @@ static int vega20_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr, | |||
| 148 | return (ret == PPSMC_Result_OK) ? 0 : -EIO; | 148 | return (ret == PPSMC_Result_OK) ? 0 : -EIO; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | /* | 151 | static uint32_t vega20_get_argument(struct pp_hwmgr *hwmgr) |
| 152 | * Retrieve an argument from SMC. | ||
| 153 | * @param hwmgr the address of the powerplay hardware manager. | ||
| 154 | * @param arg pointer to store the argument from SMC. | ||
| 155 | * @return Always return 0. | ||
| 156 | */ | ||
| 157 | int vega20_read_arg_from_smc(struct pp_hwmgr *hwmgr, uint32_t *arg) | ||
| 158 | { | 152 | { |
| 159 | struct amdgpu_device *adev = hwmgr->adev; | 153 | struct amdgpu_device *adev = hwmgr->adev; |
| 160 | 154 | ||
| 161 | *arg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_82); | 155 | return RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_82); |
| 162 | |||
| 163 | return 0; | ||
| 164 | } | 156 | } |
| 165 | 157 | ||
| 166 | /* | 158 | /* |
| @@ -168,8 +160,8 @@ int vega20_read_arg_from_smc(struct pp_hwmgr *hwmgr, uint32_t *arg) | |||
| 168 | * @param hwmgr the address of the HW manager | 160 | * @param hwmgr the address of the HW manager |
| 169 | * @param table_id the driver's table ID to copy from | 161 | * @param table_id the driver's table ID to copy from |
| 170 | */ | 162 | */ |
| 171 | int vega20_copy_table_from_smc(struct pp_hwmgr *hwmgr, | 163 | static int vega20_copy_table_from_smc(struct pp_hwmgr *hwmgr, |
| 172 | uint8_t *table, int16_t table_id) | 164 | uint8_t *table, int16_t table_id) |
| 173 | { | 165 | { |
| 174 | struct vega20_smumgr *priv = | 166 | struct vega20_smumgr *priv = |
| 175 | (struct vega20_smumgr *)(hwmgr->smu_backend); | 167 | (struct vega20_smumgr *)(hwmgr->smu_backend); |
| @@ -208,8 +200,8 @@ int vega20_copy_table_from_smc(struct pp_hwmgr *hwmgr, | |||
| 208 | * @param hwmgr the address of the HW manager | 200 | * @param hwmgr the address of the HW manager |
| 209 | * @param table_id the table to copy from | 201 | * @param table_id the table to copy from |
| 210 | */ | 202 | */ |
| 211 | int vega20_copy_table_to_smc(struct pp_hwmgr *hwmgr, | 203 | static int vega20_copy_table_to_smc(struct pp_hwmgr *hwmgr, |
| 212 | uint8_t *table, int16_t table_id) | 204 | uint8_t *table, int16_t table_id) |
| 213 | { | 205 | { |
| 214 | struct vega20_smumgr *priv = | 206 | struct vega20_smumgr *priv = |
| 215 | (struct vega20_smumgr *)(hwmgr->smu_backend); | 207 | (struct vega20_smumgr *)(hwmgr->smu_backend); |
| @@ -345,18 +337,12 @@ int vega20_get_enabled_smc_features(struct pp_hwmgr *hwmgr, | |||
| 345 | PPSMC_MSG_GetEnabledSmuFeaturesLow)) == 0, | 337 | PPSMC_MSG_GetEnabledSmuFeaturesLow)) == 0, |
| 346 | "[GetEnabledSMCFeatures] Attemp to get SMU features Low failed!", | 338 | "[GetEnabledSMCFeatures] Attemp to get SMU features Low failed!", |
| 347 | return ret); | 339 | return ret); |
| 348 | PP_ASSERT_WITH_CODE((ret = vega20_read_arg_from_smc(hwmgr, | 340 | smc_features_low = vega20_get_argument(hwmgr); |
| 349 | &smc_features_low)) == 0, | ||
| 350 | "[GetEnabledSMCFeatures] Attemp to read SMU features Low argument failed!", | ||
| 351 | return ret); | ||
| 352 | PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc(hwmgr, | 341 | PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc(hwmgr, |
| 353 | PPSMC_MSG_GetEnabledSmuFeaturesHigh)) == 0, | 342 | PPSMC_MSG_GetEnabledSmuFeaturesHigh)) == 0, |
| 354 | "[GetEnabledSMCFeatures] Attemp to get SMU features High failed!", | 343 | "[GetEnabledSMCFeatures] Attemp to get SMU features High failed!", |
| 355 | return ret); | 344 | return ret); |
| 356 | PP_ASSERT_WITH_CODE((ret = vega20_read_arg_from_smc(hwmgr, | 345 | smc_features_high = vega20_get_argument(hwmgr); |
| 357 | &smc_features_high)) == 0, | ||
| 358 | "[GetEnabledSMCFeatures] Attemp to read SMU features High argument failed!", | ||
| 359 | return ret); | ||
| 360 | 346 | ||
| 361 | *features_enabled = ((((uint64_t)smc_features_low << SMU_FEATURES_LOW_SHIFT) & SMU_FEATURES_LOW_MASK) | | 347 | *features_enabled = ((((uint64_t)smc_features_low << SMU_FEATURES_LOW_SHIFT) & SMU_FEATURES_LOW_MASK) | |
| 362 | (((uint64_t)smc_features_high << SMU_FEATURES_HIGH_SHIFT) & SMU_FEATURES_HIGH_MASK)); | 348 | (((uint64_t)smc_features_high << SMU_FEATURES_HIGH_SHIFT) & SMU_FEATURES_HIGH_MASK)); |
| @@ -574,6 +560,19 @@ static bool vega20_is_dpm_running(struct pp_hwmgr *hwmgr) | |||
| 574 | return false; | 560 | return false; |
| 575 | } | 561 | } |
| 576 | 562 | ||
| 563 | static int vega20_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, | ||
| 564 | uint16_t table_id, bool rw) | ||
| 565 | { | ||
| 566 | int ret; | ||
| 567 | |||
| 568 | if (rw) | ||
| 569 | ret = vega20_copy_table_from_smc(hwmgr, table, table_id); | ||
| 570 | else | ||
| 571 | ret = vega20_copy_table_to_smc(hwmgr, table, table_id); | ||
| 572 | |||
| 573 | return ret; | ||
| 574 | } | ||
| 575 | |||
| 577 | const struct pp_smumgr_func vega20_smu_funcs = { | 576 | const struct pp_smumgr_func vega20_smu_funcs = { |
| 578 | .smu_init = &vega20_smu_init, | 577 | .smu_init = &vega20_smu_init, |
| 579 | .smu_fini = &vega20_smu_fini, | 578 | .smu_fini = &vega20_smu_fini, |
| @@ -584,4 +583,6 @@ const struct pp_smumgr_func vega20_smu_funcs = { | |||
| 584 | .download_pptable_settings = NULL, | 583 | .download_pptable_settings = NULL, |
| 585 | .upload_pptable_settings = NULL, | 584 | .upload_pptable_settings = NULL, |
| 586 | .is_dpm_running = vega20_is_dpm_running, | 585 | .is_dpm_running = vega20_is_dpm_running, |
| 586 | .get_argument = vega20_get_argument, | ||
| 587 | .smc_table_manager = vega20_smc_table_manager, | ||
| 587 | }; | 588 | }; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.h index 505eb0d82e3b..77349c3f0162 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.h | |||
| @@ -47,11 +47,6 @@ struct vega20_smumgr { | |||
| 47 | #define SMU_FEATURES_HIGH_MASK 0xFFFFFFFF00000000 | 47 | #define SMU_FEATURES_HIGH_MASK 0xFFFFFFFF00000000 |
| 48 | #define SMU_FEATURES_HIGH_SHIFT 32 | 48 | #define SMU_FEATURES_HIGH_SHIFT 32 |
| 49 | 49 | ||
| 50 | int vega20_read_arg_from_smc(struct pp_hwmgr *hwmgr, uint32_t *arg); | ||
| 51 | int vega20_copy_table_from_smc(struct pp_hwmgr *hwmgr, | ||
| 52 | uint8_t *table, int16_t table_id); | ||
| 53 | int vega20_copy_table_to_smc(struct pp_hwmgr *hwmgr, | ||
| 54 | uint8_t *table, int16_t table_id); | ||
| 55 | int vega20_enable_smc_features(struct pp_hwmgr *hwmgr, | 50 | int vega20_enable_smc_features(struct pp_hwmgr *hwmgr, |
| 56 | bool enable, uint64_t feature_mask); | 51 | bool enable, uint64_t feature_mask); |
| 57 | int vega20_get_enabled_smc_features(struct pp_hwmgr *hwmgr, | 52 | int vega20_get_enabled_smc_features(struct pp_hwmgr *hwmgr, |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c b/drivers/gpu/drm/etnaviv/etnaviv_sched.c index 69e9b431bf1f..e7c3ed6c9a2e 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c | |||
| @@ -105,7 +105,7 @@ static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job) | |||
| 105 | change = dma_addr - gpu->hangcheck_dma_addr; | 105 | change = dma_addr - gpu->hangcheck_dma_addr; |
| 106 | if (change < 0 || change > 16) { | 106 | if (change < 0 || change > 16) { |
| 107 | gpu->hangcheck_dma_addr = dma_addr; | 107 | gpu->hangcheck_dma_addr = dma_addr; |
| 108 | schedule_delayed_work(&sched_job->work_tdr, | 108 | schedule_delayed_work(&sched_job->sched->work_tdr, |
| 109 | sched_job->sched->timeout); | 109 | sched_job->sched->timeout); |
| 110 | return; | 110 | return; |
| 111 | } | 111 | } |
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 9ca741f3a0bc..4e8505d51795 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c | |||
| @@ -197,19 +197,15 @@ static void drm_sched_job_finish(struct work_struct *work) | |||
| 197 | * manages to find this job as the next job in the list, the fence | 197 | * manages to find this job as the next job in the list, the fence |
| 198 | * signaled check below will prevent the timeout to be restarted. | 198 | * signaled check below will prevent the timeout to be restarted. |
| 199 | */ | 199 | */ |
| 200 | cancel_delayed_work_sync(&s_job->work_tdr); | 200 | cancel_delayed_work_sync(&sched->work_tdr); |
| 201 | 201 | ||
| 202 | spin_lock(&sched->job_list_lock); | 202 | spin_lock(&sched->job_list_lock); |
| 203 | /* queue TDR for next job */ | ||
| 204 | if (sched->timeout != MAX_SCHEDULE_TIMEOUT && | ||
| 205 | !list_is_last(&s_job->node, &sched->ring_mirror_list)) { | ||
| 206 | struct drm_sched_job *next = list_next_entry(s_job, node); | ||
| 207 | |||
| 208 | if (!dma_fence_is_signaled(&next->s_fence->finished)) | ||
| 209 | schedule_delayed_work(&next->work_tdr, sched->timeout); | ||
| 210 | } | ||
| 211 | /* remove job from ring_mirror_list */ | 203 | /* remove job from ring_mirror_list */ |
| 212 | list_del(&s_job->node); | 204 | list_del(&s_job->node); |
| 205 | /* queue TDR for next job */ | ||
| 206 | if (sched->timeout != MAX_SCHEDULE_TIMEOUT && | ||
| 207 | !list_empty(&sched->ring_mirror_list)) | ||
| 208 | schedule_delayed_work(&sched->work_tdr, sched->timeout); | ||
| 213 | spin_unlock(&sched->job_list_lock); | 209 | spin_unlock(&sched->job_list_lock); |
| 214 | 210 | ||
| 215 | dma_fence_put(&s_job->s_fence->finished); | 211 | dma_fence_put(&s_job->s_fence->finished); |
| @@ -236,16 +232,21 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job) | |||
| 236 | if (sched->timeout != MAX_SCHEDULE_TIMEOUT && | 232 | if (sched->timeout != MAX_SCHEDULE_TIMEOUT && |
| 237 | list_first_entry_or_null(&sched->ring_mirror_list, | 233 | list_first_entry_or_null(&sched->ring_mirror_list, |
| 238 | struct drm_sched_job, node) == s_job) | 234 | struct drm_sched_job, node) == s_job) |
| 239 | schedule_delayed_work(&s_job->work_tdr, sched->timeout); | 235 | schedule_delayed_work(&sched->work_tdr, sched->timeout); |
| 240 | spin_unlock(&sched->job_list_lock); | 236 | spin_unlock(&sched->job_list_lock); |
| 241 | } | 237 | } |
| 242 | 238 | ||
| 243 | static void drm_sched_job_timedout(struct work_struct *work) | 239 | static void drm_sched_job_timedout(struct work_struct *work) |
| 244 | { | 240 | { |
| 245 | struct drm_sched_job *job = container_of(work, struct drm_sched_job, | 241 | struct drm_gpu_scheduler *sched; |
| 246 | work_tdr.work); | 242 | struct drm_sched_job *job; |
| 243 | |||
| 244 | sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); | ||
| 245 | job = list_first_entry_or_null(&sched->ring_mirror_list, | ||
| 246 | struct drm_sched_job, node); | ||
| 247 | 247 | ||
| 248 | job->sched->ops->timedout_job(job); | 248 | if (job) |
| 249 | job->sched->ops->timedout_job(job); | ||
| 249 | } | 250 | } |
| 250 | 251 | ||
| 251 | /** | 252 | /** |
| @@ -315,7 +316,7 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) | |||
| 315 | s_job = list_first_entry_or_null(&sched->ring_mirror_list, | 316 | s_job = list_first_entry_or_null(&sched->ring_mirror_list, |
| 316 | struct drm_sched_job, node); | 317 | struct drm_sched_job, node); |
| 317 | if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT) | 318 | if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT) |
| 318 | schedule_delayed_work(&s_job->work_tdr, sched->timeout); | 319 | schedule_delayed_work(&sched->work_tdr, sched->timeout); |
| 319 | 320 | ||
| 320 | list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { | 321 | list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { |
| 321 | struct drm_sched_fence *s_fence = s_job->s_fence; | 322 | struct drm_sched_fence *s_fence = s_job->s_fence; |
| @@ -384,7 +385,6 @@ int drm_sched_job_init(struct drm_sched_job *job, | |||
| 384 | 385 | ||
| 385 | INIT_WORK(&job->finish_work, drm_sched_job_finish); | 386 | INIT_WORK(&job->finish_work, drm_sched_job_finish); |
| 386 | INIT_LIST_HEAD(&job->node); | 387 | INIT_LIST_HEAD(&job->node); |
| 387 | INIT_DELAYED_WORK(&job->work_tdr, drm_sched_job_timedout); | ||
| 388 | 388 | ||
| 389 | return 0; | 389 | return 0; |
| 390 | } | 390 | } |
| @@ -575,6 +575,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, | |||
| 575 | INIT_LIST_HEAD(&sched->ring_mirror_list); | 575 | INIT_LIST_HEAD(&sched->ring_mirror_list); |
| 576 | spin_lock_init(&sched->job_list_lock); | 576 | spin_lock_init(&sched->job_list_lock); |
| 577 | atomic_set(&sched->hw_rq_count, 0); | 577 | atomic_set(&sched->hw_rq_count, 0); |
| 578 | INIT_DELAYED_WORK(&sched->work_tdr, drm_sched_job_timedout); | ||
| 578 | atomic_set(&sched->num_jobs, 0); | 579 | atomic_set(&sched->num_jobs, 0); |
| 579 | atomic64_set(&sched->job_id_count, 0); | 580 | atomic64_set(&sched->job_id_count, 0); |
| 580 | 581 | ||
diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c index a5501581d96b..9243dea6e6ad 100644 --- a/drivers/gpu/drm/v3d/v3d_sched.c +++ b/drivers/gpu/drm/v3d/v3d_sched.c | |||
| @@ -168,7 +168,7 @@ v3d_job_timedout(struct drm_sched_job *sched_job) | |||
| 168 | job->timedout_ctca = ctca; | 168 | job->timedout_ctca = ctca; |
| 169 | job->timedout_ctra = ctra; | 169 | job->timedout_ctra = ctra; |
| 170 | 170 | ||
| 171 | schedule_delayed_work(&job->base.work_tdr, | 171 | schedule_delayed_work(&job->base.sched->work_tdr, |
| 172 | job->base.sched->timeout); | 172 | job->base.sched->timeout); |
| 173 | return; | 173 | return; |
| 174 | } | 174 | } |
