summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/nvgpu/common/linux/cde.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/ce2.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/channel.c56
-rw-r--r--drivers/gpu/nvgpu/common/linux/channel.h1
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_channel.c5
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c10
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.h9
7 files changed, 64 insertions, 21 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/cde.c b/drivers/gpu/nvgpu/common/linux/cde.c
index dcccafb4..4911afa1 100644
--- a/drivers/gpu/nvgpu/common/linux/cde.c
+++ b/drivers/gpu/nvgpu/common/linux/cde.c
@@ -1171,7 +1171,7 @@ __releases(&l->cde_app->mutex)
1171 1171
1172 /* take always the postfence as it is needed for protecting the 1172 /* take always the postfence as it is needed for protecting the
1173 * cde context */ 1173 * cde context */
1174 flags = __flags | NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET; 1174 flags = __flags | NVGPU_SUBMIT_FLAGS_FENCE_GET;
1175 1175
1176 /* gk20a_cde_execute_buffer() will grab a power reference of it's own */ 1176 /* gk20a_cde_execute_buffer() will grab a power reference of it's own */
1177 gk20a_idle(g); 1177 gk20a_idle(g);
diff --git a/drivers/gpu/nvgpu/common/linux/ce2.c b/drivers/gpu/nvgpu/common/linux/ce2.c
index 6ffc0532..5339f130 100644
--- a/drivers/gpu/nvgpu/common/linux/ce2.c
+++ b/drivers/gpu/nvgpu/common/linux/ce2.c
@@ -128,7 +128,7 @@ int gk20a_ce_execute_ops(struct gk20a *g,
128 pbdma_gp_entry1_length_f(methodSize)); 128 pbdma_gp_entry1_length_f(methodSize));
129 129
130 /* take always the postfence as it is needed for protecting the ce context */ 130 /* take always the postfence as it is needed for protecting the ce context */
131 submit_flags |= NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET; 131 submit_flags |= NVGPU_SUBMIT_FLAGS_FENCE_GET;
132 132
133 nvgpu_smp_wmb(); 133 nvgpu_smp_wmb();
134 134
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
42u32 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
diff --git a/drivers/gpu/nvgpu/common/linux/channel.h b/drivers/gpu/nvgpu/common/linux/channel.h
index 6026e259..d4cb6d55 100644
--- a/drivers/gpu/nvgpu/common/linux/channel.h
+++ b/drivers/gpu/nvgpu/common/linux/channel.h
@@ -61,6 +61,7 @@ struct nvgpu_channel_linux {
61 struct dma_buf *cyclestate_buffer_handler; 61 struct dma_buf *cyclestate_buffer_handler;
62}; 62};
63 63
64u32 nvgpu_submit_gpfifo_user_flags_to_common_flags(u32 user_flags);
64int nvgpu_init_channel_support_linux(struct nvgpu_os_linux *l); 65int nvgpu_init_channel_support_linux(struct nvgpu_os_linux *l);
65void nvgpu_remove_channel_support_linux(struct nvgpu_os_linux *l); 66void nvgpu_remove_channel_support_linux(struct nvgpu_os_linux *l);
66 67
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
index c75c9244..5b4dda6c 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
@@ -771,6 +771,7 @@ static int gk20a_ioctl_channel_submit_gpfifo(
771 struct nvgpu_channel_fence fence; 771 struct nvgpu_channel_fence fence;
772 struct gk20a_fence *fence_out; 772 struct gk20a_fence *fence_out;
773 struct fifo_profile_gk20a *profile = NULL; 773 struct fifo_profile_gk20a *profile = NULL;
774 u32 submit_flags = 0;
774 775
775 int ret = 0; 776 int ret = 0;
776 gk20a_dbg_fn(""); 777 gk20a_dbg_fn("");
@@ -789,8 +790,10 @@ static int gk20a_ioctl_channel_submit_gpfifo(
789 return -EPERM; 790 return -EPERM;
790 791
791 nvgpu_get_fence_args(&args->fence, &fence); 792 nvgpu_get_fence_args(&args->fence, &fence);
793 submit_flags =
794 nvgpu_submit_gpfifo_user_flags_to_common_flags(args->flags);
792 ret = gk20a_submit_channel_gpfifo(ch, NULL, args, args->num_entries, 795 ret = gk20a_submit_channel_gpfifo(ch, NULL, args, args->num_entries,
793 args->flags, &fence, 796 submit_flags, &fence,
794 &fence_out, false, profile); 797 &fence_out, false, profile);
795 798
796 if (ret) 799 if (ret)
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
index 3392b6fa..e4b66460 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
@@ -43,6 +43,7 @@
43#include "platform_gk20a.h" 43#include "platform_gk20a.h"
44#include "os_linux.h" 44#include "os_linux.h"
45#include "dmabuf.h" 45#include "dmabuf.h"
46#include "channel.h"
46 47
47#define HZ_TO_MHZ(a) ((a > 0xF414F9CD7ULL) ? 0xffff : (a >> 32) ? \ 48#define HZ_TO_MHZ(a) ((a > 0xF414F9CD7ULL) ? 0xffff : (a >> 32) ? \
48 (u32) ((a * 0x10C8ULL) >> 32) : (u16) ((u32) a/MHZ)) 49 (u32) ((a * 0x10C8ULL) >> 32) : (u16) ((u32) a/MHZ))
@@ -341,7 +342,8 @@ static int gk20a_ctrl_prepare_compressible_read(
341 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); 342 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
342 struct nvgpu_channel_fence fence; 343 struct nvgpu_channel_fence fence;
343 struct gk20a_fence *fence_out = NULL; 344 struct gk20a_fence *fence_out = NULL;
344 int flags = args->submit_flags; 345 int submit_flags = nvgpu_submit_gpfifo_user_flags_to_common_flags(
346 args->submit_flags);
345 347
346 fence.id = args->fence.syncpt_id; 348 fence.id = args->fence.syncpt_id;
347 fence.value = args->fence.syncpt_value; 349 fence.value = args->fence.syncpt_value;
@@ -351,15 +353,15 @@ static int gk20a_ctrl_prepare_compressible_read(
351 args->compbits_hoffset, args->compbits_voffset, 353 args->compbits_hoffset, args->compbits_voffset,
352 args->scatterbuffer_offset, 354 args->scatterbuffer_offset,
353 args->width, args->height, args->block_height_log2, 355 args->width, args->height, args->block_height_log2,
354 flags, &fence, &args->valid_compbits, 356 submit_flags, &fence, &args->valid_compbits,
355 &args->zbc_color, &fence_out); 357 &args->zbc_color, &fence_out);
356 358
357 if (ret) 359 if (ret)
358 return ret; 360 return ret;
359 361
360 /* Convert fence_out to something we can pass back to user space. */ 362 /* Convert fence_out to something we can pass back to user space. */
361 if (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) { 363 if (submit_flags & NVGPU_SUBMIT_FLAGS_FENCE_GET) {
362 if (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SYNC_FENCE) { 364 if (submit_flags & NVGPU_SUBMIT_FLAGS_SYNC_FENCE) {
363 if (fence_out) { 365 if (fence_out) {
364 int fd = gk20a_fence_install_fd(fence_out); 366 int fd = gk20a_fence_install_fd(fence_out);
365 if (fd < 0) 367 if (fd < 0)
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h
index 2008c471..7fcc54cc 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h
@@ -47,6 +47,15 @@ struct fifo_profile_gk20a;
47#define NVGPU_GPFIFO_FLAGS_REPLAYABLE_FAULTS_ENABLE (1 << 2) 47#define NVGPU_GPFIFO_FLAGS_REPLAYABLE_FAULTS_ENABLE (1 << 2)
48#define NVGPU_GPFIFO_FLAGS_USERMODE_SUPPORT (1 << 3) 48#define NVGPU_GPFIFO_FLAGS_USERMODE_SUPPORT (1 << 3)
49 49
50/* Flags to be passed to gk20a_submit_channel_gpfifo() */
51#define NVGPU_SUBMIT_FLAGS_FENCE_WAIT (1 << 0)
52#define NVGPU_SUBMIT_FLAGS_FENCE_GET (1 << 1)
53#define NVGPU_SUBMIT_FLAGS_HW_FORMAT (1 << 2)
54#define NVGPU_SUBMIT_FLAGS_SYNC_FENCE (1 << 3)
55#define NVGPU_SUBMIT_FLAGS_SUPPRESS_WFI (1 << 4)
56#define NVGPU_SUBMIT_FLAGS_SKIP_BUFFER_REFCOUNTING (1 << 5)
57#define NVGPU_SUBMIT_FLAGS_RESCHEDULE_RUNLIST (1 << 6)
58
50/* 59/*
51 * The binary format of 'struct nvgpu_channel_fence' introduced here 60 * The binary format of 'struct nvgpu_channel_fence' introduced here
52 * should match that of 'struct nvgpu_fence' defined in uapi header, since 61 * should match that of 'struct nvgpu_fence' defined in uapi header, since