From 03b87689025b86b145236a9c707e31a3d3214eb0 Mon Sep 17 00:00:00 2001 From: Sourab Gupta Date: Tue, 27 Mar 2018 19:39:21 +0530 Subject: gpu: nvgpu: pass alloc_gpfifo args to gk20a_channel_alloc_gpfifo The patch defines 'struct nvgpu_gpfifo_args' to be filled by alloc_gpfifo(_ex) ioctls and passed to the gk20a_channel_alloc_gpfifo function. This is required as a prep towards having the usermode submission support in the core channel core. Change-Id: I72acc00cc5558dd3623604da7d716bf849f0152c Signed-off-by: Sourab Gupta Reviewed-on: https://git-master.nvidia.com/r/1683391 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/cde.c | 6 +++- drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 49 +++++++++++++++----------- 2 files changed, 34 insertions(+), 21 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/cde.c b/drivers/gpu/nvgpu/common/linux/cde.c index b366acc4..e5441ac9 100644 --- a/drivers/gpu/nvgpu/common/linux/cde.c +++ b/drivers/gpu/nvgpu/common/linux/cde.c @@ -1277,6 +1277,7 @@ static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx) struct channel_gk20a *ch; struct tsg_gk20a *tsg; struct gr_gk20a *gr = &g->gr; + struct nvgpu_gpfifo_args gpfifo_args; int err = 0; u64 vaddr; @@ -1316,8 +1317,11 @@ static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx) goto err_alloc_gpfifo; } + gpfifo_args.num_entries = 1024; + gpfifo_args.num_inflight_jobs = 0; + gpfifo_args.flags = 0; /* allocate gpfifo (1024 should be more than enough) */ - err = gk20a_channel_alloc_gpfifo(ch, 1024, 0, 0); + err = gk20a_channel_alloc_gpfifo(ch, &gpfifo_args); if (err) { nvgpu_warn(g, "cde: unable to allocate gpfifo"); goto err_alloc_gpfifo; diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 01355b78..9b5a850a 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c @@ -589,16 +589,30 @@ static u32 nvgpu_gpfifo_user_flags_to_common_flags(u32 user_flags) return flags; } -static int nvgpu_channel_ioctl_alloc_gpfifo(struct channel_gk20a *c, - unsigned int num_entries, - unsigned int num_inflight_jobs, - u32 user_flags) +static void nvgpu_get_gpfifo_ex_args( + struct nvgpu_alloc_gpfifo_ex_args *alloc_gpfifo_ex_args, + struct nvgpu_gpfifo_args *gpfifo_args) { - return gk20a_channel_alloc_gpfifo(c, num_entries, - num_inflight_jobs, - nvgpu_gpfifo_user_flags_to_common_flags(user_flags)); + gpfifo_args->num_entries = alloc_gpfifo_ex_args->num_entries; + gpfifo_args->num_inflight_jobs = alloc_gpfifo_ex_args->num_inflight_jobs; + gpfifo_args->flags = nvgpu_gpfifo_user_flags_to_common_flags( + alloc_gpfifo_ex_args->flags); } +static void nvgpu_get_gpfifo_args( + struct nvgpu_alloc_gpfifo_args *alloc_gpfifo_args, + struct nvgpu_gpfifo_args *gpfifo_args) +{ + /* + * Kernel can insert one extra gpfifo entry before user + * submitted gpfifos and another one after, for internal usage. + * Triple the requested size. + */ + gpfifo_args->num_entries = alloc_gpfifo_args->num_entries * 3; + gpfifo_args->num_inflight_jobs = 0; + gpfifo_args->flags = nvgpu_gpfifo_user_flags_to_common_flags( + alloc_gpfifo_args->flags); +} static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch, ulong id, u32 offset, @@ -1075,6 +1089,9 @@ long gk20a_channel_ioctl(struct file *filp, { struct nvgpu_alloc_gpfifo_ex_args *alloc_gpfifo_ex_args = (struct nvgpu_alloc_gpfifo_ex_args *)buf; + struct nvgpu_gpfifo_args gpfifo_args; + + nvgpu_get_gpfifo_ex_args(alloc_gpfifo_ex_args, &gpfifo_args); err = gk20a_busy(ch->g); if (err) { @@ -1089,10 +1106,7 @@ long gk20a_channel_ioctl(struct file *filp, gk20a_idle(ch->g); break; } - err = nvgpu_channel_ioctl_alloc_gpfifo(ch, - alloc_gpfifo_ex_args->num_entries, - alloc_gpfifo_ex_args->num_inflight_jobs, - alloc_gpfifo_ex_args->flags); + err = gk20a_channel_alloc_gpfifo(ch, &gpfifo_args); gk20a_idle(ch->g); break; } @@ -1100,6 +1114,9 @@ long gk20a_channel_ioctl(struct file *filp, { struct nvgpu_alloc_gpfifo_args *alloc_gpfifo_args = (struct nvgpu_alloc_gpfifo_args *)buf; + struct nvgpu_gpfifo_args gpfifo_args; + + nvgpu_get_gpfifo_args(alloc_gpfifo_args, &gpfifo_args); err = gk20a_busy(ch->g); if (err) { @@ -1109,15 +1126,7 @@ long gk20a_channel_ioctl(struct file *filp, break; } - /* - * Kernel can insert one extra gpfifo entry before user - * submitted gpfifos and another one after, for internal usage. - * Triple the requested size. - */ - err = nvgpu_channel_ioctl_alloc_gpfifo(ch, - alloc_gpfifo_args->num_entries * 3, - 0, - alloc_gpfifo_args->flags); + err = gk20a_channel_alloc_gpfifo(ch, &gpfifo_args); gk20a_idle(ch->g); break; } -- cgit v1.2.2