diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/fifo')
-rw-r--r-- | drivers/gpu/nvgpu/common/fifo/channel.c | 21 |
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 @@ | |||
53 | static void free_channel(struct fifo_gk20a *f, struct channel_gk20a *c); | 53 | static void free_channel(struct fifo_gk20a *f, struct channel_gk20a *c); |
54 | static void gk20a_channel_dump_ref_actions(struct channel_gk20a *c); | 54 | static void gk20a_channel_dump_ref_actions(struct channel_gk20a *c); |
55 | 55 | ||
56 | static int channel_gk20a_alloc_priv_cmdbuf(struct channel_gk20a *c); | ||
57 | static void channel_gk20a_free_priv_cmdbuf(struct channel_gk20a *c); | 56 | static void channel_gk20a_free_priv_cmdbuf(struct channel_gk20a *c); |
58 | 57 | ||
59 | static void channel_gk20a_free_prealloc_resources(struct channel_gk20a *c); | 58 | static 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. */ |
736 | static int channel_gk20a_alloc_priv_cmdbuf(struct channel_gk20a *c) | 735 | static 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 | } |