[PATCH] drm/amdgpu: validate the parameters of bo mapping operations more clearly

2024-04-12 Thread xinhui pan
Verify the parameters of amdgpu_vm_bo_(map/replace_map/clearing_mappings) in one common place. Reported-by: Vlad Stolyarov Suggested-by: Christian König Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 72 -- 1 file changed, 46 insertions(+), 26

[PATCH] drm/amdgpu: validate the parameters of bo mapping operations more clearly

2024-04-12 Thread xinhui pan
Verify the parameters of amdgpu_vm_bo_(map/replace_map/clearing_mappings) in one common place. Reported-by: Vlad Stolyarov Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 63 -- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git

[PATCH] drm/amdgpu: validate the parameters of amdgpu_vm_bo_clear_mappings

2024-04-10 Thread xinhui pan
Ensure there is no address overlapping. Reported-by: Vlad Stolyarov Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 8af3f0fd3073

[PATCH] drm/amdgpu: Move kfd suspend before evict resource

2023-09-20 Thread xinhui pan
Like amdgpu_device_reset_sriov does, kfd suspend should be called at the beginning to make sure kfd BO is idle. Otherwise the extra amdgpu_device_evict_resources fails or amdgpu_virt_request_full_gpu timeout. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- 1

[PATCH] drm/amdgpu: Ignore first evction failure during suspend

2023-09-11 Thread xinhui pan
that should still work fine in sriov full access mode. Fixes: 47ea20762bb7 ("drm/amdgpu: Add an extra evict_resource call during device_suspend.") Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git

[PATCH] drm/amdgpu: Ignore first evction failure during suspend

2023-09-07 Thread xinhui pan
extra evict_resource call during device_suspend.") Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 5c

[PATCH] drm/scheduler: Partially revert "drm/scheduler: track GPU active time per entity"

2023-08-16 Thread xinhui pan
access job->entity //memory overwitten As long as we can NOT guarantee entity is alive in this case, lets revert it for now. Signed-off-by: xinhui pan --- drivers/gpu/drm/scheduler/sched_main.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/dr

[PATCH v6] drm: Optimise for continuous memory allocation

2022-12-17 Thread xinhui pan
. Signed-off-by: xinhui pan --- change from v5: reworked --- drivers/gpu/drm/drm_buddy.c | 161 ++-- 1 file changed, 154 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c index 11bb59399471..6c795e1b3247 100644

[PATCH v5] drm: Optimise for continuous memory allocation

2022-11-29 Thread xinhui pan
+1 or 0+1+2+0 or 0+2+1+0. Without this patch, eviction is the final step to cleanup memory. Now there is a chance to delay the evction and then reduce the total count of evction. Signed-off-by: xinhui pan --- change from v4: Fix offset check by using <= instead of < Change patch descr

[PATCH v4] drm: Optimise for continuous memory allocation

2022-11-29 Thread xinhui pan
this patch aims to implement the rest cases. Adding a new member leaf_link which links all leaf blocks in asceding order. Now we can find more than 2 sub-order blocks easier. Say, order 4 can be combined with corresponding order 4, 2+2, 1+2+1, 0+1+2+0, 0+2+1+0. Signed-off-by: xinhui pan

[PATCH v3] drm: Optimise for continuous memory allocation

2022-11-27 Thread xinhui pan
this patch aims to implement the LR+RL case. Signed-off-by: xinhui pan --- change from v2: search continuous block in nearby root if needed change from v1: implement top-down continuous allocation --- drivers/gpu/drm/drm_buddy.c | 78 + 1 file changed, 71

[PATCH] drm/amdgpu: New method to check block continuous

2022-11-26 Thread xinhui pan
Blocks are not guarnteed to be in ascending order. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 21 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu

[PATCH v2] drm: Optimise for continuous memory allocation

2022-11-26 Thread xinhui pan
this patch aims to implement the LR+RL case. Signed-off-by: xinhui pan --- change from v1: implement top-down continuous allocation --- drivers/gpu/drm/drm_buddy.c | 66 + 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm

[PATCH] drm: Optimise for continuous memory allocation

2022-11-26 Thread xinhui pan
this patch aims to implement the LR+RL case. Signed-off-by: xinhui pan --- drivers/gpu/drm/drm_buddy.c | 56 - 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c index 11bb59399471

