diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/channel.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/channel.c | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/channel.c b/drivers/gpu/nvgpu/common/linux/channel.c index db85f66a..70baeb2d 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.c +++ b/drivers/gpu/nvgpu/common/linux/channel.c | |||
@@ -39,6 +39,34 @@ | |||
39 | #include <trace/events/gk20a.h> | 39 | #include <trace/events/gk20a.h> |
40 | #include <uapi/linux/nvgpu.h> | 40 | #include <uapi/linux/nvgpu.h> |
41 | 41 | ||
42 | u32 nvgpu_submit_gpfifo_user_flags_to_common_flags(u32 user_flags) | ||
43 | { | ||
44 | u32 flags = 0; | ||
45 | |||
46 | if (user_flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_WAIT) | ||
47 | flags |= NVGPU_SUBMIT_FLAGS_FENCE_WAIT; | ||
48 | |||
49 | if (user_flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) | ||
50 | flags |= NVGPU_SUBMIT_FLAGS_FENCE_GET; | ||
51 | |||
52 | if (user_flags & NVGPU_SUBMIT_GPFIFO_FLAGS_HW_FORMAT) | ||
53 | flags |= NVGPU_SUBMIT_FLAGS_HW_FORMAT; | ||
54 | |||
55 | if (user_flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SYNC_FENCE) | ||
56 | flags |= NVGPU_SUBMIT_FLAGS_SYNC_FENCE; | ||
57 | |||
58 | if (user_flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SUPPRESS_WFI) | ||
59 | flags |= NVGPU_SUBMIT_FLAGS_SUPPRESS_WFI; | ||
60 | |||
61 | if (user_flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SKIP_BUFFER_REFCOUNTING) | ||
62 | flags |= NVGPU_SUBMIT_FLAGS_SKIP_BUFFER_REFCOUNTING; | ||
63 | |||
64 | if (user_flags & NVGPU_SUBMIT_GPFIFO_FLAGS_RESCHEDULE_RUNLIST) | ||
65 | flags |= NVGPU_SUBMIT_FLAGS_RESCHEDULE_RUNLIST; | ||
66 | |||
67 | return flags; | ||
68 | } | ||
69 | |||
42 | /* | 70 | /* |
43 | * API to convert error_notifiers in common code and of the form | 71 | * API to convert error_notifiers in common code and of the form |
44 | * NVGPU_ERR_NOTIFIER_* into Linux specific error_notifiers exposed to user | 72 | * NVGPU_ERR_NOTIFIER_* into Linux specific error_notifiers exposed to user |
@@ -430,7 +458,7 @@ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, | |||
430 | bool new_sync_created = false; | 458 | bool new_sync_created = false; |
431 | int wait_fence_fd = -1; | 459 | int wait_fence_fd = -1; |
432 | int err = 0; | 460 | int err = 0; |
433 | bool need_wfi = !(flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SUPPRESS_WFI); | 461 | bool need_wfi = !(flags & NVGPU_SUBMIT_FLAGS_SUPPRESS_WFI); |
434 | bool pre_alloc_enabled = channel_gk20a_is_prealloc_enabled(c); | 462 | bool pre_alloc_enabled = channel_gk20a_is_prealloc_enabled(c); |
435 | 463 | ||
436 | /* | 464 | /* |
@@ -465,7 +493,7 @@ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, | |||
465 | * Optionally insert syncpt/semaphore wait in the beginning of gpfifo | 493 | * Optionally insert syncpt/semaphore wait in the beginning of gpfifo |
466 | * submission when user requested and the wait hasn't expired. | 494 | * submission when user requested and the wait hasn't expired. |
467 | */ | 495 | */ |
468 | if (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_WAIT) { | 496 | if (flags & NVGPU_SUBMIT_FLAGS_FENCE_WAIT) { |
469 | int max_wait_cmds = c->deterministic ? 1 : 0; | 497 | int max_wait_cmds = c->deterministic ? 1 : 0; |
470 | 498 | ||
471 | if (!pre_alloc_enabled) | 499 | if (!pre_alloc_enabled) |
@@ -477,7 +505,7 @@ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, | |||
477 | goto fail; | 505 | goto fail; |
478 | } | 506 | } |
479 | 507 | ||
480 | if (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SYNC_FENCE) { | 508 | if (flags & NVGPU_SUBMIT_FLAGS_SYNC_FENCE) { |
481 | wait_fence_fd = fence->id; | 509 | wait_fence_fd = fence->id; |
482 | err = c->sync->wait_fd(c->sync, wait_fence_fd, | 510 | err = c->sync->wait_fd(c->sync, wait_fence_fd, |
483 | job->wait_cmd, max_wait_cmds); | 511 | job->wait_cmd, max_wait_cmds); |
@@ -494,8 +522,8 @@ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, | |||
494 | *wait_cmd = job->wait_cmd; | 522 | *wait_cmd = job->wait_cmd; |
495 | } | 523 | } |
496 | 524 | ||
497 | if ((flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) && | 525 | if ((flags & NVGPU_SUBMIT_FLAGS_FENCE_GET) && |
498 | (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SYNC_FENCE)) | 526 | (flags & NVGPU_SUBMIT_FLAGS_SYNC_FENCE)) |
499 | need_sync_fence = true; | 527 | need_sync_fence = true; |
500 | 528 | ||
501 | /* | 529 | /* |
@@ -516,7 +544,7 @@ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, | |||
516 | goto clean_up_post_fence; | 544 | goto clean_up_post_fence; |
517 | } | 545 | } |
518 | 546 | ||
519 | if (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) | 547 | if (flags & NVGPU_SUBMIT_FLAGS_FENCE_GET) |
520 | err = c->sync->incr_user(c->sync, wait_fence_fd, job->incr_cmd, | 548 | err = c->sync->incr_user(c->sync, wait_fence_fd, job->incr_cmd, |
521 | job->post_fence, need_wfi, need_sync_fence, | 549 | job->post_fence, need_wfi, need_sync_fence, |
522 | register_irq); | 550 | register_irq); |
@@ -678,7 +706,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, | |||
678 | * and one for post fence. */ | 706 | * and one for post fence. */ |
679 | const int extra_entries = 2; | 707 | const int extra_entries = 2; |
680 | bool skip_buffer_refcounting = (flags & | 708 | bool skip_buffer_refcounting = (flags & |
681 | NVGPU_SUBMIT_GPFIFO_FLAGS_SKIP_BUFFER_REFCOUNTING); | 709 | NVGPU_SUBMIT_FLAGS_SKIP_BUFFER_REFCOUNTING); |
682 | int err = 0; | 710 | int err = 0; |
683 | bool need_job_tracking; | 711 | bool need_job_tracking; |
684 | bool need_deferred_cleanup = false; | 712 | bool need_deferred_cleanup = false; |
@@ -706,8 +734,8 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, | |||
706 | if (!gpfifo && !args) | 734 | if (!gpfifo && !args) |
707 | return -EINVAL; | 735 | return -EINVAL; |
708 | 736 | ||
709 | if ((flags & (NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_WAIT | | 737 | if ((flags & (NVGPU_SUBMIT_FLAGS_FENCE_WAIT | |
710 | NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET)) && | 738 | NVGPU_SUBMIT_FLAGS_FENCE_GET)) && |
711 | !fence) | 739 | !fence) |
712 | return -EINVAL; | 740 | return -EINVAL; |
713 | 741 | ||
@@ -738,8 +766,8 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, | |||
738 | * required and a fast submit can be done (ie. only need to write | 766 | * required and a fast submit can be done (ie. only need to write |
739 | * out userspace GPFIFO entries and update GP_PUT). | 767 | * out userspace GPFIFO entries and update GP_PUT). |
740 | */ | 768 | */ |
741 | need_job_tracking = (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_WAIT) || | 769 | need_job_tracking = (flags & NVGPU_SUBMIT_FLAGS_FENCE_WAIT) || |
742 | (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) || | 770 | (flags & NVGPU_SUBMIT_FLAGS_FENCE_GET) || |
743 | c->timeout.enabled || | 771 | c->timeout.enabled || |
744 | (g->can_railgate && !c->deterministic) || | 772 | (g->can_railgate && !c->deterministic) || |
745 | !skip_buffer_refcounting; | 773 | !skip_buffer_refcounting; |
@@ -757,8 +785,8 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, | |||
757 | 785 | ||
758 | need_sync_framework = force_need_sync_fence || | 786 | need_sync_framework = force_need_sync_fence || |
759 | gk20a_channel_sync_needs_sync_framework(g) || | 787 | gk20a_channel_sync_needs_sync_framework(g) || |
760 | (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SYNC_FENCE && | 788 | (flags & NVGPU_SUBMIT_FLAGS_SYNC_FENCE && |
761 | flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET); | 789 | flags & NVGPU_SUBMIT_FLAGS_FENCE_GET); |
762 | 790 | ||
763 | /* | 791 | /* |
764 | * Deferred clean-up is necessary for any of the following | 792 | * Deferred clean-up is necessary for any of the following |
@@ -899,7 +927,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, | |||
899 | 927 | ||
900 | g->ops.fifo.userd_gp_put(g, c); | 928 | g->ops.fifo.userd_gp_put(g, c); |
901 | 929 | ||
902 | if ((NVGPU_SUBMIT_GPFIFO_FLAGS_RESCHEDULE_RUNLIST & flags) && | 930 | if ((NVGPU_SUBMIT_FLAGS_RESCHEDULE_RUNLIST & flags) && |
903 | g->ops.fifo.reschedule_runlist) | 931 | g->ops.fifo.reschedule_runlist) |
904 | g->ops.fifo.reschedule_runlist(g, c->runlist_id); | 932 | g->ops.fifo.reschedule_runlist(g, c->runlist_id); |
905 | 933 | ||