diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2017-08-31 06:01:26 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-09-11 13:34:57 -0400 |
commit | 17451138cf60f5d64eed88cc5defd44981926d9d (patch) | |
tree | ea335a05d9e038876d42bcd8a73c56e3b60af1a5 /drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h | |
parent | de0ce3e017decadd3a5049477f17ba770ddf074c (diff) |
gpu: nvgpu: hold ch ref when getting ch from fd
Fix a race condition in gk20a_get_channel_from_file() that returns a
channel pointer from an fd: take a reference to the channel before
putting the file ref back. Now the caller is responsible of releasing
the channel reference eventually.
Also document why dbg_session_channel_data has to hold a ref to the
channel file instead of just the channel: that might deadlock if the fds
were closed in "wrong" order.
Change-Id: I8e91b809f5f7b1cb0c1487bd955ad6d643727a53
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1549290
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h index 827fb42f..4d2c0f94 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.h | |||
@@ -93,7 +93,14 @@ dbg_session_data_from_dbg_s_entry(struct nvgpu_list_node *node) | |||
93 | }; | 93 | }; |
94 | 94 | ||
95 | struct dbg_session_channel_data { | 95 | struct dbg_session_channel_data { |
96 | struct file *ch_f; | 96 | /* |
97 | * We have to keep a ref to the _file_, not the channel, because | ||
98 | * close(channel_fd) is synchronous and would deadlock if we had an | ||
99 | * open debug session fd holding a channel ref at that time. Holding a | ||
100 | * ref to the file makes close(channel_fd) just drop a kernel ref to | ||
101 | * the file; the channel will close when the last file ref is dropped. | ||
102 | */ | ||
103 | struct file *ch_f; | ||
97 | int channel_fd; | 104 | int channel_fd; |
98 | int chid; | 105 | int chid; |
99 | struct nvgpu_list_node ch_entry; | 106 | struct nvgpu_list_node ch_entry; |