[PATCH] drm/amdgpu: Remove one duplicated ef removal

2022-07-07 Thread xinhui pan
That has been done in BO release notify. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 - 1 file changed, 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 0f9811d02f61

[PATCH] drm/amdgpu: Fix one list corruption when create queue fails

2022-07-07 Thread xinhui pan
Queue would be freed when create_queue_cpsch fails So lets do queue cleanup otherwise various list and memory issues happen. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git

[PATCH] drm/amdgpu: Fix a NULL pointer of fence

2022-07-07 Thread xinhui pan
Fence is accessed by dma_resv_add_fence() now. Use amdgpu_amdkfd_remove_eviction_fence instead. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

[PATCH] dma-buf: Fix one use-after-free of fence

2022-07-07 Thread xinhui pan
Need get the new fence when we replace the old one. Fixes: 047a1b877ed48 ("dma-buf & drm/amdgpu: remove dma_resv workaround") Signed-off-by: xinhui pan --- drivers/dma-buf/dma-resv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-resv.c b/d

[PATCH v2] drm/amdgpu: Fix one use-after-free of VM

2022-04-13 Thread xinhui pan
Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 17 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index

[PATCH v2] drm/amdgpu: Make sure ttm delayed work finished

2022-04-13 Thread xinhui pan
ttm_device_delayed_workqueue would reschedule itself if there is pending BO to be destroyed. So just one flush + cancel_sync is not enough. We still see lru_list not empty warnging. Fix it by waiting all BO to be destroyed. Acked-by: Guchun Chen Signed-off-by: xinhui pan --- drivers/gpu/drm

[PATCH] drm/amdgpu: Make sure ttm delayed work finished

2022-04-12 Thread xinhui pan
ttm_device_delayed_workqueue would reschedule itself if there is pending BO to be destroyed. So just one flush + cancel_sync is not enough. We still see lru_list not empty warnging. Fix it by waiting all BO to be destroyed. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu

[PATCH] drm/amdgpu: Fix one use-after-free of VM

2022-04-12 Thread xinhui pan
do_group_exit+0x50/0xc0 __x64_sys_exit_group+0x18/0x20 do_syscall_64+0x38/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae Suggested-by: Christian König Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 22 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 + 2

[RFC PATCH] drm/amdgpu: Fix one use-after-free of VM

2022-04-12 Thread xinhui pan
do_group_exit+0x50/0xc0 __x64_sys_exit_group+0x18/0x20 do_syscall_64+0x38/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers

[PATCH v2] drm/amdgpu: Fix null pointer access of BO

2021-12-02 Thread xinhui pan
ain first then alloc memory from specific domain. Suggested-by: Christian König Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/a

[PATCH] drm/amdgpu: Fix null pointer access of BO

2021-12-01 Thread xinhui pan
smem node to BO to make bo->resource valid. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index

[PATCH] drm/amdgpu: Fix double free of dmabuf

2021-11-19 Thread xinhui pan
amdgpu_amdkfd_gpuvm_free_memory_of_gpu drop dmabuf reference increased in amdgpu_gem_prime_export. amdgpu_bo_destroy drop dmabuf reference increased in amdgpu_gem_prime_import. So remove this extra dma_buf_put to avoid double free. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu

[PATCH 1/2] drm/ttm: Put BO in its memory manager's lru list

2021-11-09 Thread xinhui pan
After we move BO to a new memory region, we should put it to the new memory manager's lru list regardless we unlock the resv or not. Cc: sta...@vger.kernel.org Reviewed-by: Christian König Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_bo.c | 2 ++ 1 file changed, 2 insertions(+) diff

[PATCH 2/2] drm/ttm: Double check mem_type of BO while eviction

2021-11-09 Thread xinhui pan
BO might sit in a wrong lru list as there is a small period of memory moving and lru list updating. Lets skip eviction if we hit such mismatch. Suggested-by: Christian König Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion

[PATCH] drm/ttm: Put BO in its memory manager's lru list

2021-11-09 Thread xinhui pan
After we move BO to a new memory region, we should put it to the new memory manager's lru list regardless we unlock the resv or not. Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_bo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm

[PATCH] drm/amdgpu: Let BO created in its allowed_domain

