ion: fix debugfs deadlock

In the 4.9 kernel, a global srcu lock was added to debugfs file
operations. Debugfs_remove_recursive() will wait until all file
operations have completed before returning; thus guaranteeing that it is
safe to free the file's private data. Modify the ion_client_destroy()
function to take advantage of this.

This fixes a deadlock between debugfs_mutex and the debugfs srcu lock.
T1:
[40963.119756] [<ffffff8ee7087c2c>] mutex_lock+0x44/0x5c
[40963.119760] [<ffffff8ee6c19154>] ion_debug_client_show+0x58/0x164
[40963.119769] [<ffffff8ee6427a98>] seq_read+0x1bc/0x494
[40963.119774] [<ffffff8ee651f320>] full_proxy_read+0x64/0xb8
[40963.119782] [<ffffff8ee640068c>] vfs_read+0x90/0x148
[40963.119786] [<ffffff8ee6401850>] SyS_read+0x50/0xb0
[40963.119790] [<ffffff8ee62826f0>] el0_svc_naked+0x24/0x28

T2:
[40963.118397] [<ffffff8ee6320218>] __synchronize_srcu+0xe8/0x12c
[40963.118402] [<ffffff8ee63202a0>] synchronize_srcu+0x44/0x50
[40963.118406] [<ffffff8ee651da18>] debugfs_remove_recursive+0x174/0x18c
[40963.118410] [<ffffff8ee6c1a368>] ion_client_destroy+0x98/0xd0

Change-Id: I7a95fed5faf18d2d0aa93748ac37ffa1114d3b0c
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
1 file changed