summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-09-13 14:05:09 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-11-16 18:12:27 -0500
commitabcbb58fe4a9af316bde4af58dc8f506a5dcdb59 (patch)
treee7859e8f34e8d76af1ddac9b3a6e7c9d0533db15 /drivers
parent96f2d4320adb866e1f9813309e6c61d761eecc8d (diff)
gpu: nvgpu: Make priv_cmd_buf honor num_in_flight jobs
If num_in_flight jobs is set use that to determine the proper size of the priv_cmd_buf. If num_in_flight is not set then use the original logic: the priv_cmd_buf is sized based on a worst case assumption for the GPFIFO. Also clean up MISRA issues. Bug 2327792 Change-Id: Ie192caeb6cc48fdcac57e5cbb71c534aeaf46011 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1831095 (cherry picked from commit b9ec592f1d3ce23db736ff9c36eab994fc86ed46) Reviewed-on: https://git-master.nvidia.com/r/1949220 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Tested-by: James Norton <jnorton@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/common/fifo/channel.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/common/fifo/channel.c b/drivers/gpu/nvgpu/common/fifo/channel.c
index 2097a28e..8af5f5e9 100644
--- a/drivers/gpu/nvgpu/common/fifo/channel.c
+++ b/drivers/gpu/nvgpu/common/fifo/channel.c
@@ -53,7 +53,6 @@
53static void free_channel(struct fifo_gk20a *f, struct channel_gk20a *c); 53static void free_channel(struct fifo_gk20a *f, struct channel_gk20a *c);
54static void gk20a_channel_dump_ref_actions(struct channel_gk20a *c); 54static void gk20a_channel_dump_ref_actions(struct channel_gk20a *c);
55 55
56static int channel_gk20a_alloc_priv_cmdbuf(struct channel_gk20a *c);
57static void channel_gk20a_free_priv_cmdbuf(struct channel_gk20a *c); 56static void channel_gk20a_free_priv_cmdbuf(struct channel_gk20a *c);
58 57
59static void channel_gk20a_free_prealloc_resources(struct channel_gk20a *c); 58static void channel_gk20a_free_prealloc_resources(struct channel_gk20a *c);
@@ -733,13 +732,20 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g,
733 732
734/* allocate private cmd buffer. 733/* allocate private cmd buffer.
735 used for inserting commands before/after user submitted buffers. */ 734 used for inserting commands before/after user submitted buffers. */
736static int channel_gk20a_alloc_priv_cmdbuf(struct channel_gk20a *c) 735static int channel_gk20a_alloc_priv_cmdbuf(struct channel_gk20a *c,
736 u32 num_in_flight)
737{ 737{
738 struct gk20a *g = c->g; 738 struct gk20a *g = c->g;
739 struct vm_gk20a *ch_vm = c->vm; 739 struct vm_gk20a *ch_vm = c->vm;
740 struct priv_cmd_queue *q = &c->priv_cmd_q; 740 struct priv_cmd_queue *q = &c->priv_cmd_q;
741 u32 size; 741 u32 size;
742 int err = 0; 742 int err = 0;
743 bool gpfifo_based = false;
744
745 if (num_in_flight == 0U) {
746 num_in_flight = c->gpfifo.entry_num;
747 gpfifo_based = true;
748 }
743 749
744 /* 750 /*
745 * Compute the amount of priv_cmdbuf space we need. In general the worst 751 * Compute the amount of priv_cmdbuf space we need. In general the worst
@@ -758,8 +764,12 @@ static int channel_gk20a_alloc_priv_cmdbuf(struct channel_gk20a *c)
758 * 764 *
759 * (gpfifo entry number * (2 / 3) * (8 + 10) * 4 bytes. 765 * (gpfifo entry number * (2 / 3) * (8 + 10) * 4 bytes.
760 */ 766 */
761 size = roundup_pow_of_two(c->gpfifo.entry_num * 767 size = num_in_flight * 18U * (u32)sizeof(u32);
762 2 * 18 * sizeof(u32) / 3); 768 if (gpfifo_based) {
769 size = 2U * size / 3U;
770 }
771
772 size = PAGE_ALIGN(roundup_pow_of_two(size));
763 773
764 err = nvgpu_dma_alloc_map_sys(ch_vm, size, &q->mem); 774 err = nvgpu_dma_alloc_map_sys(ch_vm, size, &q->mem);
765 if (err) { 775 if (err) {
@@ -1230,7 +1240,8 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c,
1230 } 1240 }
1231 } 1241 }
1232 1242
1233 err = channel_gk20a_alloc_priv_cmdbuf(c); 1243 err = channel_gk20a_alloc_priv_cmdbuf(c,
1244 gpfifo_args->num_inflight_jobs);
1234 if (err) { 1245 if (err) {
1235 goto clean_up_prealloc; 1246 goto clean_up_prealloc;
1236 } 1247 }