2021-09-17 Thread xinhui pan
-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 66bb8a53bb20..9a547bb38cda 100644 --- a/drivers/gpu/drm/amd/amdgpu

[PATCH] drm/amdgpu: Fix uvd ib test timeout when use pre-allocated BO

2021-09-16 Thread xinhui pan
Now we use same BO for create/destroy msg. So destroy will wait for the fence returned from create to be signaled. The default timeout value in destroy is 10ms which is too short. Lets wait both fences with the specific timeout. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu

[PATCH v2] drm/amdgpu: Put drm_dev_enter/exit outside hot codepath

2021-09-15 Thread xinhui pan
-by: xinhui pan --- change from v1: add enter/exit in more gmc_set_pte_pde callers --- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 11 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 11 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 28 +--- 3 files changed, 36

[PATCH] drm/amdgpu: Put drm_dev_enter/exit outside hot codepath

2021-09-14 Thread xinhui pan
1.09% [drm] [k] drm_dev_exit So move drm_dev_enter/exit outside gmc code, instead let caller do it. They are gart_unbind, gart_map, vm_cpu_update(already hold in its caller) and gmc_init_pdb0(no need) Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 11

[PATCH v4 3/3] drm/amdgpu: VCN avoid memory allocation during IB test

2021-09-13 Thread xinhui pan
alloc extra msg from direct IB pool. Reviewed-by: Christian König Signed-off-by: xinhui pan --- change from v1: msg is aligned to gpu page boundary --- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 97 +++-- 1 file changed, 44 insertions(+), 53 deletions(-) diff --git

[PATCH v4 2/3] drm/amdgpu: VCE avoid memory allocation during IB test

2021-09-13 Thread xinhui pan
alloc extra msg from direct IB pool. Signed-off-by: xinhui pan --- change from v1: msg is allocated separately. msg is aligned to gpu page boundary --- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 27 - 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers

[PATCH v4 1/3] drm/amdgpu: UVD avoid memory allocation during IB test

2021-09-13 Thread xinhui pan
move BO allocation in sw_init. Signed-off-by: xinhui pan --- change from v3: drop the bo resv lock in ib test. --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 102 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 11 +-- drivers

[RFC PATCH v2] drm/ttm: Try to check if new ttm man out of bounds during compile

2021-09-13 Thread xinhui pan
Allow TTM know if vendor set new ttm mananger out of bounds by adding build_bug_on. Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_range_manager.c | 8 include/drm/ttm/ttm_device.h| 3 +++ include/drm/ttm/ttm_range_manager.h | 18 -- 3 files

[RFC PATCH 2/2] drm/amdgpu: protect ring from concurrency access

2021-09-12 Thread xinhui pan
Park the ring scheduler thread before accessing the ring. And unpark it only when we finish accessing the ring. The right sequence should be like below. lock ring park ring thread direct access ring [unlock ring, do something, lock ring] unpark ring thread unlock ring Signed-off-by: xinhui pan

[RFC PATCH 1/2] drm/amdgpu: Introduce ring lock

2021-09-12 Thread xinhui pan
This is used for direct IB submission to ring. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu

[RFC PATCH] drm/ttm: Try to check if new ttm man out of bounds during compile

2021-09-12 Thread xinhui pan
Allow TTM know if vendor set new ttm mananger out of bounds by adding build_bug_on. Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_range_manager.c | 2 ++ include/drm/ttm/ttm_device.h| 3 +++ include/drm/ttm/ttm_range_manager.h | 10 ++ 3 files changed, 15

[PATCH v2] drm/amdgpu: Fix a race of IB test

2021-09-12 Thread xinhui pan
Direct IB submission should be exclusive. So use write lock. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu

[PATCH] drm/amdgpu: Fix a race of IB test

2021-09-10 Thread xinhui pan
Direct IB submission should be exclusive. So use write lock. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu

[PATCH v3 2/3] drm/amdgpu: VCE avoid memory allocation during IB test

2021-09-10 Thread xinhui pan
alloc extra msg from direct IB pool. Signed-off-by: xinhui pan --- change from v1: let addr align up to gpu page boundary. --- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 27 - 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu

[PATCH v3 3/3] drm/amdgpu: VCN avoid memory allocation during IB test

