[PATCH v11 1/5] drm: add drm_memory_stats_is_zero

2024-12-12 Thread Yunxiang Li
Add a helper to check if the memory stats is zero, this will be used to check for memory accounting errors. Signed-off-by: Yunxiang Li Reviewed-by: Christian König CC: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_file.c | 10 ++ include/drm/drm_file.h | 1 + 2 files

[PATCH v11 3/5] Documentation/gpu: Clarify drm memory stats definition

2024-12-12 Thread Yunxiang Li
having both is better for back-compat. Also re-order the paragraphs to flow better. Signed-off-by: Yunxiang Li Reviewed-by: Tvrtko Ursulin CC: dri-devel@lists.freedesktop.org --- Documentation/gpu/drm-usage-stats.rst | 54 +-- 1 file changed, 27 insertions(+), 27 del

[PATCH v11 2/5] drm: make drm-active- stats optional

2024-12-12 Thread Yunxiang Li
ptional to enable amdgpu to switch to the second method. Signed-off-by: Yunxiang Li Reviewed-by: Tvrtko Ursulin CC: dri-devel@lists.freedesktop.org CC: intel-...@lists.freedesktop.org CC: amd-...@lists.freedesktop.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 1 + drivers/gpu/drm/

[PATCH v10 4/6] drm: consider GEM object shared when it is exported

2024-12-10 Thread Yunxiang Li
o get notified when GEM object is being shared. Signed-off-by: Yunxiang Li CC: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_gem.c | 3 +++ drivers/gpu/drm/drm_prime.c | 3 +++ include/drm/drm_gem.h | 12 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --

[PATCH v10 2/6] drm: make drm-active- stats optional

2024-12-10 Thread Yunxiang Li
ptional to enable amdgpu to switch to the second method. Signed-off-by: Yunxiang Li Reviewed-by: Tvrtko Ursulin CC: dri-devel@lists.freedesktop.org CC: intel-...@lists.freedesktop.org CC: amd-...@lists.freedesktop.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 1 + drivers/gpu/drm/

[PATCH v10 3/6] Documentation/gpu: Clarify drm memory stats definition

2024-12-10 Thread Yunxiang Li
having both is better for back-compat. Also re-order the paragraphs to flow better. Signed-off-by: Yunxiang Li Reviewed-by: Tvrtko Ursulin CC: dri-devel@lists.freedesktop.org --- Documentation/gpu/drm-usage-stats.rst | 54 +-- 1 file changed, 27 insertions(+), 27 del

[PATCH v10 1/6] drm: add drm_memory_stats_is_zero

2024-12-10 Thread Yunxiang Li
Add a helper to check if the memory stats is zero, this will be used to check for memory accounting errors. Signed-off-by: Yunxiang Li Reviewed-by: Christian König CC: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_file.c | 10 ++ include/drm/drm_file.h | 1 + 2 files

[PATCH v9 1/5] drm: add drm_memory_stats_is_zero

2024-11-28 Thread Yunxiang Li
Add a helper to check if the memory stats is zero, this will be used to check for memory accounting errors. Signed-off-by: Yunxiang Li Reviewed-by: Christian König CC: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_file.c | 10 ++ include/drm/drm_file.h | 1 + 2 files

[PATCH v9 3/5] Documentation/gpu: Clarify drm memory stats definition

2024-11-28 Thread Yunxiang Li
y- is legacy, amdgpu only behavior. Re-order the paragraphs to flow better as well. Signed-off-by: Yunxiang Li CC: dri-devel@lists.freedesktop.org --- Documentation/gpu/drm-usage-stats.rst | 54 +-- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Documentation/gp

[PATCH v9 2/5] drm: make drm-active- stats optional

2024-11-28 Thread Yunxiang Li
ptional to enable amdgpu to switch to the second method. Signed-off-by: Yunxiang Li CC: dri-devel@lists.freedesktop.org CC: intel-...@lists.freedesktop.org CC: amd-...@lists.freedesktop.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 1 + drivers/gpu/drm/drm_file.c

[PATCH v8 3/5] Documentation/gpu: Clarify drm memory stats definition

2024-11-15 Thread Yunxiang Li
having both is better for back-compat. Also re-order the paragraphs to flow better. Signed-off-by: Yunxiang Li CC: dri-devel@lists.freedesktop.org --- Documentation/gpu/drm-usage-stats.rst | 36 --- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/Docume

[PATCH v8 2/5] drm: make drm-active- stats optional

2024-11-15 Thread Yunxiang Li
ptional to enable amdgpu to switch to the second method. Signed-off-by: Yunxiang Li CC: dri-devel@lists.freedesktop.org CC: intel-...@lists.freedesktop.org CC: amd-...@lists.freedesktop.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 1 + drivers/gpu/drm/drm_file.c

