When an MMU notifier runs in memory reclaim context, it can deadlock
trying to take locks that are already held in the thread causing the
memory reclaim. The solution is to avoid memory reclaim while holding
locks that are taken in MMU notifiers by using GFP_NOIO.

This commit fixes kmalloc while holding rmn->lock. The GFX MMU
notifier also locks reservation objects. I have no good solution for
avoiding reclaim while holding reservation objects. The HSA MMU
notifier will not lock any reservation objects.

Signed-off-by: Felix Kuehling <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
index f2ed18e..b4a5c03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
@@ -402,7 +402,7 @@ int amdgpu_mn_register(struct amdgpu_bo *bo, unsigned long 
addr)
        }
 
        if (!node) {
-               node = kmalloc(sizeof(struct amdgpu_mn_node), GFP_KERNEL);
+               node = kmalloc(sizeof(struct amdgpu_mn_node), GFP_NOIO);
                if (!node) {
                        up_write(&rmn->lock);
                        return -ENOMEM;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to