diff options
author | Alex Waterman <alexw@nvidia.com> | 2016-11-08 14:28:35 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-01-04 18:53:55 -0500 |
commit | 9e2f7d98d4cf2845d3dfea1653f3d6bedd4fb1e6 (patch) | |
tree | 5849b8c4f3f120337d945770fc8a73e61873e22a /drivers/gpu | |
parent | 91d977ced46f5db02da077df8703e958c5e2af4e (diff) |
gpu: nvgpu: Move deferred interrupt wait code
Move the code that waits for deferred interrupts to nvgpu_common.c and
make it global. Also rename that function to use nvgpu_ as the function
prefix.
Bug 1816516
Bug 1807277
Change-Id: I42c4982ea853af5489051534219bfe8b253c2784
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1250027
(cherry picked from commit cb6fb03e20b08e5c3606ae8a5a9c237bfdf9e7da)
Reviewed-on: http://git-master/r/1274475
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 29 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.h | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/nvgpu_common.c | 39 |
3 files changed, 43 insertions, 27 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 7b5013ea..136c28d0 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c | |||
@@ -871,31 +871,6 @@ static void gk20a_free_error_notifiers(struct channel_gk20a *ch) | |||
871 | mutex_unlock(&ch->error_notifier_mutex); | 871 | mutex_unlock(&ch->error_notifier_mutex); |
872 | } | 872 | } |
873 | 873 | ||
874 | /* Returns delta of cyclic integers a and b. If a is ahead of b, delta | ||
875 | * is positive */ | ||
876 | static int cyclic_delta(int a, int b) | ||
877 | { | ||
878 | return a - b; | ||
879 | } | ||
880 | |||
881 | static void gk20a_wait_for_deferred_interrupts(struct gk20a *g) | ||
882 | { | ||
883 | int stall_irq_threshold = atomic_read(&g->hw_irq_stall_count); | ||
884 | int nonstall_irq_threshold = atomic_read(&g->hw_irq_nonstall_count); | ||
885 | |||
886 | /* wait until all stalling irqs are handled */ | ||
887 | wait_event(g->sw_irq_stall_last_handled_wq, | ||
888 | cyclic_delta(stall_irq_threshold, | ||
889 | atomic_read(&g->sw_irq_stall_last_handled)) | ||
890 | <= 0); | ||
891 | |||
892 | /* wait until all non-stalling irqs are handled */ | ||
893 | wait_event(g->sw_irq_nonstall_last_handled_wq, | ||
894 | cyclic_delta(nonstall_irq_threshold, | ||
895 | atomic_read(&g->sw_irq_nonstall_last_handled)) | ||
896 | <= 0); | ||
897 | } | ||
898 | |||
899 | static void gk20a_wait_until_counter_is_N( | 874 | static void gk20a_wait_until_counter_is_N( |
900 | struct channel_gk20a *ch, atomic_t *counter, int wait_value, | 875 | struct channel_gk20a *ch, atomic_t *counter, int wait_value, |
901 | wait_queue_head_t *wq, const char *caller, const char *counter_name) | 876 | wait_queue_head_t *wq, const char *caller, const char *counter_name) |
@@ -944,7 +919,7 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) | |||
944 | 919 | ||
945 | /* wait until all pending interrupts for recently completed | 920 | /* wait until all pending interrupts for recently completed |
946 | * jobs are handled */ | 921 | * jobs are handled */ |
947 | gk20a_wait_for_deferred_interrupts(g); | 922 | nvgpu_wait_for_deferred_interrupts(g); |
948 | 923 | ||
949 | /* prevent new refs */ | 924 | /* prevent new refs */ |
950 | spin_lock(&ch->ref_obtain_lock); | 925 | spin_lock(&ch->ref_obtain_lock); |
@@ -1043,7 +1018,7 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) | |||
1043 | 1018 | ||
1044 | /* make sure we don't have deferred interrupts pending that | 1019 | /* make sure we don't have deferred interrupts pending that |
1045 | * could still touch the channel */ | 1020 | * could still touch the channel */ |
1046 | gk20a_wait_for_deferred_interrupts(g); | 1021 | nvgpu_wait_for_deferred_interrupts(g); |
1047 | 1022 | ||
1048 | unbind: | 1023 | unbind: |
1049 | if (gk20a_is_channel_marked_as_tsg(ch)) | 1024 | if (gk20a_is_channel_marked_as_tsg(ch)) |
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index eab9843a..e8c1b30f 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h | |||
@@ -1384,6 +1384,8 @@ static inline void gk20a_channel_trace_sched_param( | |||
1384 | ch->ch_ctx.gr_ctx->compute_preempt_mode : 0)); | 1384 | ch->ch_ctx.gr_ctx->compute_preempt_mode : 0)); |
1385 | } | 1385 | } |
1386 | 1386 | ||
1387 | void nvgpu_wait_for_deferred_interrupts(struct gk20a *g); | ||
1388 | |||
1387 | #ifdef CONFIG_DEBUG_FS | 1389 | #ifdef CONFIG_DEBUG_FS |
1388 | int gk20a_railgating_debugfs_init(struct device *dev); | 1390 | int gk20a_railgating_debugfs_init(struct device *dev); |
1389 | #endif | 1391 | #endif |
diff --git a/drivers/gpu/nvgpu/nvgpu_common.c b/drivers/gpu/nvgpu/nvgpu_common.c index a1f4832b..a2673b26 100644 --- a/drivers/gpu/nvgpu/nvgpu_common.c +++ b/drivers/gpu/nvgpu/nvgpu_common.c | |||
@@ -231,3 +231,42 @@ const struct firmware *nvgpu_request_firmware(struct gk20a *g, | |||
231 | 231 | ||
232 | return fw; | 232 | return fw; |
233 | } | 233 | } |
234 | |||
235 | /** | ||
236 | * cyclic_delta - Returns delta of cyclic integers a and b. | ||
237 | * | ||
238 | * @a - First integer | ||
239 | * @b - Second integer | ||
240 | * | ||
241 | * Note: if a is ahead of b, delta is positive. | ||
242 | */ | ||
243 | static int cyclic_delta(int a, int b) | ||
244 | { | ||
245 | return a - b; | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * nvgpu_wait_for_deferred_interrupts - Wait for interrupts to complete | ||
250 | * | ||
251 | * @g - The GPU to wait on. | ||
252 | * | ||
253 | * Waits until all interrupt handlers that have been scheduled to run have | ||
254 | * completed. | ||
255 | */ | ||
256 | void nvgpu_wait_for_deferred_interrupts(struct gk20a *g) | ||
257 | { | ||
258 | int stall_irq_threshold = atomic_read(&g->hw_irq_stall_count); | ||
259 | int nonstall_irq_threshold = atomic_read(&g->hw_irq_nonstall_count); | ||
260 | |||
261 | /* wait until all stalling irqs are handled */ | ||
262 | wait_event(g->sw_irq_stall_last_handled_wq, | ||
263 | cyclic_delta(stall_irq_threshold, | ||
264 | atomic_read(&g->sw_irq_stall_last_handled)) | ||
265 | <= 0); | ||
266 | |||
267 | /* wait until all non-stalling irqs are handled */ | ||
268 | wait_event(g->sw_irq_nonstall_last_handled_wq, | ||
269 | cyclic_delta(nonstall_irq_threshold, | ||
270 | atomic_read(&g->sw_irq_nonstall_last_handled)) | ||
271 | <= 0); | ||
272 | } | ||