[PATCH v8 1/5] drm: add drm_memory_stats_is_zero

2024-11-15 Thread Yunxiang Li
Add a helper to check if the memory stats is zero, this will be used to check for memory accounting errors. Signed-off-by: Yunxiang Li Reviewed-by: Christian König CC: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_file.c | 10 ++ include/drm/drm_file.h | 1 + 2 files

[PATCH v8 2/4] drm: make drm-active- stats optional

2024-11-11 Thread Yunxiang Li
drm-active- optional to enable amdgpu to switch to the second method. Signed-off-by: Yunxiang Li CC: dri-devel@lists.freedesktop.org CC: intel-...@lists.freedesktop.org CC: amd-...@lists.freedesktop.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 1 + drivers/gpu/drm/drm_file.c

[PATCH v7 1/4] drm: add drm_memory_stats_is_zero

2024-11-10 Thread Yunxiang Li
Add a helper to check if the memory stats is zero, this will be used to check for memory accounting errors. Signed-off-by: Yunxiang Li Reviewed-by: Christian König CC: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_file.c | 10 ++ include/drm/drm_file.h | 1 + 2 files

[PATCH v6 0/5] rework bo mem stats tracking

2024-10-25 Thread Yunxiang Li
7;t know where would be a good place to add such info, especially how I could remove a BO's stat when it's fence is signaled. Yunxiang Li (5): drm/amdgpu: remove unused function parameter drm/amdgpu: make drm-memory-* report resident memory drm/amdgpu: stop tracking v

[PATCH v6 1/5] drm/amdgpu: remove unused function parameter

2024-10-25 Thread Yunxiang Li
amdgpu_vm_bo_invalidate doesn't use the adev parameter and not all callers have a reference to adev handy, so remove it for cleanliness. Signed-off-by: Yunxiang Li Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_

[PATCH v6 4/5] drm: add drm_memory_stats_is_zero

2024-10-25 Thread Yunxiang Li
Add a helper to check if the memory stats is zero, this will be used to check for memory accounting errors. Signed-off-by: Yunxiang Li --- drivers/gpu/drm/drm_file.c | 9 + include/drm/drm_file.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/gpu/drm/drm_file.c b

[PATCH v6 5/5] drm/amdgpu: track bo memory stats at runtime

2024-10-25 Thread Yunxiang Li
ision, we track the BOs as they change states. This way when the fdinfo is queried we only need to take the status lock and copy out the usage stats with minimal impact to the runtime performance. Signed-off-by: Yunxiang Li --- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 14 +- drivers/gpu/dr

[PATCH v6 3/5] drm/amdgpu: stop tracking visible memory stats

2024-10-25 Thread Yunxiang Li
Since on modern systems all of vram can be made visible anyways, to simplify the new implementation, drops tracking how much memory is visible for now. If this is really needed we can add it back on top of the new implementation. Signed-off-by: Yunxiang Li Reviewed-by: Christian König

[PATCH v6 2/5] drm/amdgpu: make drm-memory-* report resident memory

2024-10-25 Thread Yunxiang Li
The old behavior reports the resident memory usage for this key and the documentation say so as well. However this was accidentally changed to include buffers that was evicted. Fixes: a2529f67e2ed ("drm/amdgpu: Use drm_print_memory_stats helper from fdinfo") Signed-off-by: Yunxiang Li

[PATCH v5 4/4] drm/amdgpu: track bo memory stats at runtime

2024-10-18 Thread Yunxiang Li
ision, we track the BOs as they change states. This way when the fdinfo is queried we only need to take the status lock and copy out the usage stats with minimal impact to the runtime performance. Signed-off-by: Yunxiang Li --- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 14 +- drivers/gpu/dr

[PATCH v5 1/4] drm/amdgpu: remove unused function parameter

2024-10-18 Thread Yunxiang Li
amdgpu_vm_bo_invalidate doesn't use the adev parameter and not all callers have a reference to adev handy, so remove it for cleanliness. Signed-off-by: Yunxiang Li --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +- drivers/gpu/dr

[PATCH v5 3/4] drm/amdgpu: stop tracking visible memory stats

2024-10-18 Thread Yunxiang Li
Since on modern systems all of vram can be made visible anyways, to simplify the new implementation, drops tracking how much memory is visible for now. If this is really needed we can add it back on top of the new implementation, or just report all the BOs as visible. Signed-off-by: Yunxiang Li

[PATCH v5 2/4] drm/amdgpu: make drm-memory-* report resident memory

