diff options
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/channel.c | 1 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/channel.h | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 28 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.h | 1 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 22 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 8 |
6 files changed, 30 insertions, 33 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/channel.c b/drivers/gpu/nvgpu/common/linux/channel.c index 0ed596ac..a725cd6b 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.c +++ b/drivers/gpu/nvgpu/common/linux/channel.c | |||
@@ -245,6 +245,7 @@ static void nvgpu_channel_close_linux(struct channel_gk20a *ch) | |||
245 | nvgpu_channel_work_completion_clear(ch); | 245 | nvgpu_channel_work_completion_clear(ch); |
246 | 246 | ||
247 | #if defined(CONFIG_GK20A_CYCLE_STATS) | 247 | #if defined(CONFIG_GK20A_CYCLE_STATS) |
248 | gk20a_channel_free_cycle_stats_buffer(ch); | ||
248 | gk20a_channel_free_cycle_stats_snapshot(ch); | 249 | gk20a_channel_free_cycle_stats_snapshot(ch); |
249 | #endif | 250 | #endif |
250 | } | 251 | } |
diff --git a/drivers/gpu/nvgpu/common/linux/channel.h b/drivers/gpu/nvgpu/common/linux/channel.h index a4df75d6..35be425a 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.h +++ b/drivers/gpu/nvgpu/common/linux/channel.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #define __NVGPU_CHANNEL_H__ | 17 | #define __NVGPU_CHANNEL_H__ |
18 | 18 | ||
19 | #include <linux/workqueue.h> | 19 | #include <linux/workqueue.h> |
20 | #include <linux/dma-buf.h> | ||
20 | 21 | ||
21 | #include <nvgpu/types.h> | 22 | #include <nvgpu/types.h> |
22 | 23 | ||
@@ -56,6 +57,8 @@ struct nvgpu_channel_linux { | |||
56 | 57 | ||
57 | struct nvgpu_channel_completion_cb completion_cb; | 58 | struct nvgpu_channel_completion_cb completion_cb; |
58 | struct nvgpu_error_notifier error_notifier; | 59 | struct nvgpu_error_notifier error_notifier; |
60 | |||
61 | struct dma_buf *cyclestate_buffer_handler; | ||
59 | }; | 62 | }; |
60 | 63 | ||
61 | int nvgpu_init_channel_support_linux(struct nvgpu_os_linux *l); | 64 | int nvgpu_init_channel_support_linux(struct nvgpu_os_linux *l); |
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 | ||
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.h b/drivers/gpu/nvgpu/common/linux/ioctl_channel.h index 3ea8d765..c37108c4 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.h +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.h | |||
@@ -37,6 +37,7 @@ int gk20a_channel_open_ioctl(struct gk20a *g, | |||
37 | struct nvgpu_channel_open_args *args); | 37 | struct nvgpu_channel_open_args *args); |
38 | 38 | ||
39 | int gk20a_channel_free_cycle_stats_snapshot(struct channel_gk20a *ch); | 39 | int gk20a_channel_free_cycle_stats_snapshot(struct channel_gk20a *ch); |
40 | void gk20a_channel_free_cycle_stats_buffer(struct channel_gk20a *ch); | ||
40 | 41 | ||
41 | extern const struct file_operations gk20a_event_id_ops; | 42 | extern const struct file_operations gk20a_event_id_ops; |
42 | extern const struct file_operations gk20a_channel_ops; | 43 | extern const struct file_operations gk20a_channel_ops; |
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index dac38739..6d62d888 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c | |||
@@ -360,24 +360,6 @@ static void gk20a_wait_until_counter_is_N( | |||
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | #if defined(CONFIG_GK20A_CYCLE_STATS) | ||
364 | void gk20a_channel_free_cycle_stats_buffer(struct channel_gk20a *ch) | ||
365 | { | ||
366 | /* disable existing cyclestats buffer */ | ||
367 | nvgpu_mutex_acquire(&ch->cyclestate.cyclestate_buffer_mutex); | ||
368 | if (ch->cyclestate.cyclestate_buffer_handler) { | ||
369 | dma_buf_vunmap(ch->cyclestate.cyclestate_buffer_handler, | ||
370 | ch->cyclestate.cyclestate_buffer); | ||
371 | dma_buf_put(ch->cyclestate.cyclestate_buffer_handler); | ||
372 | ch->cyclestate.cyclestate_buffer_handler = NULL; | ||
373 | ch->cyclestate.cyclestate_buffer = NULL; | ||
374 | ch->cyclestate.cyclestate_buffer_size = 0; | ||
375 | } | ||
376 | nvgpu_mutex_release(&ch->cyclestate.cyclestate_buffer_mutex); | ||
377 | } | ||
378 | |||
379 | #endif | ||
380 | |||
381 | /* call ONLY when no references to the channel exist: after the last put */ | 363 | /* call ONLY when no references to the channel exist: after the last put */ |
382 | static void gk20a_free_channel(struct channel_gk20a *ch, bool force) | 364 | static void gk20a_free_channel(struct channel_gk20a *ch, bool force) |
383 | { | 365 | { |
@@ -490,10 +472,6 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) | |||
490 | nvgpu_big_free(g, ch->gpfifo.pipe); | 472 | nvgpu_big_free(g, ch->gpfifo.pipe); |
491 | memset(&ch->gpfifo, 0, sizeof(struct gpfifo_desc)); | 473 | memset(&ch->gpfifo, 0, sizeof(struct gpfifo_desc)); |
492 | 474 | ||
493 | #if defined(CONFIG_GK20A_CYCLE_STATS) | ||
494 | gk20a_channel_free_cycle_stats_buffer(ch); | ||
495 | #endif | ||
496 | |||
497 | channel_gk20a_free_priv_cmdbuf(ch); | 475 | channel_gk20a_free_priv_cmdbuf(ch); |
498 | 476 | ||
499 | /* sync must be destroyed before releasing channel vm */ | 477 | /* sync must be destroyed before releasing channel vm */ |
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index 87ab6202..9d294399 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h | |||
@@ -253,10 +253,9 @@ struct channel_gk20a { | |||
253 | 253 | ||
254 | #if defined(CONFIG_GK20A_CYCLE_STATS) | 254 | #if defined(CONFIG_GK20A_CYCLE_STATS) |
255 | struct { | 255 | struct { |
256 | void *cyclestate_buffer; | 256 | void *cyclestate_buffer; |
257 | u32 cyclestate_buffer_size; | 257 | u32 cyclestate_buffer_size; |
258 | struct dma_buf *cyclestate_buffer_handler; | 258 | struct nvgpu_mutex cyclestate_buffer_mutex; |
259 | struct nvgpu_mutex cyclestate_buffer_mutex; | ||
260 | } cyclestate; | 259 | } cyclestate; |
261 | 260 | ||
262 | struct nvgpu_mutex cs_client_mutex; | 261 | struct nvgpu_mutex cs_client_mutex; |
@@ -370,7 +369,6 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c, | |||
370 | unsigned int num_entries, | 369 | unsigned int num_entries, |
371 | unsigned int num_inflight_jobs, | 370 | unsigned int num_inflight_jobs, |
372 | u32 flags); | 371 | u32 flags); |
373 | void gk20a_channel_free_cycle_stats_buffer(struct channel_gk20a *ch); | ||
374 | 372 | ||
375 | void gk20a_channel_timeout_restart_all_channels(struct gk20a *g); | 373 | void gk20a_channel_timeout_restart_all_channels(struct gk20a *g); |
376 | 374 | ||