2021-09-10 Thread xinhui pan
alloc extra msg from direct IB pool. Reviewed-by: Christian König Signed-off-by: xinhui pan --- change from v1: let addr align up to gpu page boundary. --- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 97 +++-- 1 file changed, 44 insertions(+), 53 deletions(-) diff --git

[PATCH v3 1/3] drm/amdgpu: UVD avoid memory allocation during IB test

2021-09-10 Thread xinhui pan
move BO allocation in sw_init. Signed-off-by: xinhui pan --- change from v2: use reservation trylock for direct IB test. change from v1: only use pre-allocated BO for direct IB submission. and take its reservation lock to avoid any potential race. better safe than sorry. --- drivers/gpu/drm/amd

[PATCH v2 1/3] drm/amdgpu: UVD avoid memory allocation during IB test

2021-09-10 Thread xinhui pan
move BO allocation in sw_init. Signed-off-by: xinhui pan --- change from v1: only use pre-allocated BO for direct IB submission. and take its reservation lock to avoid any potential race. better safe than sorry. --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 103 +--- drivers

[PATCH v2 2/3] drm/amdgpu: VCE avoid memory allocation during IB test

2021-09-10 Thread xinhui pan
alloc extra msg from direct IB pool. Signed-off-by: xinhui pan --- change from v1: let addr align up to gpu page boundary. --- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 27 - 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu

[PATCH v2 3/3] drm/amdgpu: VCN avoid memory allocation during IB test

2021-09-10 Thread xinhui pan
alloc extra msg from direct IB pool. Reviewed-by: Christian König Signed-off-by: xinhui pan --- change from v1: let addr align up to gpu page boundary. --- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 97 +++-- 1 file changed, 44 insertions(+), 53 deletions(-) diff --git

[PATCH 4/4] drm/amdgpu: VCN avoid memory allocation during IB test

2021-09-09 Thread xinhui pan
alloc extra msg from direct IB pool. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 99 +++-- 1 file changed, 45 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c index

[PATCH 3/4] drm/amdgpu: VCE avoid memory allocation during IB test

2021-09-09 Thread xinhui pan
alloc extra msg from direct IB pool. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 18 +++--- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c index

[PATCH 2/4] drm/amdgpu: UVD avoid memory allocation during IB test

2021-09-09 Thread xinhui pan
move BO allocation in sw_init. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 75 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 +-- drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 8 +-- 4 files

[PATCH 1/4] drm/amdgpu: Increase direct IB pool size

2021-09-09 Thread xinhui pan
Direct IB pool is used for vce/vcn IB extra msg too. Increase its size to AMDGPU_IB_POOL_SIZE. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu

[RFC PATCH v2 2/2] drm/amdgpu: IPs use IB test dedicated BO

2021-09-08 Thread xinhui pan
Let vce/uvd/vcn use it to avoid memory allocation during IB test. This is useful when memory is nearly used up and no BO can be evicted/swappout. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 51 --- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 9 +- drivers

[RFC PATCH v2 1/2] drm/amdgpu: Add IB test dedicated BOs

2021-09-08 Thread xinhui pan
Two dedicated VRAM and GTT BOs for IB test. Signed-off-by: xinhui pan --- change from v1 check the existence of uvd and clean the code --- drivers/gpu/drm/amd/amdgpu/amdgpu.h| 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c

[RFC PATCH 2/2] drm/amdgpu: IPs use IB test dedicated BO

2021-09-07 Thread xinhui pan
Let vce/uvd/vcn use it to avoid memory allocation during IB test. This is useful when memory is nearly used up and no BO can be evicted/swappout. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 51 --- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 9 +- drivers

[RFC PATCH 1/2] drm/amdgpu: Add IB test dedicated BOs

2021-09-07 Thread xinhui pan
Two dedicated VRAM and GTT BOs for IB test. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu.h| 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 54 ++ 3 files changed, 64 insertions(+) diff

[RFC PATCH v3] drm/amdgpu: alloc uvd msg from IB pool

2021-09-07 Thread xinhui pan
There is one dedicated IB pool for IB test. So lets use it for uvd msg too. For some older HW, use one reserved BO at specific range. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 173 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 2 + 2 files

[RFC PATCH v2] drm/amdgpu: alloc uvd msg from IB pool

