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

Merge branch 'drm-next-5.1' of git://people.freedesktop.org/~agd5f/linux into drm-next

Fixes for 5.1:
amdgpu:
- Fix missing fw declaration after dropping old CI DPM code
- Fix debugfs access to registers beyond the MMIO bar size
- Fix context priority handling
- Add missing license on some new files
- Various cleanups and bug fixes

radeon:
- Fix missing break in CS parser for evergreen
- Various cleanups and bug fixes

sched:
- Fix entities with 0 run queues

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

+704 -615
+2
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 411 411 struct amdgpu_ctx_mgr ctx_mgr; 412 412 }; 413 413 414 + int amdgpu_file_to_fpriv(struct file *filp, struct amdgpu_fpriv **fpriv); 415 + 414 416 int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, 415 417 unsigned size, struct amdgpu_ib *ib); 416 418 void amdgpu_ib_free(struct amdgpu_device *adev, struct amdgpu_ib *ib,
+17 -30
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
··· 131 131 132 132 void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) 133 133 { 134 - int i, n; 134 + int i; 135 135 int last_valid_bit; 136 136 137 137 if (adev->kfd.dev) { ··· 142 142 .gpuvm_size = min(adev->vm_manager.max_pfn 143 143 << AMDGPU_GPU_PAGE_SHIFT, 144 144 AMDGPU_GMC_HOLE_START), 145 - .drm_render_minor = adev->ddev->render->index 145 + .drm_render_minor = adev->ddev->render->index, 146 + .sdma_doorbell_idx = adev->doorbell_index.sdma_engine, 147 + 146 148 }; 147 149 148 150 /* this is going to have a few of the MSBs set that we need to ··· 174 172 &gpu_resources.doorbell_aperture_size, 175 173 &gpu_resources.doorbell_start_offset); 176 174 177 - if (adev->asic_type < CHIP_VEGA10) { 178 - kgd2kfd_device_init(adev->kfd.dev, &gpu_resources); 179 - return; 180 - } 181 - 182 - n = (adev->asic_type < CHIP_VEGA20) ? 2 : 8; 183 - 184 - for (i = 0; i < n; i += 2) { 185 - /* On SOC15 the BIF is involved in routing 186 - * doorbells using the low 12 bits of the 187 - * address. Communicate the assignments to 188 - * KFD. KFD uses two doorbell pages per 189 - * process in case of 64-bit doorbells so we 190 - * can use each doorbell assignment twice. 191 - */ 192 - gpu_resources.sdma_doorbell[0][i] = 193 - adev->doorbell_index.sdma_engine[0] + (i >> 1); 194 - gpu_resources.sdma_doorbell[0][i+1] = 195 - adev->doorbell_index.sdma_engine[0] + 0x200 + (i >> 1); 196 - gpu_resources.sdma_doorbell[1][i] = 197 - adev->doorbell_index.sdma_engine[1] + (i >> 1); 198 - gpu_resources.sdma_doorbell[1][i+1] = 199 - adev->doorbell_index.sdma_engine[1] + 0x200 + (i >> 1); 200 - } 201 - /* Doorbells 0x0e0-0ff and 0x2e0-2ff are reserved for 202 - * SDMA, IH and VCN. So don't use them for the CP. 175 + /* Since SOC15, BIF starts to statically use the 176 + * lower 12 bits of doorbell addresses for routing 177 + * based on settings in registers like 178 + * SDMA0_DOORBELL_RANGE etc.. 179 + * In order to route a doorbell to CP engine, the lower 180 + * 12 bits of its address has to be outside the range 181 + * set for SDMA, VCN, and IH blocks. 203 182 */ 204 - gpu_resources.reserved_doorbell_mask = 0x1e0; 205 - gpu_resources.reserved_doorbell_val = 0x0e0; 183 + if (adev->asic_type >= CHIP_VEGA10) { 184 + gpu_resources.non_cp_doorbells_start = 185 + adev->doorbell_index.first_non_cp; 186 + gpu_resources.non_cp_doorbells_end = 187 + adev->doorbell_index.last_non_cp; 188 + } 206 189 207 190 kgd2kfd_device_init(adev->kfd.dev, &gpu_resources); 208 191 }
+13 -125
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
··· 204 204 } 205 205 206 206 207 - /* amdgpu_amdkfd_remove_eviction_fence - Removes eviction fence(s) from BO's 207 + /* amdgpu_amdkfd_remove_eviction_fence - Removes eviction fence from BO's 208 208 * reservation object. 209 209 * 210 210 * @bo: [IN] Remove eviction fence(s) from this BO 211 - * @ef: [IN] If ef is specified, then this eviction fence is removed if it 211 + * @ef: [IN] This eviction fence is removed if it 212 212 * is present in the shared list. 213 - * @ef_list: [OUT] Returns list of eviction fences. These fences are removed 214 - * from BO's reservation object shared list. 215 - * @ef_count: [OUT] Number of fences in ef_list. 216 213 * 217 - * NOTE: If called with ef_list, then amdgpu_amdkfd_add_eviction_fence must be 218 - * called to restore the eviction fences and to avoid memory leak. This is 219 - * useful for shared BOs. 220 214 * NOTE: Must be called with BO reserved i.e. bo->tbo.resv->lock held. 221 215 */ 222 216 static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo, 223 - struct amdgpu_amdkfd_fence *ef, 224 - struct amdgpu_amdkfd_fence ***ef_list, 225 - unsigned int *ef_count) 217 + struct amdgpu_amdkfd_fence *ef) 226 218 { 227 219 struct reservation_object *resv = bo->tbo.resv; 228 220 struct reservation_object_list *old, *new; 229 221 unsigned int i, j, k; 230 222 231 - if (!ef && !ef_list) 223 + if (!ef) 232 224 return -EINVAL; 233 - 234 - if (ef_list) { 235 - *ef_list = NULL; 236 - *ef_count = 0; 237 - } 238 225 239 226 old = reservation_object_get_list(resv); 240 227 if (!old) ··· 241 254 f = rcu_dereference_protected(old->shared[i], 242 255 reservation_object_held(resv)); 243 256 244 - if ((ef && f->context == ef->base.context) || 245 - (!ef && to_amdgpu_amdkfd_fence(f))) 257 + if (f->context == ef->base.context) 246 258 RCU_INIT_POINTER(new->shared[--j], f); 247 259 else 248 260 RCU_INIT_POINTER(new->shared[k++], f); 249 261 } 250 262 new->shared_max = old->shared_max; 251 263 new->shared_count = k; 252 - 253 - if (!ef) { 254 - unsigned int count = old->shared_count - j; 255 - 256 - /* Alloc memory for count number of eviction fence pointers. 257 - * Fill the ef_list array and ef_count 258 - */ 259 - *ef_list = kcalloc(count, sizeof(**ef_list), GFP_KERNEL); 260 - *ef_count = count; 261 - 262 - if (!*ef_list) { 263 - kfree(new); 264 - return -ENOMEM; 265 - } 266 - } 267 264 268 265 /* Install the new fence list, seqcount provides the barriers */ 269 266 preempt_disable(); ··· 262 291 263 292 f = rcu_dereference_protected(new->shared[i], 264 293 reservation_object_held(resv)); 265 - if (!ef) 266 - (*ef_list)[k++] = to_amdgpu_amdkfd_fence(f); 267 - else 268 - dma_fence_put(f); 294 + dma_fence_put(f); 269 295 } 270 296 kfree_rcu(old, rcu); 271 297 272 298 return 0; 273 - } 274 - 275 - /* amdgpu_amdkfd_add_eviction_fence - Adds eviction fence(s) back into BO's 276 - * reservation object. 277 - * 278 - * @bo: [IN] Add eviction fences to this BO 279 - * @ef_list: [IN] List of eviction fences to be added 280 - * @ef_count: [IN] Number of fences in ef_list. 281 - * 282 - * NOTE: Must call amdgpu_amdkfd_remove_eviction_fence before calling this 283 - * function. 284 - */ 285 - static void amdgpu_amdkfd_add_eviction_fence(struct amdgpu_bo *bo, 286 - struct amdgpu_amdkfd_fence **ef_list, 287 - unsigned int ef_count) 288 - { 289 - int i; 290 - 291 - if (!ef_list || !ef_count) 292 - return; 293 - 294 - for (i = 0; i < ef_count; i++) { 295 - amdgpu_bo_fence(bo, &ef_list[i]->base, true); 296 - /* Re-adding the fence takes an additional reference. Drop that 297 - * reference. 298 - */ 299 - dma_fence_put(&ef_list[i]->base); 300 - } 301 - 302 - kfree(ef_list); 303 299 } 304 300 305 301 static int amdgpu_amdkfd_bo_validate(struct amdgpu_bo *bo, uint32_t domain, ··· 284 346 ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); 285 347 if (ret) 286 348 goto validate_fail; 287 - if (wait) { 288 - struct amdgpu_amdkfd_fence **ef_list; 289 - unsigned int ef_count; 290 - 291 - ret = amdgpu_amdkfd_remove_eviction_fence(bo, NULL, &ef_list, 292 - &ef_count); 293 - if (ret) 294 - goto validate_fail; 295 - 296 - ttm_bo_wait(&bo->tbo, false, false); 297 - amdgpu_amdkfd_add_eviction_fence(bo, ef_list, ef_count); 298 - } 349 + if (wait) 350 + amdgpu_bo_sync_wait(bo, AMDGPU_FENCE_OWNER_KFD, false); 299 351 300 352 validate_fail: 301 353 return ret; ··· 372 444 { 373 445 int ret; 374 446 struct kfd_bo_va_list *bo_va_entry; 375 - struct amdgpu_bo *pd = vm->root.base.bo; 376 447 struct amdgpu_bo *bo = mem->bo; 377 448 uint64_t va = mem->va; 378 449 struct list_head *list_bo_va = &mem->bo_va_list; ··· 411 484 *p_bo_va_entry = bo_va_entry; 412 485 413 486 /* Allocate new page tables if needed and validate 414 - * them. Clearing of new page tables and validate need to wait 415 - * on move fences. We don't want that to trigger the eviction 416 - * fence, so remove it temporarily. 487 + * them. 417 488 */ 418 - amdgpu_amdkfd_remove_eviction_fence(pd, 419 - vm->process_info->eviction_fence, 420 - NULL, NULL); 421 - 422 489 ret = amdgpu_vm_alloc_pts(adev, vm, va, amdgpu_bo_size(bo)); 423 490 if (ret) { 424 491 pr_err("Failed to allocate pts, err=%d\n", ret); ··· 425 504 goto err_alloc_pts; 426 505 } 427 506 428 - /* Add the eviction fence back */ 429 - amdgpu_bo_fence(pd, &vm->process_info->eviction_fence->base, true); 430 - 431 507 return 0; 432 508 433 509 err_alloc_pts: 434 - amdgpu_bo_fence(pd, &vm->process_info->eviction_fence->base, true); 435 510 amdgpu_vm_bo_rmv(adev, bo_va_entry->bo_va); 436 511 list_del(&bo_va_entry->bo_list); 437 512 err_vmadd: ··· 726 809 { 727 810 struct amdgpu_bo_va *bo_va = entry->bo_va; 728 811 struct amdgpu_vm *vm = bo_va->base.vm; 729 - struct amdgpu_bo *pd = vm->root.base.bo; 730 812 731 - /* Remove eviction fence from PD (and thereby from PTs too as 732 - * they share the resv. object). Otherwise during PT update 733 - * job (see amdgpu_vm_bo_update_mapping), eviction fence would 734 - * get added to job->sync object and job execution would 735 - * trigger the eviction fence. 736 - */ 737 - amdgpu_amdkfd_remove_eviction_fence(pd, 738 - vm->process_info->eviction_fence, 739 - NULL, NULL); 740 813 amdgpu_vm_bo_unmap(adev, bo_va, entry->va); 741 814 742 815 amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update); 743 - 744 - /* Add the eviction fence back */ 745 - amdgpu_bo_fence(pd, &vm->process_info->eviction_fence->base, true); 746 816 747 817 amdgpu_sync_fence(NULL, sync, bo_va->last_pt_update, false); 748 818 ··· 906 1002 pr_err("validate_pt_pd_bos() failed\n"); 907 1003 goto validate_pd_fail; 908 1004 } 909 - ret = ttm_bo_wait(&vm->root.base.bo->tbo, false, false); 1005 + amdgpu_bo_sync_wait(vm->root.base.bo, AMDGPU_FENCE_OWNER_KFD, false); 910 1006 if (ret) 911 1007 goto wait_pd_fail; 912 1008 amdgpu_bo_fence(vm->root.base.bo, ··· 1293 1389 * attached 1294 1390 */ 1295 1391 amdgpu_amdkfd_remove_eviction_fence(mem->bo, 1296 - process_info->eviction_fence, 1297 - NULL, NULL); 1392 + process_info->eviction_fence); 1298 1393 pr_debug("Release VA 0x%llx - 0x%llx\n", mem->va, 1299 1394 mem->va + bo_size * (1 + mem->aql_queue)); 1300 1395 ··· 1520 1617 if (mem->mapped_to_gpu_memory == 0 && 1521 1618 !amdgpu_ttm_tt_get_usermm(mem->bo->tbo.ttm) && !mem->bo->pin_count) 1522 1619 amdgpu_amdkfd_remove_eviction_fence(mem->bo, 1523 - process_info->eviction_fence, 1524 - NULL, NULL); 1620 + process_info->eviction_fence); 1525 1621 1526 1622 unreserve_out: 1527 1623 unreserve_bo_and_vms(&ctx, false, false); ··· 1581 1679 } 1582 1680 1583 1681 amdgpu_amdkfd_remove_eviction_fence( 1584 - bo, mem->process_info->eviction_fence, NULL, NULL); 1682 + bo, mem->process_info->eviction_fence); 1585 1683 list_del_init(&mem->validate_list.head); 1586 1684 1587 1685 if (size) ··· 1847 1945 1848 1946 amdgpu_sync_create(&sync); 1849 1947 1850 - /* Avoid triggering eviction fences when unmapping invalid 1851 - * userptr BOs (waits for all fences, doesn't use 1852 - * FENCE_OWNER_VM) 1853 - */ 1854 - list_for_each_entry(peer_vm, &process_info->vm_list_head, 1855 - vm_list_node) 1856 - amdgpu_amdkfd_remove_eviction_fence(peer_vm->root.base.bo, 1857 - process_info->eviction_fence, 1858 - NULL, NULL); 1859 - 1860 1948 ret = process_validate_vms(process_info); 1861 1949 if (ret) 1862 1950 goto unreserve_out; ··· 1907 2015 ret = process_update_pds(process_info, &sync); 1908 2016 1909 2017 unreserve_out: 1910 - list_for_each_entry(peer_vm, &process_info->vm_list_head, 1911 - vm_list_node) 1912 - amdgpu_bo_fence(peer_vm->root.base.bo, 1913 - &process_info->eviction_fence->base, true); 1914 2018 ttm_eu_backoff_reservation(&ticket, &resv_list); 1915 2019 amdgpu_sync_wait(&sync, false); 1916 2020 amdgpu_sync_free(&sync);
+8 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
··· 124 124 struct amdgpu_ring *rings[AMDGPU_MAX_RINGS]; 125 125 struct drm_sched_rq *rqs[AMDGPU_MAX_RINGS]; 126 126 unsigned num_rings; 127 + unsigned num_rqs = 0; 127 128 128 129 switch (i) { 129 130 case AMDGPU_HW_IP_GFX: ··· 167 166 break; 168 167 } 169 168 170 - for (j = 0; j < num_rings; ++j) 171 - rqs[j] = &rings[j]->sched.sched_rq[priority]; 169 + for (j = 0; j < num_rings; ++j) { 170 + if (!rings[j]->adev) 171 + continue; 172 + 173 + rqs[num_rqs++] = &rings[j]->sched.sched_rq[priority]; 174 + } 172 175 173 176 for (j = 0; j < amdgpu_ctx_num_entities[i]; ++j) 174 177 r = drm_sched_entity_init(&ctx->entities[i][j].entity, 175 - rqs, num_rings, &ctx->guilty); 178 + rqs, num_rqs, &ctx->guilty); 176 179 if (r) 177 180 goto error_cleanup_entities; 178 181 }
-3
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
··· 158 158 while (size) { 159 159 uint32_t value; 160 160 161 - if (*pos > adev->rmmio_size) 162 - goto end; 163 - 164 161 if (read) { 165 162 value = RREG32(*pos >> 2); 166 163 r = put_user(value, (uint32_t *)buf);
+9
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h
··· 71 71 uint32_t vce_ring6_7; 72 72 } uvd_vce; 73 73 }; 74 + uint32_t first_non_cp; 75 + uint32_t last_non_cp; 74 76 uint32_t max_assignment; 75 77 /* Per engine SDMA doorbell size in dword */ 76 78 uint32_t sdma_doorbell_range; ··· 145 143 AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3 = 0x18D, 146 144 AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5 = 0x18E, 147 145 AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 = 0x18F, 146 + 147 + AMDGPU_VEGA20_DOORBELL64_FIRST_NON_CP = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE0, 148 + AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP = AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7, 149 + 148 150 AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT = 0x18F, 149 151 AMDGPU_VEGA20_DOORBELL_INVALID = 0xFFFF 150 152 } AMDGPU_VEGA20_DOORBELL_ASSIGNMENT; ··· 227 221 AMDGPU_DOORBELL64_VCE_RING2_3 = 0xFD, 228 222 AMDGPU_DOORBELL64_VCE_RING4_5 = 0xFE, 229 223 AMDGPU_DOORBELL64_VCE_RING6_7 = 0xFF, 224 + 225 + AMDGPU_DOORBELL64_FIRST_NON_CP = AMDGPU_DOORBELL64_sDMA_ENGINE0, 226 + AMDGPU_DOORBELL64_LAST_NON_CP = AMDGPU_DOORBELL64_VCE_RING6_7, 230 227 231 228 AMDGPU_DOORBELL64_MAX_ASSIGNMENT = 0xFF, 232 229 AMDGPU_DOORBELL64_INVALID = 0xFFFF
-88
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
··· 184 184 return vrefresh; 185 185 } 186 186 187 - void amdgpu_calculate_u_and_p(u32 i, u32 r_c, u32 p_b, 188 - u32 *p, u32 *u) 189 - { 190 - u32 b_c = 0; 191 - u32 i_c; 192 - u32 tmp; 193 - 194 - i_c = (i * r_c) / 100; 195 - tmp = i_c >> p_b; 196 - 197 - while (tmp) { 198 - b_c++; 199 - tmp >>= 1; 200 - } 201 - 202 - *u = (b_c + 1) / 2; 203 - *p = i_c / (1 << (2 * (*u))); 204 - } 205 - 206 - int amdgpu_calculate_at(u32 t, u32 h, u32 fh, u32 fl, u32 *tl, u32 *th) 207 - { 208 - u32 k, a, ah, al; 209 - u32 t1; 210 - 211 - if ((fl == 0) || (fh == 0) || (fl > fh)) 212 - return -EINVAL; 213 - 214 - k = (100 * fh) / fl; 215 - t1 = (t * (k - 100)); 216 - a = (1000 * (100 * h + t1)) / (10000 + (t1 / 100)); 217 - a = (a + 5) / 10; 218 - ah = ((a * t) + 5000) / 10000; 219 - al = a - ah; 220 - 221 - *th = t - ah; 222 - *tl = t + al; 223 - 224 - return 0; 225 - } 226 - 227 - bool amdgpu_is_uvd_state(u32 class, u32 class2) 228 - { 229 - if (class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) 230 - return true; 231 - if (class & ATOM_PPLIB_CLASSIFICATION_HD2STATE) 232 - return true; 233 - if (class & ATOM_PPLIB_CLASSIFICATION_HDSTATE) 234 - return true; 235 - if (class & ATOM_PPLIB_CLASSIFICATION_SDSTATE) 236 - return true; 237 - if (class2 & ATOM_PPLIB_CLASSIFICATION2_MVC) 238 - return true; 239 - return false; 240 - } 241 - 242 187 bool amdgpu_is_internal_thermal_sensor(enum amdgpu_int_thermal_type sensor) 243 188 { 244 189 switch (sensor) { ··· 892 947 return AMDGPU_PCIE_GEN1; 893 948 } 894 949 return AMDGPU_PCIE_GEN1; 895 - } 896 - 897 - u16 amdgpu_get_pcie_lane_support(struct amdgpu_device *adev, 898 - u16 asic_lanes, 899 - u16 default_lanes) 900 - { 901 - switch (asic_lanes) { 902 - case 0: 903 - default: 904 - return default_lanes; 905 - case 1: 906 - return 1; 907 - case 2: 908 - return 2; 909 - case 4: 910 - return 4; 911 - case 8: 912 - return 8; 913 - case 12: 914 - return 12; 915 - case 16: 916 - return 16; 917 - } 918 - } 919 - 920 - u8 amdgpu_encode_pci_lane_width(u32 lanes) 921 - { 922 - u8 encoded_lanes[] = { 0, 1, 2, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6 }; 923 - 924 - if (lanes > 16) 925 - return 0; 926 - 927 - return encoded_lanes[lanes]; 928 950 } 929 951 930 952 struct amd_vce_state*
-9
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
··· 486 486 u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev); 487 487 u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev); 488 488 void amdgpu_dpm_get_active_displays(struct amdgpu_device *adev); 489 - bool amdgpu_is_uvd_state(u32 class, u32 class2); 490 - void amdgpu_calculate_u_and_p(u32 i, u32 r_c, u32 p_b, 491 - u32 *p, u32 *u); 492 - int amdgpu_calculate_at(u32 t, u32 h, u32 fh, u32 fl, u32 *tl, u32 *th); 493 489 494 490 bool amdgpu_is_internal_thermal_sensor(enum amdgpu_int_thermal_type sensor); 495 491 ··· 500 504 u32 sys_mask, 501 505 enum amdgpu_pcie_gen asic_gen, 502 506 enum amdgpu_pcie_gen default_gen); 503 - 504 - u16 amdgpu_get_pcie_lane_support(struct amdgpu_device *adev, 505 - u16 asic_lanes, 506 - u16 default_lanes); 507 - u8 amdgpu_encode_pci_lane_width(u32 lanes); 508 507 509 508 struct amd_vce_state* 510 509 amdgpu_get_vce_clock_state(void *handle, u32 idx);
+18 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 73 73 * - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation. 74 74 * - 3.28.0 - Add AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 75 75 * - 3.29.0 - Add AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID 76 + * - 3.30.0 - Add AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE. 76 77 */ 77 78 #define KMS_DRIVER_MAJOR 3 78 - #define KMS_DRIVER_MINOR 29 79 + #define KMS_DRIVER_MINOR 30 79 80 #define KMS_DRIVER_PATCHLEVEL 0 80 81 81 82 int amdgpu_vram_limit = 0; ··· 1178 1177 .compat_ioctl = amdgpu_kms_compat_ioctl, 1179 1178 #endif 1180 1179 }; 1180 + 1181 + int amdgpu_file_to_fpriv(struct file *filp, struct amdgpu_fpriv **fpriv) 1182 + { 1183 + struct drm_file *file; 1184 + 1185 + if (!filp) 1186 + return -EINVAL; 1187 + 1188 + if (filp->f_op != &amdgpu_driver_kms_fops) { 1189 + return -EINVAL; 1190 + } 1191 + 1192 + file = filp->private_data; 1193 + *fpriv = file->driver_priv; 1194 + return 0; 1195 + } 1181 1196 1182 1197 static bool 1183 1198 amdgpu_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
+2 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c
··· 140 140 * Interrupt hander (VI), walk the IH ring. 141 141 * Returns irq process return code. 142 142 */ 143 - int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, 144 - void (*callback)(struct amdgpu_device *adev, 145 - struct amdgpu_ih_ring *ih)) 143 + int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih) 146 144 { 147 145 u32 wptr; 148 146 ··· 160 162 rmb(); 161 163 162 164 while (ih->rptr != wptr) { 163 - callback(adev, ih); 165 + amdgpu_irq_dispatch(adev, ih); 164 166 ih->rptr &= ih->ptr_mask; 165 167 } 166 168
+1 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h
··· 69 69 int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, 70 70 unsigned ring_size, bool use_bus_addr); 71 71 void amdgpu_ih_ring_fini(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih); 72 - int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, 73 - void (*callback)(struct amdgpu_device *adev, 74 - struct amdgpu_ih_ring *ih)); 72 + int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih); 75 73 76 74 #endif
+17 -31
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
··· 131 131 } 132 132 133 133 /** 134 - * amdgpu_irq_callback - callback from the IH ring 135 - * 136 - * @adev: amdgpu device pointer 137 - * @ih: amdgpu ih ring 138 - * 139 - * Callback from IH ring processing to handle the entry at the current position 140 - * and advance the read pointer. 141 - */ 142 - static void amdgpu_irq_callback(struct amdgpu_device *adev, 143 - struct amdgpu_ih_ring *ih) 144 - { 145 - u32 ring_index = ih->rptr >> 2; 146 - struct amdgpu_iv_entry entry; 147 - 148 - entry.iv_entry = (const uint32_t *)&ih->ring[ring_index]; 149 - amdgpu_ih_decode_iv(adev, &entry); 150 - 151 - trace_amdgpu_iv(ih - &adev->irq.ih, &entry); 152 - 153 - amdgpu_irq_dispatch(adev, &entry); 154 - } 155 - 156 - /** 157 134 * amdgpu_irq_handler - IRQ handler 158 135 * 159 136 * @irq: IRQ number (unused) ··· 147 170 struct amdgpu_device *adev = dev->dev_private; 148 171 irqreturn_t ret; 149 172 150 - ret = amdgpu_ih_process(adev, &adev->irq.ih, amdgpu_irq_callback); 173 + ret = amdgpu_ih_process(adev, &adev->irq.ih); 151 174 if (ret == IRQ_HANDLED) 152 175 pm_runtime_mark_last_busy(dev->dev); 153 176 return ret; ··· 165 188 struct amdgpu_device *adev = container_of(work, struct amdgpu_device, 166 189 irq.ih1_work); 167 190 168 - amdgpu_ih_process(adev, &adev->irq.ih1, amdgpu_irq_callback); 191 + amdgpu_ih_process(adev, &adev->irq.ih1); 169 192 } 170 193 171 194 /** ··· 180 203 struct amdgpu_device *adev = container_of(work, struct amdgpu_device, 181 204 irq.ih2_work); 182 205 183 - amdgpu_ih_process(adev, &adev->irq.ih2, amdgpu_irq_callback); 206 + amdgpu_ih_process(adev, &adev->irq.ih2); 184 207 } 185 208 186 209 /** ··· 371 394 * Dispatches IRQ to IP blocks. 372 395 */ 373 396 void amdgpu_irq_dispatch(struct amdgpu_device *adev, 374 - struct amdgpu_iv_entry *entry) 397 + struct amdgpu_ih_ring *ih) 375 398 { 376 - unsigned client_id = entry->client_id; 377 - unsigned src_id = entry->src_id; 399 + u32 ring_index = ih->rptr >> 2; 400 + struct amdgpu_iv_entry entry; 401 + unsigned client_id, src_id; 378 402 struct amdgpu_irq_src *src; 379 403 bool handled = false; 380 404 int r; 405 + 406 + entry.iv_entry = (const uint32_t *)&ih->ring[ring_index]; 407 + amdgpu_ih_decode_iv(adev, &entry); 408 + 409 + trace_amdgpu_iv(ih - &adev->irq.ih, &entry); 410 + 411 + client_id = entry.client_id; 412 + src_id = entry.src_id; 381 413 382 414 if (client_id >= AMDGPU_IRQ_CLIENTID_MAX) { 383 415 DRM_DEBUG("Invalid client_id in IV: %d\n", client_id); ··· 402 416 client_id, src_id); 403 417 404 418 } else if ((src = adev->irq.client[client_id].sources[src_id])) { 405 - r = src->funcs->process(adev, src, entry); 419 + r = src->funcs->process(adev, src, &entry); 406 420 if (r < 0) 407 421 DRM_ERROR("error processing interrupt (%d)\n", r); 408 422 else if (r) ··· 414 428 415 429 /* Send it to amdkfd as well if it isn't already handled */ 416 430 if (!handled) 417 - amdgpu_amdkfd_interrupt(adev, entry->iv_entry); 431 + amdgpu_amdkfd_interrupt(adev, entry.iv_entry); 418 432 } 419 433 420 434 /**
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h
··· 108 108 unsigned client_id, unsigned src_id, 109 109 struct amdgpu_irq_src *source); 110 110 void amdgpu_irq_dispatch(struct amdgpu_device *adev, 111 - struct amdgpu_iv_entry *entry); 111 + struct amdgpu_ih_ring *ih); 112 112 int amdgpu_irq_update(struct amdgpu_device *adev, struct amdgpu_irq_src *src, 113 113 unsigned type); 114 114 int amdgpu_irq_get(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
··· 207 207 if (!r) { 208 208 acpi_status = amdgpu_acpi_init(adev); 209 209 if (acpi_status) 210 - dev_dbg(&dev->pdev->dev, 210 + dev_dbg(&dev->pdev->dev, 211 211 "Error during ACPI methods call\n"); 212 212 } 213 213
+24
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 1285 1285 } 1286 1286 1287 1287 /** 1288 + * amdgpu_sync_wait_resv - Wait for BO reservation fences 1289 + * 1290 + * @bo: buffer object 1291 + * @owner: fence owner 1292 + * @intr: Whether the wait is interruptible 1293 + * 1294 + * Returns: 1295 + * 0 on success, errno otherwise. 1296 + */ 1297 + int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr) 1298 + { 1299 + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 1300 + struct amdgpu_sync sync; 1301 + int r; 1302 + 1303 + amdgpu_sync_create(&sync); 1304 + amdgpu_sync_resv(adev, &sync, bo->tbo.resv, owner, false); 1305 + r = amdgpu_sync_wait(&sync, intr); 1306 + amdgpu_sync_free(&sync); 1307 + 1308 + return r; 1309 + } 1310 + 1311 + /** 1288 1312 * amdgpu_bo_gpu_offset - return GPU offset of bo 1289 1313 * @bo: amdgpu object for which we query the offset 1290 1314 *
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
··· 266 266 int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo); 267 267 void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence, 268 268 bool shared); 269 + int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr); 269 270 u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo); 270 271 int amdgpu_bo_validate(struct amdgpu_bo *bo); 271 272 int amdgpu_bo_restore_shadow(struct amdgpu_bo *shadow,
+47 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
··· 54 54 enum drm_sched_priority priority) 55 55 { 56 56 struct file *filp = fget(fd); 57 - struct drm_file *file; 58 57 struct amdgpu_fpriv *fpriv; 59 58 struct amdgpu_ctx *ctx; 60 59 uint32_t id; 60 + int r; 61 61 62 62 if (!filp) 63 63 return -EINVAL; 64 64 65 - file = filp->private_data; 66 - fpriv = file->driver_priv; 65 + r = amdgpu_file_to_fpriv(filp, &fpriv); 66 + if (r) { 67 + fput(filp); 68 + return r; 69 + } 70 + 67 71 idr_for_each_entry(&fpriv->ctx_mgr.ctx_handles, ctx, id) 68 72 amdgpu_ctx_priority_override(ctx, priority); 69 73 74 + fput(filp); 75 + 76 + return 0; 77 + } 78 + 79 + static int amdgpu_sched_context_priority_override(struct amdgpu_device *adev, 80 + int fd, 81 + unsigned ctx_id, 82 + enum drm_sched_priority priority) 83 + { 84 + struct file *filp = fget(fd); 85 + struct amdgpu_fpriv *fpriv; 86 + struct amdgpu_ctx *ctx; 87 + int r; 88 + 89 + if (!filp) 90 + return -EINVAL; 91 + 92 + r = amdgpu_file_to_fpriv(filp, &fpriv); 93 + if (r) { 94 + fput(filp); 95 + return r; 96 + } 97 + 98 + ctx = amdgpu_ctx_get(fpriv, ctx_id); 99 + 100 + if (!ctx) { 101 + fput(filp); 102 + return -EINVAL; 103 + } 104 + 105 + amdgpu_ctx_priority_override(ctx, priority); 106 + amdgpu_ctx_put(ctx); 70 107 fput(filp); 71 108 72 109 return 0; ··· 118 81 int r; 119 82 120 83 priority = amdgpu_to_sched_priority(args->in.priority); 121 - if (args->in.flags || priority == DRM_SCHED_PRIORITY_INVALID) 84 + if (priority == DRM_SCHED_PRIORITY_INVALID) 122 85 return -EINVAL; 123 86 124 87 switch (args->in.op) { 125 88 case AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE: 126 89 r = amdgpu_sched_process_priority_override(adev, 127 90 args->in.fd, 91 + priority); 92 + break; 93 + case AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE: 94 + r = amdgpu_sched_context_priority_override(adev, 95 + args->in.fd, 96 + args->in.ctx_id, 128 97 priority); 129 98 break; 130 99 default:
+6 -32
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 698 698 struct amdgpu_vm_bo_base *bo_base, *tmp; 699 699 int r = 0; 700 700 701 - vm->bulk_moveable &= list_empty(&vm->evicted); 702 - 703 701 list_for_each_entry_safe(bo_base, tmp, &vm->evicted, vm_status) { 704 702 struct amdgpu_bo *bo = bo_base->bo; 705 703 ··· 826 828 827 829 WARN_ON(job->ibs[0].length_dw > 64); 828 830 r = amdgpu_sync_resv(adev, &job->sync, bo->tbo.resv, 829 - AMDGPU_FENCE_OWNER_UNDEFINED, false); 831 + AMDGPU_FENCE_OWNER_KFD, false); 830 832 if (r) 831 833 goto error_free; 832 834 ··· 1330 1332 } 1331 1333 } 1332 1334 1333 - 1334 - /** 1335 - * amdgpu_vm_wait_pd - Wait for PT BOs to be free. 1336 - * 1337 - * @adev: amdgpu_device pointer 1338 - * @vm: related vm 1339 - * @owner: fence owner 1340 - * 1341 - * Returns: 1342 - * 0 on success, errno otherwise. 1343 - */ 1344 - static int amdgpu_vm_wait_pd(struct amdgpu_device *adev, struct amdgpu_vm *vm, 1345 - void *owner) 1346 - { 1347 - struct amdgpu_sync sync; 1348 - int r; 1349 - 1350 - amdgpu_sync_create(&sync); 1351 - amdgpu_sync_resv(adev, &sync, vm->root.base.bo->tbo.resv, owner, false); 1352 - r = amdgpu_sync_wait(&sync, true); 1353 - amdgpu_sync_free(&sync); 1354 - 1355 - return r; 1356 - } 1357 - 1358 1335 /** 1359 1336 * amdgpu_vm_update_func - helper to call update function 1360 1337 * ··· 1424 1451 params.adev = adev; 1425 1452 1426 1453 if (vm->use_cpu_for_update) { 1427 - r = amdgpu_vm_wait_pd(adev, vm, AMDGPU_FENCE_OWNER_VM); 1454 + r = amdgpu_bo_sync_wait(vm->root.base.bo, 1455 + AMDGPU_FENCE_OWNER_VM, true); 1428 1456 if (unlikely(r)) 1429 1457 return r; 1430 1458 ··· 1746 1772 params.adev = adev; 1747 1773 params.vm = vm; 1748 1774 1749 - /* sync to everything on unmapping */ 1775 + /* sync to everything except eviction fences on unmapping */ 1750 1776 if (!(flags & AMDGPU_PTE_VALID)) 1751 - owner = AMDGPU_FENCE_OWNER_UNDEFINED; 1777 + owner = AMDGPU_FENCE_OWNER_KFD; 1752 1778 1753 1779 if (vm->use_cpu_for_update) { 1754 1780 /* params.src is used as flag to indicate system Memory */ ··· 1758 1784 /* Wait for PT BOs to be idle. PTs share the same resv. object 1759 1785 * as the root PD BO 1760 1786 */ 1761 - r = amdgpu_vm_wait_pd(adev, vm, owner); 1787 + r = amdgpu_bo_sync_wait(vm->root.base.bo, owner, true); 1762 1788 if (unlikely(r)) 1763 1789 return r; 1764 1790
+1 -1
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
··· 2980 2980 struct amdgpu_irq_src *source, 2981 2981 struct amdgpu_iv_entry *entry) 2982 2982 { 2983 - unsigned long flags; 2983 + unsigned long flags; 2984 2984 unsigned crtc_id; 2985 2985 struct amdgpu_crtc *amdgpu_crtc; 2986 2986 struct amdgpu_flip_work *works;
+2 -1
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
··· 266 266 } 267 267 268 268 /* Trigger recovery for world switch failure if no TDR */ 269 - if (amdgpu_device_should_recover_gpu(adev)) 269 + if (amdgpu_device_should_recover_gpu(adev) 270 + && amdgpu_lockup_timeout == MAX_SCHEDULE_TIMEOUT) 270 271 amdgpu_device_gpu_recover(adev, NULL); 271 272 } 272 273
+1 -1
drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c
··· 32 32 33 33 static u32 nbio_v7_4_get_rev_id(struct amdgpu_device *adev) 34 34 { 35 - u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); 35 + u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); 36 36 37 37 tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK; 38 38 tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT;
+1 -1
drivers/gpu/drm/amd/amdgpu/si.c
··· 1436 1436 AMD_CG_SUPPORT_UVD_MGCG | 1437 1437 AMD_CG_SUPPORT_HDP_LS | 1438 1438 AMD_CG_SUPPORT_HDP_MGCG; 1439 - adev->pg_flags = 0; 1439 + adev->pg_flags = 0; 1440 1440 adev->external_rev_id = (adev->rev_id == 0) ? 1 : 1441 1441 (adev->rev_id == 1) ? 5 : 6; 1442 1442 break;
+2
drivers/gpu/drm/amd/amdgpu/si_dpm.c
··· 6216 6216 si_pi->force_pcie_gen = AMDGPU_PCIE_GEN2; 6217 6217 if (current_link_speed == AMDGPU_PCIE_GEN2) 6218 6218 break; 6219 + /* fall through */ 6219 6220 case AMDGPU_PCIE_GEN2: 6220 6221 if (amdgpu_acpi_pcie_performance_request(adev, PCIE_PERF_REQ_PECI_GEN2, false) == 0) 6221 6222 break; 6222 6223 #endif 6224 + /* fall through */ 6223 6225 default: 6224 6226 si_pi->force_pcie_gen = si_get_current_pcie_speed(adev); 6225 6227 break;
+4
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c
··· 81 81 adev->doorbell_index.uvd_vce.vce_ring2_3 = AMDGPU_DOORBELL64_VCE_RING2_3; 82 82 adev->doorbell_index.uvd_vce.vce_ring4_5 = AMDGPU_DOORBELL64_VCE_RING4_5; 83 83 adev->doorbell_index.uvd_vce.vce_ring6_7 = AMDGPU_DOORBELL64_VCE_RING6_7; 84 + 85 + adev->doorbell_index.first_non_cp = AMDGPU_DOORBELL64_FIRST_NON_CP; 86 + adev->doorbell_index.last_non_cp = AMDGPU_DOORBELL64_LAST_NON_CP; 87 + 84 88 /* In unit of dword doorbell */ 85 89 adev->doorbell_index.max_assignment = AMDGPU_DOORBELL64_MAX_ASSIGNMENT << 1; 86 90 adev->doorbell_index.sdma_doorbell_range = 4;
+4
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c
··· 85 85 adev->doorbell_index.uvd_vce.vce_ring2_3 = AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3; 86 86 adev->doorbell_index.uvd_vce.vce_ring4_5 = AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5; 87 87 adev->doorbell_index.uvd_vce.vce_ring6_7 = AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7; 88 + 89 + adev->doorbell_index.first_non_cp = AMDGPU_VEGA20_DOORBELL64_FIRST_NON_CP; 90 + adev->doorbell_index.last_non_cp = AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP; 91 + 88 92 adev->doorbell_index.max_assignment = AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT << 1; 89 93 adev->doorbell_index.sdma_doorbell_range = 20; 90 94 }
+11 -5
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
··· 134 134 */ 135 135 q->doorbell_id = q->properties.queue_id; 136 136 } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA) { 137 - /* For SDMA queues on SOC15, use static doorbell 138 - * assignments based on the engine and queue. 137 + /* For SDMA queues on SOC15 with 8-byte doorbell, use static 138 + * doorbell assignments based on the engine and queue id. 139 + * The doobell index distance between RLC (2*i) and (2*i+1) 140 + * for a SDMA engine is 512. 139 141 */ 140 - q->doorbell_id = dev->shared_resources.sdma_doorbell 141 - [q->properties.sdma_engine_id] 142 - [q->properties.sdma_queue_id]; 142 + uint32_t *idx_offset = 143 + dev->shared_resources.sdma_doorbell_idx; 144 + 145 + q->doorbell_id = idx_offset[q->properties.sdma_engine_id] 146 + + (q->properties.sdma_queue_id & 1) 147 + * KFD_QUEUE_DOORBELL_MIRROR_OFFSET 148 + + (q->properties.sdma_queue_id >> 1); 143 149 } else { 144 150 /* For CP queues on SOC15 reserve a free doorbell ID */ 145 151 unsigned int found;
+17 -5
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
··· 97 97 #define KFD_CWSR_TBA_TMA_SIZE (PAGE_SIZE * 2) 98 98 #define KFD_CWSR_TMA_OFFSET PAGE_SIZE 99 99 100 + #define KFD_MAX_NUM_OF_QUEUES_PER_DEVICE \ 101 + (KFD_MAX_NUM_OF_PROCESSES * \ 102 + KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) 103 + 104 + #define KFD_KERNEL_QUEUE_SIZE 2048 105 + 106 + /* 107 + * 512 = 0x200 108 + * The doorbell index distance between SDMA RLC (2*i) and (2*i+1) in the 109 + * same SDMA engine on SOC15, which has 8-byte doorbells for SDMA. 110 + * 512 8-byte doorbell distance (i.e. one page away) ensures that SDMA RLC 111 + * (2*i+1) doorbells (in terms of the lower 12 bit address) lie exactly in 112 + * the OFFSET and SIZE set in registers like BIF_SDMA0_DOORBELL_RANGE. 113 + */ 114 + #define KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 115 + 116 + 100 117 /* 101 118 * Kernel module parameter to specify maximum number of supported queues per 102 119 * device 103 120 */ 104 121 extern int max_num_of_queues_per_device; 105 122 106 - #define KFD_MAX_NUM_OF_QUEUES_PER_DEVICE \ 107 - (KFD_MAX_NUM_OF_PROCESSES * \ 108 - KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) 109 - 110 - #define KFD_KERNEL_QUEUE_SIZE 2048 111 123 112 124 /* Kernel module parameter to specify the scheduling policy */ 113 125 extern int sched_policy;
+9 -5
drivers/gpu/drm/amd/amdkfd/kfd_process.c
··· 607 607 if (!qpd->doorbell_bitmap) 608 608 return -ENOMEM; 609 609 610 - /* Mask out any reserved doorbells */ 611 - for (i = 0; i < KFD_MAX_NUM_OF_QUEUES_PER_PROCESS; i++) 612 - if ((dev->shared_resources.reserved_doorbell_mask & i) == 613 - dev->shared_resources.reserved_doorbell_val) { 610 + /* Mask out doorbells reserved for SDMA, IH, and VCN on SOC15. */ 611 + for (i = 0; i < KFD_MAX_NUM_OF_QUEUES_PER_PROCESS / 2; i++) { 612 + if (i >= dev->shared_resources.non_cp_doorbells_start 613 + && i <= dev->shared_resources.non_cp_doorbells_end) { 614 614 set_bit(i, qpd->doorbell_bitmap); 615 - pr_debug("reserved doorbell 0x%03x\n", i); 615 + set_bit(i + KFD_QUEUE_DOORBELL_MIRROR_OFFSET, 616 + qpd->doorbell_bitmap); 617 + pr_debug("reserved doorbell 0x%03x and 0x%03x\n", i, 618 + i + KFD_QUEUE_DOORBELL_MIRROR_OFFSET); 616 619 } 620 + } 617 621 618 622 return 0; 619 623 }
+66 -17
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 3790 3790 * check will succeed, and let DC implement proper check 3791 3791 */ 3792 3792 static const uint32_t rgb_formats[] = { 3793 - DRM_FORMAT_RGB888, 3794 3793 DRM_FORMAT_XRGB8888, 3795 3794 DRM_FORMAT_ARGB8888, 3796 3795 DRM_FORMAT_RGBA8888, ··· 4677 4678 struct dc_plane_state *dc_plane; 4678 4679 struct dm_plane_state *dm_new_plane_state = to_dm_plane_state(new_plane_state); 4679 4680 4680 - if (plane->type == DRM_PLANE_TYPE_CURSOR) { 4681 - handle_cursor_update(plane, old_plane_state); 4681 + /* Cursor plane is handled after stream updates */ 4682 + if (plane->type == DRM_PLANE_TYPE_CURSOR) 4682 4683 continue; 4683 - } 4684 4684 4685 4685 if (!fb || !crtc || pcrtc != crtc) 4686 4686 continue; ··· 4710 4712 */ 4711 4713 abo = gem_to_amdgpu_bo(fb->obj[0]); 4712 4714 r = amdgpu_bo_reserve(abo, true); 4713 - if (unlikely(r != 0)) { 4715 + if (unlikely(r != 0)) 4714 4716 DRM_ERROR("failed to reserve buffer before flip\n"); 4715 - WARN_ON(1); 4716 - } 4717 4717 4718 - /* Wait for all fences on this FB */ 4719 - WARN_ON(reservation_object_wait_timeout_rcu(abo->tbo.resv, true, false, 4720 - MAX_SCHEDULE_TIMEOUT) < 0); 4718 + /* 4719 + * Wait for all fences on this FB. Do limited wait to avoid 4720 + * deadlock during GPU reset when this fence will not signal 4721 + * but we hold reservation lock for the BO. 4722 + */ 4723 + r = reservation_object_wait_timeout_rcu(abo->tbo.resv, 4724 + true, false, 4725 + msecs_to_jiffies(5000)); 4726 + if (unlikely(r == 0)) 4727 + DRM_ERROR("Waiting for fences timed out."); 4728 + 4729 + 4721 4730 4722 4731 amdgpu_bo_get_tiling_flags(abo, &tiling_flags); 4723 4732 ··· 4878 4873 dc_state); 4879 4874 mutex_unlock(&dm->dc_lock); 4880 4875 } 4876 + 4877 + for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) 4878 + if (plane->type == DRM_PLANE_TYPE_CURSOR) 4879 + handle_cursor_update(plane, old_plane_state); 4881 4880 4882 4881 cleanup: 4883 4882 kfree(flip); ··· 5808 5799 old_dm_crtc_state = to_dm_crtc_state(old_crtc_state); 5809 5800 num_plane = 0; 5810 5801 5811 - if (!new_dm_crtc_state->stream) { 5812 - if (!new_dm_crtc_state->stream && old_dm_crtc_state->stream) { 5813 - update_type = UPDATE_TYPE_FULL; 5814 - goto cleanup; 5815 - } 5816 - 5817 - continue; 5802 + if (new_dm_crtc_state->stream != old_dm_crtc_state->stream) { 5803 + update_type = UPDATE_TYPE_FULL; 5804 + goto cleanup; 5818 5805 } 5806 + 5807 + if (!new_dm_crtc_state->stream) 5808 + continue; 5819 5809 5820 5810 for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, j) { 5821 5811 new_plane_crtc = new_plane_state->crtc; ··· 5824 5816 5825 5817 if (plane->type == DRM_PLANE_TYPE_CURSOR) 5826 5818 continue; 5819 + 5820 + if (new_dm_plane_state->dc_state != old_dm_plane_state->dc_state) { 5821 + update_type = UPDATE_TYPE_FULL; 5822 + goto cleanup; 5823 + } 5827 5824 5828 5825 if (!state->allow_modeset) 5829 5826 continue; ··· 5966 5953 ret = drm_atomic_add_affected_planes(state, crtc); 5967 5954 if (ret) 5968 5955 goto fail; 5956 + } 5957 + 5958 + /* 5959 + * Add all primary and overlay planes on the CRTC to the state 5960 + * whenever a plane is enabled to maintain correct z-ordering 5961 + * and to enable fast surface updates. 5962 + */ 5963 + drm_for_each_crtc(crtc, dev) { 5964 + bool modified = false; 5965 + 5966 + for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { 5967 + if (plane->type == DRM_PLANE_TYPE_CURSOR) 5968 + continue; 5969 + 5970 + if (new_plane_state->crtc == crtc || 5971 + old_plane_state->crtc == crtc) { 5972 + modified = true; 5973 + break; 5974 + } 5975 + } 5976 + 5977 + if (!modified) 5978 + continue; 5979 + 5980 + drm_for_each_plane_mask(plane, state->dev, crtc->state->plane_mask) { 5981 + if (plane->type == DRM_PLANE_TYPE_CURSOR) 5982 + continue; 5983 + 5984 + new_plane_state = 5985 + drm_atomic_get_plane_state(state, plane); 5986 + 5987 + if (IS_ERR(new_plane_state)) { 5988 + ret = PTR_ERR(new_plane_state); 5989 + goto fail; 5990 + } 5991 + } 5969 5992 } 5970 5993 5971 5994 /* Remove exiting planes if they are modified */
+2
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
··· 265 265 && id.enum_id == obj_id.enum_id) 266 266 return &bp->object_info_tbl.v1_4->display_path[i]; 267 267 } 268 + /* fall through */ 268 269 case OBJECT_TYPE_CONNECTOR: 269 270 case OBJECT_TYPE_GENERIC: 270 271 /* Both Generic and Connector Object ID ··· 278 277 && id.enum_id == obj_id.enum_id) 279 278 return &bp->object_info_tbl.v1_4->display_path[i]; 280 279 } 280 + /* fall through */ 281 281 default: 282 282 return NULL; 283 283 }
+9 -6
drivers/gpu/drm/amd/display/dc/core/dc.c
··· 1138 1138 /* pplib is notified if disp_num changed */ 1139 1139 dc->hwss.optimize_bandwidth(dc, context); 1140 1140 1141 + for (i = 0; i < context->stream_count; i++) 1142 + context->streams[i]->mode_changed = false; 1143 + 1141 1144 dc_release_state(dc->current_state); 1142 1145 1143 1146 dc->current_state = context; ··· 1626 1623 stream_update->adjust->v_total_min, 1627 1624 stream_update->adjust->v_total_max); 1628 1625 1629 - if (stream_update->periodic_vsync_config && pipe_ctx->stream_res.tg->funcs->program_vline_interrupt) 1630 - pipe_ctx->stream_res.tg->funcs->program_vline_interrupt( 1631 - pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, VLINE0, &stream->periodic_vsync_config); 1626 + if (stream_update->periodic_interrupt0 && 1627 + dc->hwss.setup_periodic_interrupt) 1628 + dc->hwss.setup_periodic_interrupt(pipe_ctx, VLINE0); 1632 1629 1633 - if (stream_update->enhanced_sync_config && pipe_ctx->stream_res.tg->funcs->program_vline_interrupt) 1634 - pipe_ctx->stream_res.tg->funcs->program_vline_interrupt( 1635 - pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, VLINE1, &stream->enhanced_sync_config); 1630 + if (stream_update->periodic_interrupt1 && 1631 + dc->hwss.setup_periodic_interrupt) 1632 + dc->hwss.setup_periodic_interrupt(pipe_ctx, VLINE1); 1636 1633 1637 1634 if ((stream_update->hdr_static_metadata && !stream->use_dynamic_meta) || 1638 1635 stream_update->vrr_infopacket ||
+17 -7
drivers/gpu/drm/amd/display/dc/dc_stream.h
··· 51 51 bool dummy; 52 52 }; 53 53 54 - union vline_config { 55 - unsigned int line_number; 56 - unsigned long long delta_in_ns; 54 + enum vertical_interrupt_ref_point { 55 + START_V_UPDATE = 0, 56 + START_V_SYNC, 57 + INVALID_POINT 58 + 59 + //For now, only v_update interrupt is used. 60 + //START_V_BLANK, 61 + //START_V_ACTIVE 62 + }; 63 + 64 + struct periodic_interrupt_config { 65 + enum vertical_interrupt_ref_point ref_point; 66 + int lines_offset; 57 67 }; 58 68 59 69 ··· 116 106 /* DMCU info */ 117 107 unsigned int abm_level; 118 108 119 - union vline_config periodic_vsync_config; 120 - union vline_config enhanced_sync_config; 109 + struct periodic_interrupt_config periodic_interrupt0; 110 + struct periodic_interrupt_config periodic_interrupt1; 121 111 122 112 /* from core_stream struct */ 123 113 struct dc_context *ctx; ··· 168 158 struct dc_info_packet *hdr_static_metadata; 169 159 unsigned int *abm_level; 170 160 171 - union vline_config *periodic_vsync_config; 172 - union vline_config *enhanced_sync_config; 161 + struct periodic_interrupt_config *periodic_interrupt0; 162 + struct periodic_interrupt_config *periodic_interrupt1; 173 163 174 164 struct dc_crtc_timing_adjust *adjust; 175 165 struct dc_info_packet *vrr_infopacket;
+24 -21
drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
··· 53 53 54 54 #define MCP_DISABLE_ABM_IMMEDIATELY 255 55 55 56 + static bool dce_abm_set_pipe(struct abm *abm, uint32_t controller_id) 57 + { 58 + struct dce_abm *abm_dce = TO_DCE_ABM(abm); 59 + uint32_t rampingBoundary = 0xFFFF; 60 + 61 + REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 62 + 1, 80000); 63 + 64 + /* set ramping boundary */ 65 + REG_WRITE(MASTER_COMM_DATA_REG1, rampingBoundary); 66 + 67 + /* setDMCUParam_Pipe */ 68 + REG_UPDATE_2(MASTER_COMM_CMD_REG, 69 + MASTER_COMM_CMD_REG_BYTE0, MCP_ABM_PIPE_SET, 70 + MASTER_COMM_CMD_REG_BYTE1, controller_id); 71 + 72 + /* notifyDMCUMsg */ 73 + REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1); 74 + 75 + return true; 76 + } 56 77 57 78 static unsigned int calculate_16_bit_backlight_from_pwm(struct dce_abm *abm_dce) 58 79 { ··· 196 175 uint32_t controller_id) 197 176 { 198 177 unsigned int backlight_8_bit = 0; 199 - uint32_t rampingBoundary = 0xFFFF; 200 178 uint32_t s2; 201 179 202 180 if (backlight_pwm_u16_16 & 0x10000) ··· 205 185 // Take MSB of fractional part since backlight is not max 206 186 backlight_8_bit = (backlight_pwm_u16_16 >> 8) & 0xFF; 207 187 208 - /* set ramping boundary */ 209 - REG_WRITE(MASTER_COMM_DATA_REG1, rampingBoundary); 210 - 211 - /* setDMCUParam_Pipe */ 212 - REG_UPDATE_2(MASTER_COMM_CMD_REG, 213 - MASTER_COMM_CMD_REG_BYTE0, MCP_ABM_PIPE_SET, 214 - MASTER_COMM_CMD_REG_BYTE1, controller_id); 215 - 216 - /* notifyDMCUMsg */ 217 - REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1); 188 + dce_abm_set_pipe(&abm_dce->base, controller_id); 218 189 219 190 /* waitDMCUReadyForCmd */ 220 191 REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, ··· 320 309 { 321 310 struct dce_abm *abm_dce = TO_DCE_ABM(abm); 322 311 323 - REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 324 - 1, 80000); 325 - 326 - /* setDMCUParam_ABMLevel */ 327 - REG_UPDATE_2(MASTER_COMM_CMD_REG, 328 - MASTER_COMM_CMD_REG_BYTE0, MCP_ABM_PIPE_SET, 329 - MASTER_COMM_CMD_REG_BYTE1, MCP_DISABLE_ABM_IMMEDIATELY); 330 - 331 - /* notifyDMCUMsg */ 332 - REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1); 312 + dce_abm_set_pipe(abm, MCP_DISABLE_ABM_IMMEDIATELY); 333 313 334 314 abm->stored_backlight_registers.BL_PWM_CNTL = 335 315 REG_READ(BL_PWM_CNTL); ··· 421 419 .abm_init = dce_abm_init, 422 420 .set_abm_level = dce_abm_set_level, 423 421 .init_backlight = dce_abm_init_backlight, 422 + .set_pipe = dce_abm_set_pipe, 424 423 .set_backlight_level_pwm = dce_abm_set_backlight_level_pwm, 425 424 .get_current_backlight = dce_abm_get_current_backlight, 426 425 .get_target_backlight = dce_abm_get_target_backlight,
+1 -1
drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
··· 479 479 case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F: 480 480 sign = 1; 481 481 floating = 1; 482 - /* no break */ 482 + /* fall through */ 483 483 case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F: /* shouldn't this get float too? */ 484 484 case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616: 485 485 grph_depth = 3;
+17 -5
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
··· 1300 1300 struct drr_params params = {0}; 1301 1301 unsigned int event_triggers = 0; 1302 1302 1303 + if (dc->hwss.disable_stream_gating) { 1304 + dc->hwss.disable_stream_gating(dc, pipe_ctx); 1305 + } 1306 + 1303 1307 if (pipe_ctx->stream_res.audio != NULL) { 1304 1308 struct audio_output audio_output; 1305 1309 ··· 1333 1329 if (!pipe_ctx->stream->apply_seamless_boot_optimization) 1334 1330 dc->hwss.enable_stream_timing(pipe_ctx, context, dc); 1335 1331 1336 - if (pipe_ctx->stream_res.tg->funcs->program_vupdate_interrupt) 1337 - pipe_ctx->stream_res.tg->funcs->program_vupdate_interrupt( 1338 - pipe_ctx->stream_res.tg, 1339 - &stream->timing); 1332 + if (dc->hwss.setup_vupdate_interrupt) 1333 + dc->hwss.setup_vupdate_interrupt(pipe_ctx); 1340 1334 1341 1335 params.vertical_total_min = stream->adjust.v_total_min; 1342 1336 params.vertical_total_max = stream->adjust.v_total_max; ··· 1523 1521 struct dc_link *edp_link = get_link_for_edp(dc); 1524 1522 bool can_edp_fast_boot_optimize = false; 1525 1523 bool apply_edp_fast_boot_optimization = false; 1524 + bool can_apply_seamless_boot = false; 1525 + 1526 + for (i = 0; i < context->stream_count; i++) { 1527 + if (context->streams[i]->apply_seamless_boot_optimization) { 1528 + can_apply_seamless_boot = true; 1529 + break; 1530 + } 1531 + } 1526 1532 1527 1533 if (edp_link) { 1528 1534 /* this seems to cause blank screens on DCE8 */ ··· 1559 1549 } 1560 1550 } 1561 1551 1562 - if (!apply_edp_fast_boot_optimization) { 1552 + if (!apply_edp_fast_boot_optimization && !can_apply_seamless_boot) { 1563 1553 if (edp_link_to_turnoff) { 1564 1554 /*turn off backlight before DP_blank and encoder powered down*/ 1565 1555 dc->hwss.edp_backlight_control(edp_link_to_turnoff, false); ··· 2686 2676 .set_static_screen_control = set_static_screen_control, 2687 2677 .reset_hw_ctx_wrap = dce110_reset_hw_ctx_wrap, 2688 2678 .enable_stream_timing = dce110_enable_stream_timing, 2679 + .disable_stream_gating = NULL, 2680 + .enable_stream_gating = NULL, 2689 2681 .setup_stereo = NULL, 2690 2682 .set_avmute = dce110_set_avmute, 2691 2683 .wait_for_mpcc_disconnect = dce110_wait_for_mpcc_disconnect,
+181 -4
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
··· 959 959 static void dcn10_init_pipes(struct dc *dc, struct dc_state *context) 960 960 { 961 961 int i; 962 + bool can_apply_seamless_boot = false; 963 + 964 + for (i = 0; i < context->stream_count; i++) { 965 + if (context->streams[i]->apply_seamless_boot_optimization) { 966 + can_apply_seamless_boot = true; 967 + break; 968 + } 969 + } 962 970 963 971 for (i = 0; i < dc->res_pool->pipe_count; i++) { 964 972 struct timing_generator *tg = dc->res_pool->timing_generators[i]; 973 + struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i]; 974 + 975 + /* There is assumption that pipe_ctx is not mapping irregularly 976 + * to non-preferred front end. If pipe_ctx->stream is not NULL, 977 + * we will use the pipe, so don't disable 978 + */ 979 + if (pipe_ctx->stream != NULL) 980 + continue; 965 981 966 982 if (tg->funcs->is_tg_enabled(tg)) 967 983 tg->funcs->lock(tg); ··· 991 975 } 992 976 } 993 977 994 - dc->res_pool->mpc->funcs->mpc_init(dc->res_pool->mpc); 978 + /* Cannot reset the MPC mux if seamless boot */ 979 + if (!can_apply_seamless_boot) 980 + dc->res_pool->mpc->funcs->mpc_init(dc->res_pool->mpc); 995 981 996 982 for (i = 0; i < dc->res_pool->pipe_count; i++) { 997 983 struct timing_generator *tg = dc->res_pool->timing_generators[i]; 998 984 struct hubp *hubp = dc->res_pool->hubps[i]; 999 985 struct dpp *dpp = dc->res_pool->dpps[i]; 1000 986 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i]; 987 + 988 + // W/A for issue with dc_post_update_surfaces_to_stream 989 + hubp->power_gated = true; 990 + 991 + /* There is assumption that pipe_ctx is not mapping irregularly 992 + * to non-preferred front end. If pipe_ctx->stream is not NULL, 993 + * we will use the pipe, so don't disable 994 + */ 995 + if (pipe_ctx->stream != NULL) 996 + continue; 1001 997 1002 998 dpp->funcs->dpp_reset(dpp); 1003 999 ··· 1165 1137 struct clock_source *old_clk = pipe_ctx_old->clock_source; 1166 1138 1167 1139 reset_back_end_for_pipe(dc, pipe_ctx_old, dc->current_state); 1140 + if (dc->hwss.enable_stream_gating) { 1141 + dc->hwss.enable_stream_gating(dc, pipe_ctx); 1142 + } 1168 1143 if (old_clk) 1169 1144 old_clk->funcs->cs_power_down(old_clk); 1170 1145 } 1171 1146 } 1172 - 1173 1147 } 1174 1148 1175 1149 static bool patch_address_for_sbs_tb_stereo( ··· 2192 2162 if (!blank) { 2193 2163 if (stream_res->tg->funcs->set_blank) 2194 2164 stream_res->tg->funcs->set_blank(stream_res->tg, blank); 2195 - if (stream_res->abm) 2165 + if (stream_res->abm) { 2166 + stream_res->abm->funcs->set_pipe(stream_res->abm, stream_res->tg->inst + 1); 2196 2167 stream_res->abm->funcs->set_abm_level(stream_res->abm, stream->abm_level); 2168 + } 2197 2169 } else if (blank) { 2198 2170 if (stream_res->abm) 2199 2171 stream_res->abm->funcs->set_abm_immediate_disable(stream_res->abm); ··· 2741 2709 pipe_ctx->plane_res.dpp, &opt_attr); 2742 2710 } 2743 2711 2712 + /** 2713 + * apply_front_porch_workaround TODO FPGA still need? 2714 + * 2715 + * This is a workaround for a bug that has existed since R5xx and has not been 2716 + * fixed keep Front porch at minimum 2 for Interlaced mode or 1 for progressive. 2717 + */ 2718 + static void apply_front_porch_workaround( 2719 + struct dc_crtc_timing *timing) 2720 + { 2721 + if (timing->flags.INTERLACE == 1) { 2722 + if (timing->v_front_porch < 2) 2723 + timing->v_front_porch = 2; 2724 + } else { 2725 + if (timing->v_front_porch < 1) 2726 + timing->v_front_porch = 1; 2727 + } 2728 + } 2729 + 2730 + int get_vupdate_offset_from_vsync(struct pipe_ctx *pipe_ctx) 2731 + { 2732 + struct timing_generator *optc = pipe_ctx->stream_res.tg; 2733 + const struct dc_crtc_timing *dc_crtc_timing = &pipe_ctx->stream->timing; 2734 + struct dc_crtc_timing patched_crtc_timing; 2735 + int vesa_sync_start; 2736 + int asic_blank_end; 2737 + int interlace_factor; 2738 + int vertical_line_start; 2739 + 2740 + patched_crtc_timing = *dc_crtc_timing; 2741 + apply_front_porch_workaround(&patched_crtc_timing); 2742 + 2743 + interlace_factor = patched_crtc_timing.flags.INTERLACE ? 2 : 1; 2744 + 2745 + vesa_sync_start = patched_crtc_timing.v_addressable + 2746 + patched_crtc_timing.v_border_bottom + 2747 + patched_crtc_timing.v_front_porch; 2748 + 2749 + asic_blank_end = (patched_crtc_timing.v_total - 2750 + vesa_sync_start - 2751 + patched_crtc_timing.v_border_top) 2752 + * interlace_factor; 2753 + 2754 + vertical_line_start = asic_blank_end - 2755 + optc->dlg_otg_param.vstartup_start + 1; 2756 + 2757 + return vertical_line_start; 2758 + } 2759 + 2760 + static void calc_vupdate_position( 2761 + struct pipe_ctx *pipe_ctx, 2762 + uint32_t *start_line, 2763 + uint32_t *end_line) 2764 + { 2765 + const struct dc_crtc_timing *dc_crtc_timing = &pipe_ctx->stream->timing; 2766 + int vline_int_offset_from_vupdate = 2767 + pipe_ctx->stream->periodic_interrupt0.lines_offset; 2768 + int vupdate_offset_from_vsync = get_vupdate_offset_from_vsync(pipe_ctx); 2769 + int start_position; 2770 + 2771 + if (vline_int_offset_from_vupdate > 0) 2772 + vline_int_offset_from_vupdate--; 2773 + else if (vline_int_offset_from_vupdate < 0) 2774 + vline_int_offset_from_vupdate++; 2775 + 2776 + start_position = vline_int_offset_from_vupdate + vupdate_offset_from_vsync; 2777 + 2778 + if (start_position >= 0) 2779 + *start_line = start_position; 2780 + else 2781 + *start_line = dc_crtc_timing->v_total + start_position - 1; 2782 + 2783 + *end_line = *start_line + 2; 2784 + 2785 + if (*end_line >= dc_crtc_timing->v_total) 2786 + *end_line = 2; 2787 + } 2788 + 2789 + static void cal_vline_position( 2790 + struct pipe_ctx *pipe_ctx, 2791 + enum vline_select vline, 2792 + uint32_t *start_line, 2793 + uint32_t *end_line) 2794 + { 2795 + enum vertical_interrupt_ref_point ref_point = INVALID_POINT; 2796 + 2797 + if (vline == VLINE0) 2798 + ref_point = pipe_ctx->stream->periodic_interrupt0.ref_point; 2799 + else if (vline == VLINE1) 2800 + ref_point = pipe_ctx->stream->periodic_interrupt1.ref_point; 2801 + 2802 + switch (ref_point) { 2803 + case START_V_UPDATE: 2804 + calc_vupdate_position( 2805 + pipe_ctx, 2806 + start_line, 2807 + end_line); 2808 + break; 2809 + case START_V_SYNC: 2810 + // Suppose to do nothing because vsync is 0; 2811 + break; 2812 + default: 2813 + ASSERT(0); 2814 + break; 2815 + } 2816 + } 2817 + 2818 + static void dcn10_setup_periodic_interrupt( 2819 + struct pipe_ctx *pipe_ctx, 2820 + enum vline_select vline) 2821 + { 2822 + struct timing_generator *tg = pipe_ctx->stream_res.tg; 2823 + 2824 + if (vline == VLINE0) { 2825 + uint32_t start_line = 0; 2826 + uint32_t end_line = 0; 2827 + 2828 + cal_vline_position(pipe_ctx, vline, &start_line, &end_line); 2829 + 2830 + tg->funcs->setup_vertical_interrupt0(tg, start_line, end_line); 2831 + 2832 + } else if (vline == VLINE1) { 2833 + pipe_ctx->stream_res.tg->funcs->setup_vertical_interrupt1( 2834 + tg, 2835 + pipe_ctx->stream->periodic_interrupt1.lines_offset); 2836 + } 2837 + } 2838 + 2839 + static void dcn10_setup_vupdate_interrupt(struct pipe_ctx *pipe_ctx) 2840 + { 2841 + struct timing_generator *tg = pipe_ctx->stream_res.tg; 2842 + int start_line = get_vupdate_offset_from_vsync(pipe_ctx); 2843 + 2844 + if (start_line < 0) { 2845 + ASSERT(0); 2846 + start_line = 0; 2847 + } 2848 + 2849 + if (tg->funcs->setup_vertical_interrupt2) 2850 + tg->funcs->setup_vertical_interrupt2(tg, start_line); 2851 + } 2852 + 2744 2853 static const struct hw_sequencer_funcs dcn10_funcs = { 2745 2854 .program_gamut_remap = program_gamut_remap, 2746 2855 .init_hw = dcn10_init_hw, ··· 2929 2756 .edp_wait_for_hpd_ready = hwss_edp_wait_for_hpd_ready, 2930 2757 .set_cursor_position = dcn10_set_cursor_position, 2931 2758 .set_cursor_attribute = dcn10_set_cursor_attribute, 2932 - .set_cursor_sdr_white_level = dcn10_set_cursor_sdr_white_level 2759 + .set_cursor_sdr_white_level = dcn10_set_cursor_sdr_white_level, 2760 + .disable_stream_gating = NULL, 2761 + .enable_stream_gating = NULL, 2762 + .setup_periodic_interrupt = dcn10_setup_periodic_interrupt, 2763 + .setup_vupdate_interrupt = dcn10_setup_vupdate_interrupt 2933 2764 }; 2934 2765 2935 2766
+2
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h
··· 81 81 struct dc_state *context, 82 82 const struct dc_stream_state *stream); 83 83 84 + int get_vupdate_offset_from_vsync(struct pipe_ctx *pipe_ctx); 85 + 84 86 #endif /* __DC_HWSS_DCN10_H__ */
+20 -117
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c
··· 92 92 OTG_3D_STRUCTURE_STEREO_SEL_OVR, 0); 93 93 } 94 94 95 - static uint32_t get_start_vline(struct timing_generator *optc, const struct dc_crtc_timing *dc_crtc_timing) 96 - { 97 - struct dc_crtc_timing patched_crtc_timing; 98 - int vesa_sync_start; 99 - int asic_blank_end; 100 - int interlace_factor; 101 - int vertical_line_start; 102 - 103 - patched_crtc_timing = *dc_crtc_timing; 104 - optc1_apply_front_porch_workaround(optc, &patched_crtc_timing); 105 - 106 - vesa_sync_start = patched_crtc_timing.h_addressable + 107 - patched_crtc_timing.h_border_right + 108 - patched_crtc_timing.h_front_porch; 109 - 110 - asic_blank_end = patched_crtc_timing.h_total - 111 - vesa_sync_start - 112 - patched_crtc_timing.h_border_left; 113 - 114 - interlace_factor = patched_crtc_timing.flags.INTERLACE ? 2 : 1; 115 - 116 - vesa_sync_start = patched_crtc_timing.v_addressable + 117 - patched_crtc_timing.v_border_bottom + 118 - patched_crtc_timing.v_front_porch; 119 - 120 - asic_blank_end = (patched_crtc_timing.v_total - 121 - vesa_sync_start - 122 - patched_crtc_timing.v_border_top) 123 - * interlace_factor; 124 - 125 - vertical_line_start = asic_blank_end - optc->dlg_otg_param.vstartup_start + 1; 126 - if (vertical_line_start < 0) { 127 - ASSERT(0); 128 - vertical_line_start = 0; 129 - } 130 - 131 - return vertical_line_start; 132 - } 133 - 134 - static void calc_vline_position( 95 + void optc1_setup_vertical_interrupt0( 135 96 struct timing_generator *optc, 136 - const struct dc_crtc_timing *dc_crtc_timing, 137 - unsigned long long vsync_delta, 138 - uint32_t *start_line, 139 - uint32_t *end_line) 140 - { 141 - unsigned long long req_delta_tens_of_usec = div64_u64((vsync_delta + 9999), 10000); 142 - unsigned long long pix_clk_hundreds_khz = div64_u64((dc_crtc_timing->pix_clk_100hz + 999), 1000); 143 - uint32_t req_delta_lines = (uint32_t) div64_u64( 144 - (req_delta_tens_of_usec * pix_clk_hundreds_khz + dc_crtc_timing->h_total - 1), 145 - dc_crtc_timing->h_total); 146 - 147 - uint32_t vsync_line = get_start_vline(optc, dc_crtc_timing); 148 - 149 - if (req_delta_lines != 0) 150 - req_delta_lines--; 151 - 152 - if (req_delta_lines > vsync_line) 153 - *start_line = dc_crtc_timing->v_total - (req_delta_lines - vsync_line) - 1; 154 - else 155 - *start_line = vsync_line - req_delta_lines; 156 - 157 - *end_line = *start_line + 2; 158 - 159 - if (*end_line >= dc_crtc_timing->v_total) 160 - *end_line = 2; 161 - } 162 - 163 - void optc1_program_vline_interrupt( 164 - struct timing_generator *optc, 165 - const struct dc_crtc_timing *dc_crtc_timing, 166 - enum vline_select vline, 167 - const union vline_config *vline_config) 97 + uint32_t start_line, 98 + uint32_t end_line) 168 99 { 169 100 struct optc *optc1 = DCN10TG_FROM_TG(optc); 170 - uint32_t start_line = 0; 171 - uint32_t end_line = 0; 172 101 173 - switch (vline) { 174 - case VLINE0: 175 - calc_vline_position(optc, dc_crtc_timing, vline_config->delta_in_ns, &start_line, &end_line); 176 - REG_SET_2(OTG_VERTICAL_INTERRUPT0_POSITION, 0, 177 - OTG_VERTICAL_INTERRUPT0_LINE_START, start_line, 178 - OTG_VERTICAL_INTERRUPT0_LINE_END, end_line); 179 - break; 180 - case VLINE1: 181 - REG_SET(OTG_VERTICAL_INTERRUPT1_POSITION, 0, 182 - OTG_VERTICAL_INTERRUPT1_LINE_START, vline_config->line_number); 183 - break; 184 - default: 185 - break; 186 - } 102 + REG_SET_2(OTG_VERTICAL_INTERRUPT0_POSITION, 0, 103 + OTG_VERTICAL_INTERRUPT0_LINE_START, start_line, 104 + OTG_VERTICAL_INTERRUPT0_LINE_END, end_line); 187 105 } 188 106 189 - void optc1_program_vupdate_interrupt( 107 + void optc1_setup_vertical_interrupt1( 190 108 struct timing_generator *optc, 191 - const struct dc_crtc_timing *dc_crtc_timing) 109 + uint32_t start_line) 192 110 { 193 111 struct optc *optc1 = DCN10TG_FROM_TG(optc); 194 - int32_t vertical_line_start; 195 - uint32_t asic_blank_end; 196 - uint32_t vesa_sync_start; 197 - struct dc_crtc_timing patched_crtc_timing; 198 112 199 - patched_crtc_timing = *dc_crtc_timing; 200 - optc1_apply_front_porch_workaround(optc, &patched_crtc_timing); 113 + REG_SET(OTG_VERTICAL_INTERRUPT1_POSITION, 0, 114 + OTG_VERTICAL_INTERRUPT1_LINE_START, start_line); 115 + } 201 116 202 - /* asic_h_blank_end = HsyncWidth + HbackPorch = 203 - * vesa. usHorizontalTotal - vesa. usHorizontalSyncStart - 204 - * vesa.h_left_border 205 - */ 206 - vesa_sync_start = patched_crtc_timing.h_addressable + 207 - patched_crtc_timing.h_border_right + 208 - patched_crtc_timing.h_front_porch; 209 - 210 - asic_blank_end = patched_crtc_timing.h_total - 211 - vesa_sync_start - 212 - patched_crtc_timing.h_border_left; 213 - 214 - /* Use OTG_VERTICAL_INTERRUPT2 replace VUPDATE interrupt, 215 - * program the reg for interrupt postition. 216 - */ 217 - vertical_line_start = asic_blank_end - optc->dlg_otg_param.vstartup_start + 1; 218 - if (vertical_line_start < 0) 219 - vertical_line_start = 0; 117 + void optc1_setup_vertical_interrupt2( 118 + struct timing_generator *optc, 119 + uint32_t start_line) 120 + { 121 + struct optc *optc1 = DCN10TG_FROM_TG(optc); 220 122 221 123 REG_SET(OTG_VERTICAL_INTERRUPT2_POSITION, 0, 222 - OTG_VERTICAL_INTERRUPT2_LINE_START, vertical_line_start); 124 + OTG_VERTICAL_INTERRUPT2_LINE_START, start_line); 223 125 } 224 126 225 127 /** ··· 1382 1480 static const struct timing_generator_funcs dcn10_tg_funcs = { 1383 1481 .validate_timing = optc1_validate_timing, 1384 1482 .program_timing = optc1_program_timing, 1385 - .program_vline_interrupt = optc1_program_vline_interrupt, 1386 - .program_vupdate_interrupt = optc1_program_vupdate_interrupt, 1483 + .setup_vertical_interrupt0 = optc1_setup_vertical_interrupt0, 1484 + .setup_vertical_interrupt1 = optc1_setup_vertical_interrupt1, 1485 + .setup_vertical_interrupt2 = optc1_setup_vertical_interrupt2, 1387 1486 .program_global_sync = optc1_program_global_sync, 1388 1487 .enable_crtc = optc1_enable_crtc, 1389 1488 .disable_crtc = optc1_disable_crtc,
+9 -4
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.h
··· 483 483 const struct dc_crtc_timing *dc_crtc_timing, 484 484 bool use_vbios); 485 485 486 - void optc1_program_vline_interrupt( 486 + void optc1_setup_vertical_interrupt0( 487 487 struct timing_generator *optc, 488 - const struct dc_crtc_timing *dc_crtc_timing, 489 - enum vline_select vline, 490 - const union vline_config *vline_config); 488 + uint32_t start_line, 489 + uint32_t end_line); 490 + void optc1_setup_vertical_interrupt1( 491 + struct timing_generator *optc, 492 + uint32_t start_line); 493 + void optc1_setup_vertical_interrupt2( 494 + struct timing_generator *optc, 495 + uint32_t start_line); 491 496 492 497 void optc1_program_global_sync( 493 498 struct timing_generator *optc);
+1
drivers/gpu/drm/amd/display/dc/inc/hw/abm.h
··· 46 46 void (*abm_init)(struct abm *abm); 47 47 bool (*set_abm_level)(struct abm *abm, unsigned int abm_level); 48 48 bool (*set_abm_immediate_disable)(struct abm *abm); 49 + bool (*set_pipe)(struct abm *abm, unsigned int controller_id); 49 50 bool (*init_backlight)(struct abm *abm); 50 51 51 52 /* backlight_pwm_u16_16 is unsigned 32 bit,
+9 -14
drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h
··· 134 134 135 135 struct drr_params; 136 136 137 - union vline_config; 138 - 139 - 140 - enum vline_select { 141 - VLINE0, 142 - VLINE1, 143 - VLINE2 144 - }; 145 137 146 138 struct timing_generator_funcs { 147 139 bool (*validate_timing)(struct timing_generator *tg, ··· 141 149 void (*program_timing)(struct timing_generator *tg, 142 150 const struct dc_crtc_timing *timing, 143 151 bool use_vbios); 144 - void (*program_vline_interrupt)( 152 + void (*setup_vertical_interrupt0)( 145 153 struct timing_generator *optc, 146 - const struct dc_crtc_timing *dc_crtc_timing, 147 - enum vline_select vline, 148 - const union vline_config *vline_config); 154 + uint32_t start_line, 155 + uint32_t end_line); 156 + void (*setup_vertical_interrupt1)( 157 + struct timing_generator *optc, 158 + uint32_t start_line); 159 + void (*setup_vertical_interrupt2)( 160 + struct timing_generator *optc, 161 + uint32_t start_line); 149 162 150 - void (*program_vupdate_interrupt)(struct timing_generator *optc, 151 - const struct dc_crtc_timing *dc_crtc_timing); 152 163 bool (*enable_crtc)(struct timing_generator *tg); 153 164 bool (*disable_crtc)(struct timing_generator *tg); 154 165 bool (*is_counter_moving)(struct timing_generator *tg);
+12
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
··· 38 38 PIPE_GATING_CONTROL_INIT 39 39 }; 40 40 41 + enum vline_select { 42 + VLINE0, 43 + VLINE1 44 + }; 45 + 41 46 struct dce_hwseq_wa { 42 47 bool blnd_crtc_trigger; 43 48 bool DEGVIDCN10_253; ··· 72 67 struct stream_resource; 73 68 74 69 struct hw_sequencer_funcs { 70 + 71 + void (*disable_stream_gating)(struct dc *dc, struct pipe_ctx *pipe_ctx); 72 + 73 + void (*enable_stream_gating)(struct dc *dc, struct pipe_ctx *pipe_ctx); 75 74 76 75 void (*init_hw)(struct dc *dc); 77 76 ··· 228 219 void (*set_cursor_position)(struct pipe_ctx *pipe); 229 220 void (*set_cursor_attribute)(struct pipe_ctx *pipe); 230 221 void (*set_cursor_sdr_white_level)(struct pipe_ctx *pipe); 222 + 223 + void (*setup_periodic_interrupt)(struct pipe_ctx *pipe_ctx, enum vline_select vline); 224 + void (*setup_vupdate_interrupt)(struct pipe_ctx *pipe_ctx); 231 225 232 226 }; 233 227
+3
drivers/gpu/drm/amd/display/include/dal_asic_id.h
··· 131 131 #define INTERNAL_REV_RAVEN_A0 0x00 /* First spin of Raven */ 132 132 #define RAVEN_A0 0x01 133 133 #define RAVEN_B0 0x21 134 + #define PICASSO_A0 0x41 134 135 #if defined(CONFIG_DRM_AMD_DC_DCN1_01) 135 136 /* DCN1_01 */ 136 137 #define RAVEN2_A0 0x81 ··· 165 164 #define FAMILY_AI 141 166 165 167 166 #define FAMILY_UNKNOWN 0xFF 167 + 168 + 168 169 169 170 #endif /* __DAL_ASIC_ID_H__ */
+4 -19
drivers/gpu/drm/amd/display/modules/power/power_helpers.c
··· 165 165 }; 166 166 #pragma pack(pop) 167 167 168 - static uint16_t backlight_8_to_16(unsigned int backlight_8bit) 169 - { 170 - return (uint16_t)(backlight_8bit * 0x101); 171 - } 172 - 173 168 static void fill_backlight_transform_table(struct dmcu_iram_parameters params, 174 169 struct iram_table_v_2 *table) 175 170 { 176 171 unsigned int i; 177 172 unsigned int num_entries = NUM_BL_CURVE_SEGS; 178 - unsigned int query_input_8bit; 179 - unsigned int query_output_8bit; 180 173 unsigned int lut_index; 181 174 182 175 table->backlight_thresholds[0] = 0; ··· 187 194 * format U4.10. 188 195 */ 189 196 for (i = 1; i+1 < num_entries; i++) { 190 - query_input_8bit = DIV_ROUNDUP((i * 256), num_entries); 191 - 192 197 lut_index = (params.backlight_lut_array_size - 1) * i / (num_entries - 1); 193 198 ASSERT(lut_index < params.backlight_lut_array_size); 194 - query_output_8bit = params.backlight_lut_array[lut_index] >> 8; 195 199 196 200 table->backlight_thresholds[i] = 197 - backlight_8_to_16(query_input_8bit); 201 + cpu_to_be16(DIV_ROUNDUP((i * 65536), num_entries)); 198 202 table->backlight_offsets[i] = 199 - backlight_8_to_16(query_output_8bit); 203 + cpu_to_be16(params.backlight_lut_array[lut_index]); 200 204 } 201 205 } 202 206 ··· 202 212 { 203 213 unsigned int i; 204 214 unsigned int num_entries = NUM_BL_CURVE_SEGS; 205 - unsigned int query_input_8bit; 206 - unsigned int query_output_8bit; 207 215 unsigned int lut_index; 208 216 209 217 table->backlight_thresholds[0] = 0; ··· 219 231 * format U4.10. 220 232 */ 221 233 for (i = 1; i+1 < num_entries; i++) { 222 - query_input_8bit = DIV_ROUNDUP((i * 256), num_entries); 223 - 224 234 lut_index = (params.backlight_lut_array_size - 1) * i / (num_entries - 1); 225 235 ASSERT(lut_index < params.backlight_lut_array_size); 226 - query_output_8bit = params.backlight_lut_array[lut_index] >> 8; 227 236 228 237 table->backlight_thresholds[i] = 229 - backlight_8_to_16(query_input_8bit); 238 + cpu_to_be16(DIV_ROUNDUP((i * 65536), num_entries)); 230 239 table->backlight_offsets[i] = 231 - backlight_8_to_16(query_output_8bit); 240 + cpu_to_be16(params.backlight_lut_array[lut_index]); 232 241 } 233 242 } 234 243
+8 -11
drivers/gpu/drm/amd/include/kgd_kfd_interface.h
··· 137 137 /* Bit n == 1 means Queue n is available for KFD */ 138 138 DECLARE_BITMAP(queue_bitmap, KGD_MAX_QUEUES); 139 139 140 - /* Doorbell assignments (SOC15 and later chips only). Only 140 + /* SDMA doorbell assignments (SOC15 and later chips only). Only 141 141 * specific doorbells are routed to each SDMA engine. Others 142 142 * are routed to IH and VCN. They are not usable by the CP. 143 - * 144 - * Any doorbell number D that satisfies the following condition 145 - * is reserved: (D & reserved_doorbell_mask) == reserved_doorbell_val 146 - * 147 - * KFD currently uses 1024 (= 0x3ff) doorbells per process. If 148 - * doorbells 0x0e0-0x0ff and 0x2e0-0x2ff are reserved, that means 149 - * mask would be set to 0x1e0 and val set to 0x0e0. 150 143 */ 151 - unsigned int sdma_doorbell[2][8]; 152 - unsigned int reserved_doorbell_mask; 153 - unsigned int reserved_doorbell_val; 144 + uint32_t *sdma_doorbell_idx; 145 + 146 + /* From SOC15 onward, the doorbell index range not usable for CP 147 + * queues. 148 + */ 149 + uint32_t non_cp_doorbells_start; 150 + uint32_t non_cp_doorbells_end; 154 151 155 152 /* Base address of doorbell aperture. */ 156 153 phys_addr_t doorbell_physical_address;
+3 -5
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
··· 139 139 static int smu10_init_dynamic_state_adjustment_rule_settings( 140 140 struct pp_hwmgr *hwmgr) 141 141 { 142 - uint32_t table_size = 143 - sizeof(struct phm_clock_voltage_dependency_table) + 144 - (7 * sizeof(struct phm_clock_voltage_dependency_record)); 142 + struct phm_clock_voltage_dependency_table *table_clk_vlt; 145 143 146 - struct phm_clock_voltage_dependency_table *table_clk_vlt = 147 - kzalloc(table_size, GFP_KERNEL); 144 + table_clk_vlt = kzalloc(struct_size(table_clk_vlt, entries, 7), 145 + GFP_KERNEL); 148 146 149 147 if (NULL == table_clk_vlt) { 150 148 pr_err("Can not allocate memory!\n");
+2
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
··· 3681 3681 data->force_pcie_gen = PP_PCIEGen2; 3682 3682 if (current_link_speed == PP_PCIEGen2) 3683 3683 break; 3684 + /* fall through */ 3684 3685 case PP_PCIEGen2: 3685 3686 if (0 == amdgpu_acpi_pcie_performance_request(hwmgr->adev, PCIE_PERF_REQ_GEN2, false)) 3686 3687 break; 3687 3688 #endif 3689 + /* fall through */ 3688 3690 default: 3689 3691 data->force_pcie_gen = smu7_get_current_pcie_speed(hwmgr); 3690 3692 break;
+1 -1
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c
··· 1211 1211 hwmgr->platform_descriptor.TDPAdjustment : 1212 1212 (-1 * hwmgr->platform_descriptor.TDPAdjustment); 1213 1213 1214 - if (hwmgr->chip_id > CHIP_TONGA) 1214 + if (hwmgr->chip_id > CHIP_TONGA) 1215 1215 target_tdp = ((100 + adjust_percent) * (int)(cac_table->usTDP * 256)) / 100; 1216 1216 else 1217 1217 target_tdp = ((100 + adjust_percent) * (int)(cac_table->usConfigurableTDP * 256)) / 100;
+3 -5
drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c
··· 272 272 struct pp_hwmgr *hwmgr, 273 273 ATOM_CLK_VOLT_CAPABILITY *disp_voltage_table) 274 274 { 275 - uint32_t table_size = 276 - sizeof(struct phm_clock_voltage_dependency_table) + 277 - (7 * sizeof(struct phm_clock_voltage_dependency_record)); 275 + struct phm_clock_voltage_dependency_table *table_clk_vlt; 278 276 279 - struct phm_clock_voltage_dependency_table *table_clk_vlt = 280 - kzalloc(table_size, GFP_KERNEL); 277 + table_clk_vlt = kzalloc(struct_size(table_clk_vlt, entries, 7), 278 + GFP_KERNEL); 281 279 282 280 if (NULL == table_clk_vlt) { 283 281 pr_err("Can not allocate memory!\n");
+24 -2
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_baco.c
··· 1 + /* 2 + * Copyright 2018 Advanced Micro Devices, Inc. 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 21 + * 22 + */ 1 23 #include "amdgpu.h" 2 24 #include "soc15.h" 3 25 #include "soc15_hw_ip.h" ··· 136 114 if (soc15_baco_program_registers(hwmgr, pre_baco_tbl, 137 115 ARRAY_SIZE(pre_baco_tbl))) { 138 116 if (smum_send_msg_to_smc(hwmgr, PPSMC_MSG_EnterBaco)) 139 - return -1; 117 + return -EINVAL; 140 118 141 119 if (soc15_baco_program_registers(hwmgr, enter_baco_tbl, 142 120 ARRAY_SIZE(enter_baco_tbl))) ··· 154 132 } 155 133 } 156 134 157 - return -1; 135 + return -EINVAL; 158 136 }
+2 -2
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_baco.h
··· 20 20 * OTHER DEALINGS IN THE SOFTWARE. 21 21 * 22 22 */ 23 - #ifndef __VEGA10_BOCO_H__ 24 - #define __VEGA10_BOCO_H__ 23 + #ifndef __VEGA10_BACO_H__ 24 + #define __VEGA10_BACO_H__ 25 25 #include "hwmgr.h" 26 26 #include "common_baco.h" 27 27
+25 -3
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_baco.c
··· 1 + /* 2 + * Copyright 2018 Advanced Micro Devices, Inc. 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 21 + * 22 + */ 1 23 #include "amdgpu.h" 2 24 #include "soc15.h" 3 25 #include "soc15_hw_ip.h" ··· 89 67 90 68 91 69 if(smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_EnterBaco, 0)) 92 - return -1; 70 + return -EINVAL; 93 71 94 72 } else if (state == BACO_STATE_OUT) { 95 73 if (smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ExitBaco)) 96 - return -1; 74 + return -EINVAL; 97 75 if (!soc15_baco_program_registers(hwmgr, clean_baco_tbl, 98 76 ARRAY_SIZE(clean_baco_tbl))) 99 - return -1; 77 + return -EINVAL; 100 78 } 101 79 102 80 return 0;
+2 -2
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_baco.h
··· 20 20 * OTHER DEALINGS IN THE SOFTWARE. 21 21 * 22 22 */ 23 - #ifndef __VEGA20_BOCO_H__ 24 - #define __VEGA20_BOCO_H__ 23 + #ifndef __VEGA20_BACO_H__ 24 + #define __VEGA20_BACO_H__ 25 25 #include "hwmgr.h" 26 26 #include "common_baco.h" 27 27
+1 -1
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
··· 3456 3456 disable_mclk_switching = ((1 < hwmgr->display_config->num_display) && 3457 3457 !hwmgr->display_config->multi_monitor_in_sync) || 3458 3458 vblank_too_short; 3459 - latency = hwmgr->display_config->dce_tolerable_mclk_in_active_latency; 3459 + latency = hwmgr->display_config->dce_tolerable_mclk_in_active_latency; 3460 3460 3461 3461 /* gfxclk */ 3462 3462 dpm_table = &(data->dpm_table.gfx_table);
+4
drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
··· 29 29 #include <drm/amdgpu_drm.h> 30 30 #include "smumgr.h" 31 31 32 + MODULE_FIRMWARE("amdgpu/bonaire_smc.bin"); 33 + MODULE_FIRMWARE("amdgpu/bonaire_k_smc.bin"); 34 + MODULE_FIRMWARE("amdgpu/hawaii_smc.bin"); 35 + MODULE_FIRMWARE("amdgpu/hawaii_k_smc.bin"); 32 36 MODULE_FIRMWARE("amdgpu/topaz_smc.bin"); 33 37 MODULE_FIRMWARE("amdgpu/topaz_k_smc.bin"); 34 38 MODULE_FIRMWARE("amdgpu/tonga_smc.bin");
+2
drivers/gpu/drm/radeon/ci_dpm.c
··· 4869 4869 pi->force_pcie_gen = RADEON_PCIE_GEN2; 4870 4870 if (current_link_speed == RADEON_PCIE_GEN2) 4871 4871 break; 4872 + /* fall through */ 4872 4873 case RADEON_PCIE_GEN2: 4873 4874 if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0) 4874 4875 break; 4875 4876 #endif 4877 + /* fall through */ 4876 4878 default: 4877 4879 pi->force_pcie_gen = ci_get_current_pcie_speed(rdev); 4878 4880 break;
+1
drivers/gpu/drm/radeon/evergreen_cs.c
··· 1299 1299 return -EINVAL; 1300 1300 } 1301 1301 ib[idx] += (u32)((reloc->gpu_offset >> 8) & 0xffffffff); 1302 + break; 1302 1303 case CB_TARGET_MASK: 1303 1304 track->cb_target_mask = radeon_get_ib_value(p, idx); 1304 1305 track->cb_dirty = true;
+2
drivers/gpu/drm/radeon/si_dpm.c
··· 5762 5762 si_pi->force_pcie_gen = RADEON_PCIE_GEN2; 5763 5763 if (current_link_speed == RADEON_PCIE_GEN2) 5764 5764 break; 5765 + /* fall through */ 5765 5766 case RADEON_PCIE_GEN2: 5766 5767 if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0) 5767 5768 break; 5768 5769 #endif 5770 + /* fall through */ 5769 5771 default: 5770 5772 si_pi->force_pcie_gen = si_get_current_pcie_speed(rdev); 5771 5773 break;
+26 -13
drivers/gpu/drm/scheduler/sched_entity.c
··· 52 52 { 53 53 int i; 54 54 55 - if (!(entity && rq_list && num_rq_list > 0 && rq_list[0])) 55 + if (!(entity && rq_list && (num_rq_list == 0 || rq_list[0]))) 56 56 return -EINVAL; 57 57 58 58 memset(entity, 0, sizeof(struct drm_sched_entity)); 59 59 INIT_LIST_HEAD(&entity->list); 60 - entity->rq = rq_list[0]; 60 + entity->rq = NULL; 61 61 entity->guilty = guilty; 62 62 entity->num_rq_list = num_rq_list; 63 63 entity->rq_list = kcalloc(num_rq_list, sizeof(struct drm_sched_rq *), ··· 67 67 68 68 for (i = 0; i < num_rq_list; ++i) 69 69 entity->rq_list[i] = rq_list[i]; 70 + 71 + if (num_rq_list) 72 + entity->rq = rq_list[0]; 73 + 70 74 entity->last_scheduled = NULL; 71 75 72 76 spin_lock_init(&entity->rq_lock); ··· 168 164 struct drm_gpu_scheduler *sched; 169 165 struct task_struct *last_user; 170 166 long ret = timeout; 167 + 168 + if (!entity->rq) 169 + return 0; 171 170 172 171 sched = entity->rq->sched; 173 172 /** ··· 271 264 */ 272 265 void drm_sched_entity_fini(struct drm_sched_entity *entity) 273 266 { 274 - struct drm_gpu_scheduler *sched; 267 + struct drm_gpu_scheduler *sched = NULL; 275 268 276 - sched = entity->rq->sched; 277 - drm_sched_rq_remove_entity(entity->rq, entity); 269 + if (entity->rq) { 270 + sched = entity->rq->sched; 271 + drm_sched_rq_remove_entity(entity->rq, entity); 272 + } 278 273 279 274 /* Consumption of existing IBs wasn't completed. Forcefully 280 275 * remove them here. 281 276 */ 282 277 if (spsc_queue_peek(&entity->job_queue)) { 283 - /* Park the kernel for a moment to make sure it isn't processing 284 - * our enity. 285 - */ 286 - kthread_park(sched->thread); 287 - kthread_unpark(sched->thread); 278 + if (sched) { 279 + /* Park the kernel for a moment to make sure it isn't processing 280 + * our enity. 281 + */ 282 + kthread_park(sched->thread); 283 + kthread_unpark(sched->thread); 284 + } 288 285 if (entity->dependency) { 289 286 dma_fence_remove_callback(entity->dependency, 290 287 &entity->cb); ··· 373 362 for (i = 0; i < entity->num_rq_list; ++i) 374 363 drm_sched_entity_set_rq_priority(&entity->rq_list[i], priority); 375 364 376 - drm_sched_rq_remove_entity(entity->rq, entity); 377 - drm_sched_entity_set_rq_priority(&entity->rq, priority); 378 - drm_sched_rq_add_entity(entity->rq, entity); 365 + if (entity->rq) { 366 + drm_sched_rq_remove_entity(entity->rq, entity); 367 + drm_sched_entity_set_rq_priority(&entity->rq, priority); 368 + drm_sched_rq_add_entity(entity->rq, entity); 369 + } 379 370 380 371 spin_unlock(&entity->rq_lock); 381 372 }
+2 -1
include/uapi/drm/amdgpu_drm.h
··· 272 272 273 273 /* sched ioctl */ 274 274 #define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1 275 + #define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2 275 276 276 277 struct drm_amdgpu_sched_in { 277 278 /* AMDGPU_SCHED_OP_* */ 278 279 __u32 op; 279 280 __u32 fd; 280 281 __s32 priority; 281 - __u32 flags; 282 + __u32 ctx_id; 282 283 }; 283 284 284 285 union drm_amdgpu_sched {