Bug 54111

Summary: [IVB]I-G-T prime test/module_reload fail with *ERROR* “Memory manager not clean. Delaying takedown”
Product: DRI Reporter: Guang Yang <guang.a.yang>
Component: DRM/IntelAssignee: Imre Deak <imre.deak>
Status: CLOSED FIXED QA Contact: Intel GFX Bugs mailing list <intel-gfx-bugs>
Severity: normal    
Priority: medium CC: ben, bingx.a.yan, chris, daniel, jani.nikula, jbarnes, yangweix.shui
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on: 59229    
Bug Blocks: 63404    
Attachments:
Description Flags
dmesg info after running module_reload
none
dmesg running igt on top of current dinq + the patch
none
new_moudle_reload.dmesg none

Description Guang Yang 2012-08-27 09:16:16 UTC
Created attachment 66166 [details]
dmesg info after running module_reload

System Environment:
--------------------------
Platform:        Ivybridge
Kernel: (drm-intel-next-queued)7788a765205f63abcb8645c16c85a968bd578f4f
Bug detailed description:
-------------------------
   On IVB platform, running module_reload after prime_self_import will
fail and dmesg shows:
[drm:drm_mm_takedown] *ERROR* Memory manager not clean. Delaying takedown
 I attach the dmesg.
Comment 1 Jani Nikula 2012-08-27 12:55:34 UTC
The problem bisects to

commit 2dad9d4d057a080a4ad59c705b3e388af6794576
Author: Dave Airlie <airlied@redhat.com>
Date:   Tue May 29 15:11:22 2012 +0100

    i915: add stub dma-buf mmap callback.

which just means the dma_buf_export() call in i915_gem_prime_export() no longer fails, and the dma-buf code is exercised. There is an object reference leak somewhere.

Just the first parts of prime_self_import consisting of DRM_IOCTL_I915_GEM_CREATE, DRM_IOCTL_PRIME_HANDLE_TO_FD, RM_IOCTL_PRIME_FD_TO_HANDLE, and DRM_IOCTL_I915_GEM_MMAP_GTT is sufficient to reproduce.
Comment 2 Daniel Vetter 2012-09-17 06:23:21 UTC
*** Bug 54996 has been marked as a duplicate of this bug. ***
Comment 3 shui yangwei 2012-10-18 08:49:41 UTC
This issue also exist with 
Kernel: (drm-intel-testing)6760818aad5622d7f20d7f1c45d75a8165aeaf24
I tested.
Comment 4 Daniel Vetter 2012-12-18 09:22:06 UTC
Can you please retest with

https://patchwork.kernel.org/patch/1511931/

