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

Configure Feed

Select the types of activity you want to include in your feed.

amdgpu/vce: use amdgpu_gtt_mgr_alloc_entries

Instead of reserving a number of GTT pages for VCE 1.0 this
commit now uses amdgpu_gtt_mgr_alloc_entries to allocate
the pages when initializing vce 1.0.

While at it remove the "does the VCPU BO already have a
32-bit address" check as suggested by Timur.

This decouples vce init from gtt init.

---
v7: renamed variables (Christian)
---

Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Pierre-Eric Pelloux-Prayer and committed by
Alex Deucher
71aec08f 866eedef

+18 -36
-1
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
··· 332 332 ttm_resource_manager_init(man, &adev->mman.bdev, gtt_size); 333 333 334 334 start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS; 335 - start += amdgpu_vce_required_gart_pages(adev); 336 335 size = (adev->gmc.gart_size >> PAGE_SHIFT) - start; 337 336 drm_mm_init(&mgr->mm, start, size); 338 337 spin_lock_init(&mgr->lock);
-18
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
··· 451 451 } 452 452 453 453 /** 454 - * amdgpu_vce_required_gart_pages() - gets number of GART pages required by VCE 455 - * 456 - * @adev: amdgpu_device pointer 457 - * 458 - * Returns how many GART pages we need before GTT for the VCE IP block. 459 - * For VCE1, see vce_v1_0_ensure_vcpu_bo_32bit_addr for details. 460 - * For VCE2+, this is not needed so return zero. 461 - */ 462 - u32 amdgpu_vce_required_gart_pages(struct amdgpu_device *adev) 463 - { 464 - /* VCE IP block not added yet, so can't use amdgpu_ip_version */ 465 - if (adev->family == AMDGPU_FAMILY_SI) 466 - return 512; 467 - 468 - return 0; 469 - } 470 - 471 - /** 472 454 * amdgpu_vce_get_create_msg - generate a VCE create msg 473 455 * 474 456 * @ring: ring we should submit the msg to
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
··· 52 52 uint32_t srbm_soft_reset; 53 53 unsigned num_rings; 54 54 uint32_t keyselect; 55 + struct drm_mm_node gart_node; 55 56 }; 56 57 57 58 int amdgpu_vce_early_init(struct amdgpu_device *adev); ··· 62 61 int amdgpu_vce_suspend(struct amdgpu_device *adev); 63 62 int amdgpu_vce_resume(struct amdgpu_device *adev); 64 63 void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp); 65 - u32 amdgpu_vce_required_gart_pages(struct amdgpu_device *adev); 66 64 int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, struct amdgpu_job *job, 67 65 struct amdgpu_ib *ib); 68 66 int amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p,
+17 -16
drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
··· 47 47 #define VCE_V1_0_DATA_SIZE (7808 * (AMDGPU_MAX_VCE_HANDLES + 1)) 48 48 #define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02 49 49 50 - #define VCE_V1_0_GART_PAGE_START \ 51 - (AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS) 52 - #define VCE_V1_0_GART_ADDR_START \ 53 - (VCE_V1_0_GART_PAGE_START * AMDGPU_GPU_PAGE_SIZE) 54 - 55 50 static void vce_v1_0_set_ring_funcs(struct amdgpu_device *adev); 56 51 static void vce_v1_0_set_irq_funcs(struct amdgpu_device *adev); 57 52 ··· 530 535 */ 531 536 static int vce_v1_0_ensure_vcpu_bo_32bit_addr(struct amdgpu_device *adev) 532 537 { 533 - u64 gpu_addr = amdgpu_bo_gpu_offset(adev->vce.vcpu_bo); 534 538 u64 bo_size = amdgpu_bo_size(adev->vce.vcpu_bo); 535 539 u64 max_vcpu_bo_addr = 0xffffffff - bo_size; 536 540 u64 num_pages = ALIGN(bo_size, AMDGPU_GPU_PAGE_SIZE) / AMDGPU_GPU_PAGE_SIZE; 537 541 u64 pa = amdgpu_gmc_vram_pa(adev, adev->vce.vcpu_bo); 538 542 u64 flags = AMDGPU_PTE_READABLE | AMDGPU_PTE_WRITEABLE | AMDGPU_PTE_VALID; 543 + u64 vce_gart_start_offs; 544 + int r; 539 545 540 - /* 541 - * Check if the VCPU BO already has a 32-bit address. 542 - * Eg. if MC is configured to put VRAM in the low address range. 543 - */ 544 - if (gpu_addr <= max_vcpu_bo_addr) 545 - return 0; 546 + r = amdgpu_gtt_mgr_alloc_entries(&adev->mman.gtt_mgr, 547 + &adev->vce.gart_node, num_pages, 548 + DRM_MM_INSERT_LOW); 549 + if (r) 550 + return r; 551 + 552 + vce_gart_start_offs = amdgpu_gtt_node_to_byte_offset(&adev->vce.gart_node); 546 553 547 554 /* Check if we can map the VCPU BO in GART to a 32-bit address. */ 548 - if (adev->gmc.gart_start + VCE_V1_0_GART_ADDR_START > max_vcpu_bo_addr) 555 + if (adev->gmc.gart_start + vce_gart_start_offs > max_vcpu_bo_addr) 549 556 return -EINVAL; 550 557 551 - amdgpu_gart_map_vram_range(adev, pa, VCE_V1_0_GART_PAGE_START, 558 + amdgpu_gart_map_vram_range(adev, pa, adev->vce.gart_node.start, 552 559 num_pages, flags, adev->gart.ptr); 553 - adev->vce.gpu_addr = adev->gmc.gart_start + VCE_V1_0_GART_ADDR_START; 560 + adev->vce.gpu_addr = adev->gmc.gart_start + vce_gart_start_offs; 554 561 if (adev->vce.gpu_addr > max_vcpu_bo_addr) 555 562 return -EINVAL; 556 563 ··· 607 610 if (r) 608 611 return r; 609 612 610 - return amdgpu_vce_sw_fini(adev); 613 + r = amdgpu_vce_sw_fini(adev); 614 + 615 + amdgpu_gtt_mgr_free_entries(&adev->mman.gtt_mgr, &adev->vce.gart_node); 616 + 617 + return r; 611 618 } 612 619 613 620 /**