NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/55127: Possible memory leak in drm2 radeon_ttm.c



>Number:         55127
>Category:       kern
>Synopsis:       Possible memory leak in drm2 radeon_ttm.c
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 31 15:00:00 +0000 2020
>Originator:     Izumi Tsutsui
>Release:        NetBSD 9.0
>Organization:
>Environment:
System: NetBSD 9.0 GENERIC
Architecture: i386
Machine: i386
>Description:
In sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c,
radeon_ttm_tt_populate() calls drm_prime_bus_dmamap_load_sgt()
in sys/external/bsd/drm2/dist/drm/drm_prime.c and it calls
bus_dmamap_load_raw(9), but there is no bus_dmamap_unload()
in radeon_ttm_tt_unpopulate().

>How-To-Repeat:
Code inspection.

>Fix:
Call bus_dmamap_unload(9) in radeon_ttm_tt_unpopulate() as
i915_gem_object_get_pages_dmabuf() and i915_gem_object_put_pages_dmabuf()
in  sys/external/bsd/drm2/dist/drm/i915/i915_gem_dmabuf.c does?

Note this does not help kmem-96 leaks mentioned in PR/54818
 https://mail-index.netbsd.org/netbsd-bugs/2020/03/19/msg066605.html
but we should double-check all bus_dmamap_load(9) pairs?

Index: sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c
===================================================================
RCS file: /cvsroot/src/sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c,v
retrieving revision 1.15
diff -u -p -d -r1.15 radeon_ttm.c
--- sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c	27 Aug 2018 15:22:54 -0000	1.15
+++ sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c	31 Mar 2020 14:41:39 -0000
@@ -838,6 +838,11 @@ static void radeon_ttm_tt_unpopulate(str
 #endif
 	bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
 
+#ifdef __NetBSD__
+	if (slave && ttm->sg) {
+		bus_dmamap_unload(ttm->bdev->dmat, gtt->ttm.dma_address);
+	}
+#endif
 	if (gtt && gtt->userptr) {
 		kfree(ttm->sg);
 		ttm->page_flags &= ~TTM_PAGE_FLAG_SG;

---
Izumi Tsutsui



Home | Main Index | Thread Index | Old Index