applied? If it doesn't apply any longer, I can rebase the patch.
Comment 5 Jani Nikula 2012-12-18 15:19:22 UTC
(In reply to comment #4)
> Can you please retest with
> 
> https://patchwork.kernel.org/patch/1511931/
> 
> applied? If it doesn't apply any longer, I can rebase the patch.

I tried the patch earlier, and retested it on top of current dinq, resulting in:
http://mid.gmane.org/874nmjh995.fsf@intel.com

Then I realized my i-g-t was out of date, and after updating, some test oopsed with the patch, and without the patch all tests pass. Confused. Has something related changed in tests lately?
Comment 6 Jani Nikula 2012-12-18 15:45:10 UTC
Created attachment 71737 [details]
dmesg running igt on top of current dinq + the patch

Tail of the 'make test' where the gp fault happens.

[...]
PASS: gem_pread_after_blit
testing untiled->tiled
testing tiled->tiled
testing tiled->untiled
PASS: gem_set_tiling_vs_gtt
testing pwrite on tiled buffer
testing pwrite on untiled, but still fenced buffer
PASS: gem_set_tiling_vs_pwrite
PASS: gem_tiled_pread
gem_tiled_pread_pwrite: 100%
PASS: gem_tiled_pread_pwrite
Comment 7 shui yangwei 2012-12-19 03:30:58 UTC
(In reply to comment #4)
> Can you please retest with
> 
> https://patchwork.kernel.org/patch/1511931/
> 
> applied? If it doesn't apply any longer, I can rebase the patch.


lscpi:
----------
00:02.0 VGA compatible controller: Intel Corporation Ivy Bridge Graphics Controller (rev 09)


On top of current dinq + the patch, after running case prime_self_import,
console display:
-------------------------------------
prime_self_import: prime_self_import.c:61: check_bo: Assertion `ptr1' failed.
Aborted (core dumped)
Comment 8 Jani Nikula 2013-01-11 12:10:03 UTC
*** Bug 59229 has been marked as a duplicate of this bug. ***
Comment 9 Daniel Vetter 2013-01-11 13:37:06 UTC
Can you please retest whether anything changes with latest -nightly: drm-fixes (_not_ drm-intel-fixes) contains a patch which might plug this leak:

commit be8a42ae60addd8b6092535c11b42d099d6470ec
Author: Seung-Woo Kim <sw0312.kim@samsung.com>
Date:   Thu Sep 27 15:30:06 2012 +0900

    drm/prime: drop reference on imported dma-buf come from gem
Comment 10 yanbing 2013-01-14 02:18:39 UTC
1.After revert commit be8a42ae60addd8b6092535c11b42d099d6470ec,retest this.
2.The case prime_self_import was pass.
3.Running module_reload after prime_self_import will
fail and dmesg shows:
[drm:drm_mm_takedown] *ERROR* Memory manager not clean. Delaying takedown.

This kind of phenomenon was reappeared.

I attach the new_module_reload.dmesg.
Comment 11 yanbing 2013-01-14 02:19:33 UTC
Created attachment 72975 [details]
new_moudle_reload.dmesg
Comment 12 Ben Widawsky 2013-04-17 18:35:22 UTC
Still have this issue?
Comment 13 Daniel Vetter 2013-04-17 19:09:23 UTC
I think Imre is now banging his head against this ...
Comment 14 Imre Deak 2013-04-17 22:22:35 UTC
(In reply to comment #13)
> I think Imre is now banging his head against this ...

If think commit be8a42ae60 fixed the issue in the bug description. comment #10 seems to support this and I can't reproduce that issue with current drm-intel-nightly either.

Unfortunately commit be8a42ae60 also introduced two new regressions. The first is when i915_gem_prime_import() fails for a self imported object and we do an extranous dma_buf_put in drm_gem_prime_fd_to_handle(). The second is not taking any reference on dma_buf on the import path for self imported objects that leads to the 'prime_self_import: prime_self_import.c:61: check_bo: Assertion `ptr1' failed.' error.

Dave Airlie is working on a final fix for the second regression. Until that's ready could people try the following two patches? They should fix both of the above issues:

https://patchwork.kernel.org/patch/2414801/
Comment 15 shui yangwei 2013-04-18 02:35:36 UTC
> (In reply to comment #13)
> > I think Imre is now banging his head against this ...
> 
> If think commit be8a42ae60 fixed the issue in the bug description. comment
> #10 seems to support this and I can't reproduce that issue with current
> drm-intel-nightly either.
> 
> Unfortunately commit be8a42ae60 also introduced two new regressions. The
> first is when i915_gem_prime_import() fails for a self imported object and
> we do an extranous dma_buf_put in drm_gem_prime_fd_to_handle(). The second
> is not taking any reference on dma_buf on the import path for self imported
> objects that leads to the 'prime_self_import: prime_self_import.c:61:
> check_bo: Assertion `ptr1' failed.' error.
> 
> Dave Airlie is working on a final fix for the second regression. Until
> that's ready could people try the following two patches? They should fix
> both of the above issues:
> 
> https://patchwork.kernel.org/patch/2414801/
(In reply to comment #14)

There's a bug blocked this bug, I have tried this patch, but prime_self_import failed. After the bug below fixed in nightly branch, I will retest it.
---------------------
Bug 59229 - [Bisected]I-G-T/ prime_self_import fail
Comment 16 Imre Deak 2013-04-18 04:20:55 UTC
(In reply to comment #15)
> > (In reply to comment #13)
> > > I think Imre is now banging his head against this ...
> > 
> > If think commit be8a42ae60 fixed the issue in the bug description. comment
> > #10 seems to support this and I can't reproduce that issue with current
> > drm-intel-nightly either.
> > 
> > Unfortunately commit be8a42ae60 also introduced two new regressions. The
> > first is when i915_gem_prime_import() fails for a self imported object and
> > we do an extranous dma_buf_put in drm_gem_prime_fd_to_handle(). The second
> > is not taking any reference on dma_buf on the import path for self imported
> > objects that leads to the 'prime_self_import: prime_self_import.c:61:
> > check_bo: Assertion `ptr1' failed.' error.
> > 
> > Dave Airlie is working on a final fix for the second regression. Until
> > that's ready could people try the following two patches? They should fix
> > both of the above issues:
> > 
> > https://patchwork.kernel.org/patch/2414801/
> (In reply to comment #14)
> 
> There's a bug blocked this bug, I have tried this patch, but
> prime_self_import failed. After the bug below fixed in nightly branch, I
> will retest it.

Did you have both patches applied, that is also the following?:

https://patchwork.kernel.org/patch/2414771/

The two patches should apply on nightly. It would be still useful to know if prime_self_import still fails. Note that the test was updated in igt yesterday.
Comment 17 shui yangwei 2013-04-18 05:26:47 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > > Dave Airlie is working on a final fix for the second regression. Until
> > > that's ready could people try the following two patches? They should fix
> > > both of the above issues:
> > > 
> > > https://patchwork.kernel.org/patch/2414801/
> > (In reply to comment #14)
> > 
> > There's a bug blocked this bug, I have tried this patch, but
> > prime_self_import failed. After the bug below fixed in nightly branch, I
> > will retest it.
> 
> Did you have both patches applied, that is also the following?:
> 
> https://patchwork.kernel.org/patch/2414771/
> 
> The two patches should apply on nightly. It would be still useful to know if
> prime_self_import still fails. Note that the test was updated in igt
> yesterday.

Apply these two patches on latest nightly top, both of the cases work well now,
so I think if patches updated to daniel's tree, this bug can be closed.
Comment 18 Imre Deak 2013-04-18 07:57:00 UTC
(In reply to comment #17)
> (In reply to comment #16)
> > (In reply to comment #15)
> > > > Dave Airlie is working on a final fix for the second regression. Until
> > > > that's ready could people try the following two patches? They should fix
> > > > both of the above issues:
> > > > 
> > > > https://patchwork.kernel.org/patch/2414801/
> > > (In reply to comment #14)
> > > 
> > > There's a bug blocked this bug, I have tried this patch, but
> > > prime_self_import failed. After the bug below fixed in nightly branch, I
> > > will retest it.
> > 
> > Did you have both patches applied, that is also the following?:
> > 
> > https://patchwork.kernel.org/patch/2414771/
> > 
> > The two patches should apply on nightly. It would be still useful to know if
> > prime_self_import still fails. Note that the test was updated in igt
> > yesterday.
> 
> Apply these two patches on latest nightly top, both of the cases work well
> now,
> so I think if patches updated to daniel's tree, this bug can be closed.

Ok, thanks. Setting bug #59229 as a dependency.
Comment 19 Daniel Vetter 2013-05-01 09:26:07 UTC
Dave Airlie merged the prime refcount fixes into drm-next, which is now included in drm-intel-nightly. Note that dinq/drm-intel-fixes does not yet have the patches, since it's a drm upstream issue.
Comment 20 shui yangwei 2013-05-02 01:23:31 UTC
(In reply to comment #19)
> Dave Airlie merged the prime refcount fixes into drm-next, which is now
> included in drm-intel-nightly. Note that dinq/drm-intel-fixes does not yet
> have the patches, since it's a drm upstream issue.

Thanks for your reminding, I verified it here.
Comment 21 Elizabeth 2017-10-06 14:48:34 UTC
Closing old verified.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.