All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drm/buddy: fix issue that force_merge cannot free all roots
@ 2024-12-26  7:01 Arunpravin Paneer Selvam
  2024-12-26  7:01 ` [PATCH v2 2/2] drm/buddy: Add a testcase to verify the multiroot fini Arunpravin Paneer Selvam
  0 siblings, 1 reply; 8+ messages in thread
From: Arunpravin Paneer Selvam @ 2024-12-26  7:01 UTC (permalink / raw)
  To: dri-devel, amd-gfx, matthew.auld
  Cc: christian.koenig, alexander.deucher, Arunpravin Paneer Selvam,
	Lin . Cao

From: Lin.Cao <lincao12@amd.com>

If buddy manager have more than one roots and each root have sub-block
need to be free. When drm_buddy_fini called, the first loop of
force_merge will merge and free all of the sub block of first root,
which offset is 0x0 and size is biggest(more than have of the mm size).
In subsequent force_merge rounds, if we use 0 as start and use remaining
mm size as end, the block of other roots will be skipped in
__force_merge function. It will cause the other roots can not be freed.

Solution: use roots' offset as the start could fix this issue.

Signed-off-by: Lin.Cao <lincao12@amd.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/drm_buddy.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
index 103c185bb1c8..ca42e6081d27 100644
--- a/drivers/gpu/drm/drm_buddy.c
+++ b/drivers/gpu/drm/drm_buddy.c
@@ -324,7 +324,7 @@ EXPORT_SYMBOL(drm_buddy_init);
  */
 void drm_buddy_fini(struct drm_buddy *mm)
 {
-	u64 root_size, size;
+	u64 root_size, size, start;
 	unsigned int order;
 	int i;
 
@@ -332,7 +332,8 @@ void drm_buddy_fini(struct drm_buddy *mm)
 
 	for (i = 0; i < mm->n_roots; ++i) {
 		order = ilog2(size) - ilog2(mm->chunk_size);
-		__force_merge(mm, 0, size, order);
+		start = drm_buddy_block_offset(mm->roots[i]);
+		__force_merge(mm, start, start + size, order);
 
 		WARN_ON(!drm_buddy_block_is_free(mm->roots[i]));
 		drm_block_free(mm, mm->roots[i]);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-01-15 14:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-26  7:01 [PATCH v2 1/2] drm/buddy: fix issue that force_merge cannot free all roots Arunpravin Paneer Selvam
2024-12-26  7:01 ` [PATCH v2 2/2] drm/buddy: Add a testcase to verify the multiroot fini Arunpravin Paneer Selvam
2025-01-06  9:51   ` Matthew Auld
2025-01-06 12:37   ` Paneer Selvam, Arunpravin
2025-01-06 12:40     ` Matthew Auld
2025-01-15 11:38   ` Jani Nikula
2025-01-15 13:53     ` Paneer Selvam, Arunpravin
2025-01-15 12:12   ` [v2,2/2] " Hellstrom, Thomas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.