diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c index 236ddaaf..25c57681 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c | |||
@@ -83,7 +83,7 @@ static int gk20a_channel_syncpt_wait_syncpt(struct gk20a_channel_sync *s, | |||
83 | } | 83 | } |
84 | 84 | ||
85 | static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd, | 85 | static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd, |
86 | struct priv_cmd_entry *wait_cmd) | 86 | struct priv_cmd_entry *wait_cmd, int max_wait_cmds) |
87 | { | 87 | { |
88 | #ifdef CONFIG_SYNC | 88 | #ifdef CONFIG_SYNC |
89 | int i; | 89 | int i; |
@@ -101,6 +101,11 @@ static int gk20a_channel_syncpt_wait_fd(struct gk20a_channel_sync *s, int fd, | |||
101 | if (!sync_fence) | 101 | if (!sync_fence) |
102 | return -EINVAL; | 102 | return -EINVAL; |
103 | 103 | ||
104 | if (max_wait_cmds && sync_fence->num_fences > max_wait_cmds) { | ||
105 | sync_fence_put(sync_fence); | ||
106 | return -EINVAL; | ||
107 | } | ||
108 | |||
104 | /* validate syncpt ids */ | 109 | /* validate syncpt ids */ |
105 | for (i = 0; i < sync_fence->num_fences; i++) { | 110 | for (i = 0; i < sync_fence->num_fences; i++) { |
106 | pt = sync_pt_from_fence(sync_fence->cbs[i].sync_pt); | 111 | pt = sync_pt_from_fence(sync_fence->cbs[i].sync_pt); |
@@ -473,7 +478,7 @@ static int gk20a_channel_semaphore_wait_syncpt( | |||
473 | 478 | ||
474 | #ifdef CONFIG_SYNC | 479 | #ifdef CONFIG_SYNC |
475 | static int semaphore_wait_fd_native(struct channel_gk20a *c, int fd, | 480 | static int semaphore_wait_fd_native(struct channel_gk20a *c, int fd, |
476 | struct priv_cmd_entry *wait_cmd) | 481 | struct priv_cmd_entry *wait_cmd, int max_wait_cmds) |
477 | { | 482 | { |
478 | struct sync_fence *sync_fence; | 483 | struct sync_fence *sync_fence; |
479 | int err; | 484 | int err; |
@@ -491,6 +496,11 @@ static int semaphore_wait_fd_native(struct channel_gk20a *c, int fd, | |||
491 | goto put_fence; | 496 | goto put_fence; |
492 | } | 497 | } |
493 | 498 | ||
499 | if (max_wait_cmds && sync_fence->num_fences > max_wait_cmds) { | ||
500 | err = -EINVAL; | ||
501 | goto put_fence; | ||
502 | } | ||
503 | |||
494 | err = gk20a_channel_alloc_priv_cmdbuf(c, | 504 | err = gk20a_channel_alloc_priv_cmdbuf(c, |
495 | wait_cmd_size * num_wait_cmds, | 505 | wait_cmd_size * num_wait_cmds, |
496 | wait_cmd); | 506 | wait_cmd); |
@@ -526,14 +536,13 @@ put_fence: | |||
526 | 536 | ||
527 | static int gk20a_channel_semaphore_wait_fd( | 537 | static int gk20a_channel_semaphore_wait_fd( |
528 | struct gk20a_channel_sync *s, int fd, | 538 | struct gk20a_channel_sync *s, int fd, |
529 | struct priv_cmd_entry *entry) | 539 | struct priv_cmd_entry *entry, int max_wait_cmds) |
530 | { | 540 | { |
531 | struct gk20a_channel_semaphore *sema = | 541 | struct gk20a_channel_semaphore *sema = |
532 | container_of(s, struct gk20a_channel_semaphore, ops); | 542 | container_of(s, struct gk20a_channel_semaphore, ops); |
533 | struct channel_gk20a *c = sema->c; | 543 | struct channel_gk20a *c = sema->c; |
534 | #ifdef CONFIG_SYNC | 544 | #ifdef CONFIG_SYNC |
535 | 545 | return semaphore_wait_fd_native(c, fd, entry, max_wait_cmds); | |
536 | return semaphore_wait_fd_native(c, fd, entry); | ||
537 | #else | 546 | #else |
538 | nvgpu_err(c->g, | 547 | nvgpu_err(c->g, |
539 | "trying to use sync fds with CONFIG_SYNC disabled"); | 548 | "trying to use sync fds with CONFIG_SYNC disabled"); |