2024-10-18 Thread Yunxiang Li
The old behavior reports the resident memory usage for this key and the documentation say so as well. However this was accidentally changed to include buffers that was evicted. Fixes: a2529f67e2ed ("drm/amdgpu: Use drm_print_memory_stats helper from fdinfo") Signed-off-by: Y

[PATCH v5 0/4] rework bo mem stats tracking

2024-10-18 Thread Yunxiang Li
n a modern system all of VRAM can be mapped if needed. v5: rebase on top of the drm_print_memory_stats refactor Yunxiang Li (4): drm/amdgpu: remove unused function parameter drm/amdgpu: make drm-memory-* report resident memory drm/amdgpu: stop tracking visible memory stats drm/amdgpu: track

[PATCH] drm/sched: test before reading fence timestamp

2023-09-08 Thread Yunxiang Li
Reading fence timestamp always need to check the corresponding flag bit before to make sure the write is actually visible, otherwise we can read garbage here. Fixes: 1774baa64f93 ("drm/scheduler: Change scheduled fence track v2") Signed-off-by: Yunxiang Li --- drivers/gpu/drm

[PATCH v3] dma-buf: allow nested dma_resv_reserve_fences

2023-06-23 Thread Yunxiang Li
. This fixes issue where ttm_bo_mem_space's reserve is ignored in various amdgpu ioctl paths, and was causing soft-lockup when VRAM is exhausted. v2: try to avoid memory corruption if possible. Signed-off-by: Yunxiang Li --- v3: fix typo drivers/dma-buf/dma-resv.c

[PATCH v2] dma-buf: allow nested dma_resv_reserve_fences

2023-06-23 Thread Yunxiang Li
. This fixes issue where ttm_bo_mem_space's reserve is ignored in various amdgpu ioctl paths, and was causing soft-lockup when VRAM is exhausted. v2: try to avoid memory corruption if possible. Signed-off-by: Yunxiang Li --- drivers/dma-buf/dma-resv.c

[PATCH v2] drm/ttm: fix bulk_move corruption when adding a entry

2023-06-22 Thread Yunxiang Li
ng v5") Signed-off-by: Yunxiang Li --- v2: style cleanup drivers/gpu/drm/ttm/ttm_resource.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c index 7333f7a87a2f..e51dbc7a2d53 100644 --- a/drivers/g

[PATCH 2/2] dma-buf: allow nested dma_resv_reserve_fences

2023-06-21 Thread Yunxiang Li
check are now stricter and need to be enabled all the time. This fixes issue where ttm_bo_mem_space's reserve is ignored in various amdgpu ioctl paths, and was causing fence lost leading to soft-lockup when VRAM is exhausted. Signed-off-by: Yunxiang Li --- drivers/dma-buf/dma-resv.c

[PATCH 1/2] drm/amdgpu: fix missing fence reserve in amdgpu_vm_sdma_commit

2023-06-21 Thread Yunxiang Li
When amdgpu_bo_fence is converted to dma_resv_add_fence, the reserve was removed in that process, so putting it back. Fixes: 4247084057cf ("drm/amdgpu: use DMA_RESV_USAGE_BOOKKEEP v2") Signed-off-by: Yunxiang Li --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 4 1 file

[PATCH 0/2] drm: fix soft lockup when saturating vram

2023-06-21 Thread Yunxiang Li
When running multiple graphical application and vram is saturated, the excessive swapping triggers the BUG_ON() in dma_resv_add_fences. The root cause is that calling dma_resv_reserve_fences twice would shadow the second call and this happens in amdgpu_cs_ioctl/amdgpu_gem_va_ioctl path shadowing re

[PATCH] drm/ttm: fix bulk_move corruption when adding a entry

2023-06-21 Thread Yunxiang Li
ng v5") Signed-off-by: Yunxiang Li --- drivers/gpu/drm/ttm/ttm_resource.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c index 7333f7a87a2f..4b84cfb5f916 100644 --- a/drivers/gpu/drm/ttm/ttm_resour

[PATCH 1/2] drm: Fix vblank refcount during modeset

2022-07-22 Thread Yunxiang Li
drm_crtc_vblank_on later re-enables vblank if the refcount is not zero, letting drm_vblank_get succeed during modeset should fix the behavior. Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/1380 Signed-off-by: Yunxiang Li --- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1

[PATCH 2/2] drm: get lock before accessing vblank refcount

2022-07-22 Thread Yunxiang Li
Acquire vbl_lock before accessing vblank refcount in drm_vblank_put, just like everywhere else that access the refcount. Signed-off-by: Yunxiang Li --- drivers/gpu/drm/drm_vblank.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b