2021-09-07 Thread xinhui pan
There is one dedicated IB pool for IB test. So lets use it for uvd msg too. For some older HW, use one reserved BO at specific range. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 174 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 2 + 2 files

[RFC PATCH] drm/amdgpu: alloc uvd msg from IB pool

2021-09-07 Thread xinhui pan
There is one dedicated IB pool for IB test. So lets use it for uvd msg too. For some older HW, use one reserved BO at specific range. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 174 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 2 + 2 files

[RFC PATCH] drm/amdgpu: alloc uvd msg from IB pool

2021-09-07 Thread xinhui pan
There is one dedicated IB pool for IB test. So lets use it for uvd msg too. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 223 +--- 1 file changed, 126 insertions(+), 97 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers

[RFC PATCH] drm/amdgpu: alloc uvd msg from IB pool

2021-09-07 Thread xinhui pan
There is one dedicated IB pool for IB test. So lets use it for uvd msg too. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 223 +--- 1 file changed, 126 insertions(+), 97 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers

[RFC PATCH] drm/amdgpu: alloc uvd msg from IB pool

2021-09-07 Thread xinhui pan
There is one dedicated IB pool for IB test. So lets use it for uvd msg too. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 223 +--- 1 file changed, 126 insertions(+), 97 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers

[resend PATCH] drm/ttm: Fix a deadlock if the target BO is not idle during swap

2021-09-06 Thread xinhui pan
wapout) will be stuck as we actually did not free any BO memory. This usually happens when the fence is not signaled for a long time. Signed-off-by: xinhui pan Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/g

[PATCH v2 1/2] drm/ttm: Fix a deadlock if the target BO is not idle during swap

2021-09-05 Thread xinhui pan
wapout) will be stuck as we actually did not free any BO memory. This usually happens when the fence is not signaled for a long time. Signed-off-by: xinhui pan Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/g

[PATCH v2 2/2] drm/amdpgu: Use VRAM domain in UVD IB test

2021-09-05 Thread xinhui pan
Like vce/vcn does, visible VRAM is OK for ib test. While commit a11d9ff3ebe0 ("drm/amdgpu: use GTT for uvd_get_create/destory_msg") says VRAM is not mapped correctly in his platform which is likely an arm64. So lets change back to use VRAM on x86_64 platform. Signed-off-by:

[PATCH v2 0/2] Fix a hung during memory pressure test

2021-09-05 Thread xinhui pan
dgpu_bo_unmap_and_free(bo1, bo1_va_handle, bo1_mc, sdma_write_length); CU_ASSERT_EQUAL(r, 0); -- *** BLURB HERE *** xinhui pan (2): drm/ttm: Fix a deadlock if the target BO is not idle during swap drm/amdpgu: Use VRAM domain in UVD IB test drivers/gpu/drm/amd/amd

[PATCH v3] drm/amdkfd: Fix some double free when destroy queue fails

2021-06-18 Thread xinhui pan
] destroy_queue_cpsch+0x20c/0x330 [amdgpu] pqm_destroy_queue+0x1a3/0x390 [amdgpu] kfd_ioctl_destroy_queue+0x57/0xc0 [amdgpu] Signed-off-by: xinhui pan --- .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 15 ++- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 4 +++- .../drm/amd

[PATCH v2 2/2] drm/amdkfd: Walk through list with dqm lock hold

2021-06-17 Thread xinhui pan
To avoid any list corruption. Signed-off-by: xinhui pan --- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 22 ++- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd

[PATCH v2 1/2] drm/amdkfd: Fix some double free when destroy queue fails

2021-06-17 Thread xinhui pan
[amdgpu] Signed-off-by: xinhui pan --- .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 13 + drivers/gpu/drm/amd/amdkfd/kfd_process.c| 4 +++- .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git

[PATCH 2/2] drm/amdkfd: Walk thorugh list with dqm lock hold

2021-06-16 Thread xinhui pan
To avoid any list corruption. Signed-off-by: xinhui pan --- .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c| 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd

[PATCH] drm/amdgpu: Set TTM_PAGE_FLAG_SG earlier for userprt BOs

2021-06-16 Thread xinhui pan
Because TTM do page counting on userptr BOs which is actually not needed. To avoid that, lets set TTM_PAGE_FLAG_SG after tt_create and before tt_populate. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff

[PATCH 1/2] drm/amdkfd: Fix some double free when destroy queue fails

2021-06-16 Thread xinhui pan
=7 pid=2511 kfree+0x322/0x340 free_mqd_hiq_sdma+0x20/0x60 [amdgpu] destroy_queue_cpsch+0x20c/0x330 [amdgpu] pqm_destroy_queue+0x1a3/0x390 [amdgpu] kfd_ioctl_destroy_queue+0x57/0xc0 [amdgpu] Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 2 ++ drivers

[RFC PATCH] drm/ttm: Do page counting after populate callback succeed

2021-06-15 Thread xinhui pan
-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_tt.c | 32 +--- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index a1a25410ec74..4fa0a8cd71c0 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu

[PATCH] drm/amdkfd: Fix a race between queue destroy and process termination

2021-06-15 Thread xinhui pan
We call free_mqd without dqm lock hold, that causes double free of mqd_mem_obj. Fix it by using a tmp pointer. We need walk through the queues_list with dqm lock hold. Otherwise hit list corruption. Signed-off-by: xinhui pan --- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 17

[PATCH] drm/amdgpu: Fix a BUG_ON due to resv trylock fails

2021-05-21 Thread xinhui pan
ss_zero)) dma_resv_unlock(resv) unlock lru_lock To fix it simply, let's acquire lru_lock before resv trylock to avoid the race above. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 ++ 1 file changed, 2 ins

[PATCH] drm/ttm: Skip swapout if ttm object is not populated

2021-05-21 Thread xinhui pan
Swapping a ttm object which has no backend pages makes no sense. Suggested-by: Christian König Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c

[PATCH] drm/amdgpu: Use dma_resv_lock instead in BO release_notify

2021-05-20 Thread xinhui pan
ctually this is not a bug if trylock fails. So use dma_resv_lock instead. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd

[PATCH] drm/amdgpu: Let userptr BO ttm have TTM_PAGE_FLAG_SG set

2021-05-19 Thread xinhui pan
n BO A // memory overwritten To fix this issue, we can set TTM_PAGE_FLAG_SG when we create userptr BO ttm. Then swapout function would not swap it. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4

[RFC PATCH 2/2] drm/ttm: skip swapout when ttm has no backend page.

2021-05-18 Thread xinhui pan
Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c index 510e3e001dab..a9772fcc8f9c 100644 --- a/drivers/gpu/drm/ttm/ttm_device.c +++ b/drivers/gpu/drm/ttm

[RFC PATCH 1/2] drm/amdgpu: Fix memory corruption due to swapout and swapin

2021-05-18 Thread xinhui pan
ion too. But I hit page fault mostly. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdg

[PATCH] drm/amdgpu: Fix a use-after-free

2021-05-17 Thread xinhui pan
0 [amdgpu] [ 1236.046912] kfd_ioctl+0x463/0x690 [amdgpu] [ 1236.051632] ? kfd_dev_is_large_bar+0xf0/0xf0 [amdgpu] [ 1236.057360] __x64_sys_ioctl+0x91/0xc0 [ 1236.061457] do_syscall_64+0x38/0x90 [ 1236.065383] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 1236.070920] RIP: 0033:0x7f5013dbe50b Signed-off-b

[PATCH 2/2] drm/radeon: Fix size overflow

2021-04-07 Thread xinhui pan
ttm->num_pages is uint32. Hit overflow when << PAGE_SHIFT directly Signed-off-by: xinhui pan --- drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_tt

[PATCH 1/2] drm/amdgpu: Fix size overflow

2021-04-07 Thread xinhui pan
ttm->num_pages is uint32. Hit overflow when << PAGE_SHIFT directly Fix: 230c079fd (drm/ttm: make num_pages uint32_t) Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amd

[PATCH] drm/amdgpu: Fix size overflow

2021-04-07 Thread xinhui pan
ttm->num_pages is uint32. Hit overflow when << PAGE_SHIFT directly Fix: 230c079fd (drm/ttm: make num_pages uint32_t) Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amd

[PATCH] drm/amdgpu: Use correct size when access vram

2021-03-21 Thread xinhui pan
To make size is 4 byte aligned. Use &~0x3ULL instead of &3ULL. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm

[PATCH] drm/amdgpu: Fix memory leak

