Re: [drm:dm_plane_helper_prepare_fb [amdgpu]] *ERROR* Failed to pin framebuffer with error -12

From: Christian König
Date: Mon Jan 11 2021 - 04:04:50 EST


Hi Mikhail

Am 10.01.21 um 23:26 schrieb Mikhail Gavrilov:
Hi folks,
today I joined to testing Kernel 5.11 and saw that the kernel log was
flooded with BUG messages:
BUG: sleeping function called from invalid context at mm/vmalloc.c:1756
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 266, name: kswapd0
INFO: lockdep is turned off.
CPU: 15 PID: 266 Comm: kswapd0 Tainted: G W ---------
--- 5.11.0-0.rc2.20210108gitf5e6c330254a.119.fc34.x86_64 #1
Hardware name: System manufacturer System Product Name/ROG STRIX
X570-I GAMING, BIOS 2802 10/21/2020
Call Trace:
dump_stack+0x8b/0xb0
___might_sleep.cold+0xb6/0xc6
vm_unmap_aliases+0x21/0x40
change_page_attr_set_clr+0x9e/0x190
set_memory_wb+0x2f/0x80
ttm_pool_free_page+0x28/0x90 [ttm]
ttm_pool_shrink+0x45/0xb0 [ttm]
ttm_pool_shrinker_scan+0xa/0x20 [ttm]
do_shrink_slab+0x177/0x3a0
shrink_slab+0x9c/0x290
shrink_node+0x2e6/0x700
balance_pgdat+0x2f5/0x650
kswapd+0x21d/0x4d0
? do_wait_intr_irq+0xd0/0xd0
? balance_pgdat+0x650/0x650
kthread+0x13a/0x150
? __kthread_bind_mask+0x60/0x60
ret_from_fork+0x22/0x30

I'm probably responsible for this. Need to double check why we try to allocate memory while freeing some.

But the most unpleasant thing is that after a while the monitor turns
off and does not go on again until the restart.
This is accompanied by an entry in the kernel log:

amdgpu 0000:0b:00.0: amdgpu: 00000000ff7d8b94 pin failed
[drm:dm_plane_helper_prepare_fb [amdgpu]] *ERROR* Failed to pin
framebuffer with error -12

-12 is just -ENOMEM. Looks like a memory leak to me, maybe caused by the problem above, maybe something completely unrelated.

I will take a look.

Thanks,
Christian.


$ grep "Failed to pin framebuffer with error" -Rn .
./drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:5816:
DRM_ERROR("Failed to pin framebuffer with error %d\n", r);

$ git blame -L 5811,5821 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
Blaming lines: 0% (11/9167), done.
5d43be0ccbc2f (Christian König 2017-10-26 18:06:23 +0200 5811)
domain = AMDGPU_GEM_DOMAIN_VRAM;
e7b07ceef2a65 (Harry Wentland 2017-08-10 13:29:07 -0400 5812)
7b7c6c81b3a37 (Junwei Zhang 2018-06-25 12:51:14 +0800 5813) r =
amdgpu_bo_pin(rbo, domain);
e7b07ceef2a65 (Harry Wentland 2017-08-10 13:29:07 -0400 5814) if
(unlikely(r != 0)) {
30b7c6147d18d (Harry Wentland 2017-10-26 15:35:14 -0400 5815)
if (r != -ERESTARTSYS)
30b7c6147d18d (Harry Wentland 2017-10-26 15:35:14 -0400 5816)
DRM_ERROR("Failed to pin framebuffer with error %d\n", r);
0f257b09531b4 (Chunming Zhou 2019-05-07 19:45:31 +0800 5817)
ttm_eu_backoff_reservation(&ticket, &list);
e7b07ceef2a65 (Harry Wentland 2017-08-10 13:29:07 -0400 5818)
return r;
e7b07ceef2a65 (Harry Wentland 2017-08-10 13:29:07 -0400 5819) }
e7b07ceef2a65 (Harry Wentland 2017-08-10 13:29:07 -0400 5820)
bb812f1ea87dd (Junwei Zhang 2018-06-25 13:32:24 +0800 5821) r =
amdgpu_ttm_alloc_gart(&rbo->tbo);

Who knows how to fix it?

Full kernel logs is here:
[1] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpastebin.com%2FfLasjDHX&data=04%7C01%7Cchristian.koenig%40amd.com%7C15ef83e462e049429be208d8b5b6c6bb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637459143942981908%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Uj9Ob3lUCAsH8NrxC715zSfl5Yqc44ySVo%2FZkdyTpCM%3D&reserved=0
[2] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpastebin.com%2Fg3wR2r9e&data=04%7C01%7Cchristian.koenig%40amd.com%7C15ef83e462e049429be208d8b5b6c6bb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637459143942981908%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=u8irMU3i8c37W5SkyiaAi%2FtwMoPorezm3NI1EYI3csE%3D&reserved=0

--
Best Regards,
Mike Gavrilov.