diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_channel.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 13355605..3a2f7b5e 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c | |||
@@ -102,17 +102,35 @@ struct channel_priv { | |||
102 | 102 | ||
103 | #if defined(CONFIG_GK20A_CYCLE_STATS) | 103 | #if defined(CONFIG_GK20A_CYCLE_STATS) |
104 | 104 | ||
105 | void gk20a_channel_free_cycle_stats_buffer(struct channel_gk20a *ch) | ||
106 | { | ||
107 | struct nvgpu_channel_linux *priv = ch->os_priv; | ||
108 | |||
109 | /* disable existing cyclestats buffer */ | ||
110 | nvgpu_mutex_acquire(&ch->cyclestate.cyclestate_buffer_mutex); | ||
111 | if (priv->cyclestate_buffer_handler) { | ||
112 | dma_buf_vunmap(priv->cyclestate_buffer_handler, | ||
113 | ch->cyclestate.cyclestate_buffer); | ||
114 | dma_buf_put(priv->cyclestate_buffer_handler); | ||
115 | priv->cyclestate_buffer_handler = NULL; | ||
116 | ch->cyclestate.cyclestate_buffer = NULL; | ||
117 | ch->cyclestate.cyclestate_buffer_size = 0; | ||
118 | } | ||
119 | nvgpu_mutex_release(&ch->cyclestate.cyclestate_buffer_mutex); | ||
120 | } | ||
121 | |||
105 | static int gk20a_channel_cycle_stats(struct channel_gk20a *ch, | 122 | static int gk20a_channel_cycle_stats(struct channel_gk20a *ch, |
106 | struct nvgpu_cycle_stats_args *args) | 123 | struct nvgpu_cycle_stats_args *args) |
107 | { | 124 | { |
108 | struct dma_buf *dmabuf; | 125 | struct dma_buf *dmabuf; |
109 | void *virtual_address; | 126 | void *virtual_address; |
127 | struct nvgpu_channel_linux *priv = ch->os_priv; | ||
110 | 128 | ||
111 | /* is it allowed to handle calls for current GPU? */ | 129 | /* is it allowed to handle calls for current GPU? */ |
112 | if (!nvgpu_is_enabled(ch->g, NVGPU_SUPPORT_CYCLE_STATS)) | 130 | if (!nvgpu_is_enabled(ch->g, NVGPU_SUPPORT_CYCLE_STATS)) |
113 | return -ENOSYS; | 131 | return -ENOSYS; |
114 | 132 | ||
115 | if (args->dmabuf_fd && !ch->cyclestate.cyclestate_buffer_handler) { | 133 | if (args->dmabuf_fd && !priv->cyclestate_buffer_handler) { |
116 | 134 | ||
117 | /* set up new cyclestats buffer */ | 135 | /* set up new cyclestats buffer */ |
118 | dmabuf = dma_buf_get(args->dmabuf_fd); | 136 | dmabuf = dma_buf_get(args->dmabuf_fd); |
@@ -122,18 +140,16 @@ static int gk20a_channel_cycle_stats(struct channel_gk20a *ch, | |||
122 | if (!virtual_address) | 140 | if (!virtual_address) |
123 | return -ENOMEM; | 141 | return -ENOMEM; |
124 | 142 | ||
125 | ch->cyclestate.cyclestate_buffer_handler = dmabuf; | 143 | priv->cyclestate_buffer_handler = dmabuf; |
126 | ch->cyclestate.cyclestate_buffer = virtual_address; | 144 | ch->cyclestate.cyclestate_buffer = virtual_address; |
127 | ch->cyclestate.cyclestate_buffer_size = dmabuf->size; | 145 | ch->cyclestate.cyclestate_buffer_size = dmabuf->size; |
128 | return 0; | 146 | return 0; |
129 | 147 | ||
130 | } else if (!args->dmabuf_fd && | 148 | } else if (!args->dmabuf_fd && priv->cyclestate_buffer_handler) { |
131 | ch->cyclestate.cyclestate_buffer_handler) { | ||
132 | gk20a_channel_free_cycle_stats_buffer(ch); | 149 | gk20a_channel_free_cycle_stats_buffer(ch); |
133 | return 0; | 150 | return 0; |
134 | 151 | ||
135 | } else if (!args->dmabuf_fd && | 152 | } else if (!args->dmabuf_fd && !priv->cyclestate_buffer_handler) { |
136 | !ch->cyclestate.cyclestate_buffer_handler) { | ||
137 | /* no requst from GL */ | 153 | /* no requst from GL */ |
138 | return 0; | 154 | return 0; |
139 | 155 | ||