2021-03-17 Thread xinhui pan
drm_gem_object_put() should be paired with drm_gem_object_lookup(). All gem objs are saved in fb->base.obj[]. Need put the old first before assign a new obj. Trigger VRAM leak by running command below $ service gdm restart Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amd

[PATCH] drm/ttm: Do not add non-system domain BO into swap list

2021-02-23 Thread xinhui pan
BO would be added into swap list if it is validated into system domain. If BO is validated again into non-system domain, say, VRAM domain. It actually should not be in the swap list. Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_bo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git

[PATCH] drm/ttm: Fix a memory leak

2021-02-18 Thread xinhui pan
Free the memory on failure. Also no need to re-alloc memory on retry. Signed-off-by: xinhui pan --- drivers/gpu/drm/ttm/ttm_bo.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index e38102282fd5

[PATCH] drm/amdgpu: Fix a false positive when pin non-VRAM memory

2021-01-29 Thread xinhui pan
Flag TTM_PL_FLAG_CONTIGUOUS is only valid for VRAM domain. So fix the false positive by checking memory type too. Suggested-by: Felix Kuehling Acked-by: Christian König Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- 1 file changed, 2 insertions(+), 1

[PATCH] drm/amdgpu: Fix size calculation when init onchip memory

2020-10-22 Thread xinhui pan
Size is page count here. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 4a85f8cedd77..11dd3d9eac15 100644

[PATCH v3] amd/amdgpu: Fix resv shared fence overflow

2020-10-12 Thread xinhui pan
during vm init and bo moving. But looks like we forget to reserve the immediate shared fence slot during vm fault. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm

[PATCH v2] amd/amdgpu: Fix resv shared fence overflow

2020-09-28 Thread xinhui pan
-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 37221b99ca96..9e0116c7f8d1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b

[PATCH] amd/amdgpu: Fix resv shared fence overflow

2020-09-28 Thread xinhui pan
ves. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 37221b99ca96..77689cecd189 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c ++

[PATCH] drm/amdgpu: Revert "drm/amdgpu: stop allocating dummy GTT nodes"

2020-09-01 Thread xinhui pan
979.354934] CR2: 94dfc4bc [ 979.358566] ---[ end trace 5b622843e4242519 ]--- Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 104 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 +--- 2 files changed, 80 insertions(+), 42 deletions(-) diff

[PATCH] drm/amdgpu: Fix kernel panic while gpu recovery

2020-04-19 Thread xinhui pan
Ras error occurs while gpu recovery. We can not add its list head to two lists at same time. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b

[PATCH] drm/ttm: Break out the loops if need_resched in bo delayed delete worker

2020-04-10 Thread xinhui pan
The delayed delete list is per device which might be very huge. And in a heavy workload test, the list might always not be empty. That will trigger any RCU stall warnings or softlockups in non-preemptible kernels Lets do break out the loops in that case. Signed-off-by: xinhui pan --- drivers

[PATCH] drm/ttm: Schedule out if possibe in bo delayed delete worker

2020-04-08 Thread xinhui pan
The delayed delete list is per device which might be very huge. And in a heavy workload test, the list might always not be empty. That will trigger any RCU stall warnings or softlockups in non-preemptible kernels Lets do schedule out if possible in that case. Signed-off-by: xinhui pan

[PATCH v2] drm/amdgpu: implement more ib pools

2020-03-26 Thread xinhui pan
We have three ib pools, they are normal, VM, direct pools. Any jobs which schedule IBs without dependence on gpu scheduler should use DIRECT pool. Any jobs schedule direct VM update IBs should use VM pool. Any other jobs use NORMAL pool. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd

[RFC PATCH 2/2] drm/amdgpu: use new job alloc variation if possible

2020-03-26 Thread xinhui pan
use corresponding ib pool for each job Signed-off-by: xinhui pan --- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c| 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 5 +++-- drivers/gpu

[RFC PATCH 1/2] drm/amdgpu: implement more ib pools

2020-03-26 Thread xinhui pan
We have tree ib pools, they are normal, VM, direct pools. Any jobs which schedule IBs without dependence on gpu scheduler should use DIRECT pool. Any jobs schedule direct VM update IBs should use VM pool. Any other jobs use NORMAL pool. Signed-off-by: xinhui pan --- drivers/gpu/drm/amd

  1   2   >