From f8578c92741425ec4630bc9fe52d8537fa8a5c16 Mon Sep 17 00:00:00 2001 From: Sourab Gupta Date: Tue, 10 Apr 2018 12:44:25 +0530 Subject: gpu: nvgpu: remove usage of nvgpu_gpfifo Remove the usage of nvgpu_gpfifo splattered across nvgpu, and replace with a struct defined in common code. The usage is still inside Linux, but this helps the subsequent unification efforts, e.g. to unify the submit path. VQRM-3465 Change-Id: I9e5ac697a0c7f85239ddba319085c09481d20d6b Signed-off-by: Sourab Gupta Reviewed-on: https://git-master.nvidia.com/r/1691978 Reviewed-by: Konsta Holtta GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/cde.c | 12 ++++++------ drivers/gpu/nvgpu/common/linux/cde.h | 6 +++--- drivers/gpu/nvgpu/common/linux/ce2.c | 2 +- drivers/gpu/nvgpu/common/linux/channel.c | 33 ++++++++++++++++---------------- drivers/gpu/nvgpu/common/linux/channel.h | 2 +- drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 13 +++++++++++++ 6 files changed, 41 insertions(+), 27 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/common/linux/cde.c b/drivers/gpu/nvgpu/common/linux/cde.c index aefef882..dcccafb4 100644 --- a/drivers/gpu/nvgpu/common/linux/cde.c +++ b/drivers/gpu/nvgpu/common/linux/cde.c @@ -558,7 +558,7 @@ static int gk20a_init_cde_command(struct gk20a_cde_ctx *cde_ctx, { struct nvgpu_os_linux *l = cde_ctx->l; struct gk20a *g = &l->g; - struct nvgpu_gpfifo **gpfifo, *gpfifo_elem; + struct nvgpu_gpfifo_entry **gpfifo, *gpfifo_elem; u32 *num_entries; unsigned int i; @@ -577,7 +577,7 @@ static int gk20a_init_cde_command(struct gk20a_cde_ctx *cde_ctx, /* allocate gpfifo entries to be pushed */ *gpfifo = nvgpu_kzalloc(g, - sizeof(struct nvgpu_gpfifo) * num_elems); + sizeof(struct nvgpu_gpfifo_entry) * num_elems); if (!*gpfifo) { nvgpu_warn(g, "cde: could not allocate memory for gpfifo entries"); return -ENOMEM; @@ -624,11 +624,11 @@ static int gk20a_cde_pack_cmdbufs(struct gk20a_cde_ctx *cde_ctx) struct nvgpu_os_linux *l = cde_ctx->l; struct gk20a *g = &l->g; unsigned long init_bytes = cde_ctx->init_cmd_num_entries * - sizeof(struct nvgpu_gpfifo); + sizeof(struct nvgpu_gpfifo_entry); unsigned long conv_bytes = cde_ctx->convert_cmd_num_entries * - sizeof(struct nvgpu_gpfifo); + sizeof(struct nvgpu_gpfifo_entry); unsigned long total_bytes = init_bytes + conv_bytes; - struct nvgpu_gpfifo *combined_cmd; + struct nvgpu_gpfifo_entry *combined_cmd; /* allocate buffer that has space for both */ combined_cmd = nvgpu_kzalloc(g, total_bytes); @@ -753,7 +753,7 @@ static int gk20a_cde_execute_buffer(struct gk20a_cde_ctx *cde_ctx, { struct nvgpu_os_linux *l = cde_ctx->l; struct gk20a *g = &l->g; - struct nvgpu_gpfifo *gpfifo = NULL; + struct nvgpu_gpfifo_entry *gpfifo = NULL; int num_entries = 0; /* check command type */ diff --git a/drivers/gpu/nvgpu/common/linux/cde.h b/drivers/gpu/nvgpu/common/linux/cde.h index 9ff142ea..5928b624 100644 --- a/drivers/gpu/nvgpu/common/linux/cde.h +++ b/drivers/gpu/nvgpu/common/linux/cde.h @@ -47,7 +47,7 @@ struct gk20a_fence; struct nvgpu_channel_fence; struct channel_gk20a; struct vm_gk20a; -struct nvgpu_gpfifo; +struct nvgpu_gpfifo_entry; /* * this element defines a buffer that is allocated and mapped into gpu address @@ -258,10 +258,10 @@ struct gk20a_cde_ctx { u64 backing_store_vaddr; - struct nvgpu_gpfifo *init_convert_cmd; + struct nvgpu_gpfifo_entry *init_convert_cmd; int init_cmd_num_entries; - struct nvgpu_gpfifo *convert_cmd; + struct nvgpu_gpfifo_entry *convert_cmd; int convert_cmd_num_entries; struct kobj_attribute attr; diff --git a/drivers/gpu/nvgpu/common/linux/ce2.c b/drivers/gpu/nvgpu/common/linux/ce2.c index d1f0ad63..6ffc0532 100644 --- a/drivers/gpu/nvgpu/common/linux/ce2.c +++ b/drivers/gpu/nvgpu/common/linux/ce2.c @@ -55,7 +55,7 @@ int gk20a_ce_execute_ops(struct gk20a *g, u32 methodSize; u32 cmd_buf_read_offset; u32 dma_copy_class; - struct nvgpu_gpfifo gpfifo; + struct nvgpu_gpfifo_entry gpfifo; struct nvgpu_channel_fence fence = {0, 0}; struct gk20a_fence *ce_cmd_buf_fence_out = NULL; diff --git a/drivers/gpu/nvgpu/common/linux/channel.c b/drivers/gpu/nvgpu/common/linux/channel.c index ad127606..db85f66a 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.c +++ b/drivers/gpu/nvgpu/common/linux/channel.c @@ -328,12 +328,12 @@ void nvgpu_remove_channel_support_linux(struct nvgpu_os_linux *l) u32 nvgpu_get_gpfifo_entry_size(void) { - return sizeof(struct nvgpu_gpfifo); + return sizeof(struct nvgpu_gpfifo_entry); } #ifdef CONFIG_DEBUG_FS static void trace_write_pushbuffer(struct channel_gk20a *c, - struct nvgpu_gpfifo *g) + struct nvgpu_gpfifo_entry *g) { void *mem = NULL; unsigned int words; @@ -371,15 +371,15 @@ static void trace_write_pushbuffer(struct channel_gk20a *c, #endif static void trace_write_pushbuffer_range(struct channel_gk20a *c, - struct nvgpu_gpfifo *g, - struct nvgpu_gpfifo __user *user_gpfifo, + struct nvgpu_gpfifo_entry *g, + struct nvgpu_gpfifo_entry __user *user_gpfifo, int offset, int count) { #ifdef CONFIG_DEBUG_FS u32 size; int i; - struct nvgpu_gpfifo *gp; + struct nvgpu_gpfifo_entry *gp; bool gpfifo_allocated = false; if (!gk20a_debug_trace_cmdbuf) @@ -389,7 +389,7 @@ static void trace_write_pushbuffer_range(struct channel_gk20a *c, return; if (!g) { - size = count * sizeof(struct nvgpu_gpfifo); + size = count * sizeof(struct nvgpu_gpfifo_entry); if (size) { g = nvgpu_big_malloc(c->g, size); if (!g) @@ -553,7 +553,7 @@ static void gk20a_submit_append_priv_cmdbuf(struct channel_gk20a *c, { struct gk20a *g = c->g; struct nvgpu_mem *gpfifo_mem = &c->gpfifo.mem; - struct nvgpu_gpfifo x = { + struct nvgpu_gpfifo_entry x = { .entry0 = u64_lo32(cmd->gva), .entry1 = u64_hi32(cmd->gva) | pbdma_gp_entry1_length_f(cmd->size) @@ -574,17 +574,18 @@ static void gk20a_submit_append_priv_cmdbuf(struct channel_gk20a *c, * splitting into two memcpys to handle wrap-around. */ static int gk20a_submit_append_gpfifo(struct channel_gk20a *c, - struct nvgpu_gpfifo *kern_gpfifo, - struct nvgpu_gpfifo __user *user_gpfifo, + struct nvgpu_gpfifo_entry *kern_gpfifo, + struct nvgpu_gpfifo_entry __user *user_gpfifo, u32 num_entries) { /* byte offsets */ - u32 gpfifo_size = c->gpfifo.entry_num * sizeof(struct nvgpu_gpfifo); - u32 len = num_entries * sizeof(struct nvgpu_gpfifo); - u32 start = c->gpfifo.put * sizeof(struct nvgpu_gpfifo); + u32 gpfifo_size = + c->gpfifo.entry_num * sizeof(struct nvgpu_gpfifo_entry); + u32 len = num_entries * sizeof(struct nvgpu_gpfifo_entry); + u32 start = c->gpfifo.put * sizeof(struct nvgpu_gpfifo_entry); u32 end = start + len; /* exclusive */ struct nvgpu_mem *gpfifo_mem = &c->gpfifo.mem; - struct nvgpu_gpfifo *cpu_src; + struct nvgpu_gpfifo_entry *cpu_src; int err; if (user_gpfifo && !c->gpfifo.pipe) { @@ -659,7 +660,7 @@ out: } int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, - struct nvgpu_gpfifo *gpfifo, + struct nvgpu_gpfifo_entry *gpfifo, struct nvgpu_submit_gpfifo_args *args, u32 num_entries, u32 flags, @@ -681,8 +682,8 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, int err = 0; bool need_job_tracking; bool need_deferred_cleanup = false; - struct nvgpu_gpfifo __user *user_gpfifo = args ? - (struct nvgpu_gpfifo __user *)(uintptr_t)args->gpfifo : NULL; + struct nvgpu_gpfifo_entry __user *user_gpfifo = args ? + (struct nvgpu_gpfifo_entry __user *)(uintptr_t)args->gpfifo : NULL; if (nvgpu_is_enabled(g, NVGPU_DRIVER_IS_DYING)) return -ENODEV; diff --git a/drivers/gpu/nvgpu/common/linux/channel.h b/drivers/gpu/nvgpu/common/linux/channel.h index 85be581a..6026e259 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.h +++ b/drivers/gpu/nvgpu/common/linux/channel.h @@ -71,7 +71,7 @@ struct channel_gk20a *gk20a_open_new_channel_with_cb(struct gk20a *g, bool is_privileged_channel); int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, - struct nvgpu_gpfifo *gpfifo, + struct nvgpu_gpfifo_entry *gpfifo, struct nvgpu_submit_gpfifo_args *args, u32 num_entries, u32 flags, diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index ab1c4a6f..2008c471 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -59,6 +59,19 @@ struct nvgpu_channel_fence { u32 value; }; +/* + * The binary format of 'struct nvgpu_gpfifo_entry' introduced here + * should match that of 'struct nvgpu_gpfifo' defined in uapi header, since + * this struct is intended to be a mirror copy of the uapi struct. This is + * a rigid requirement because there's no conversion function and there are + * memcpy's present between the user gpfifo (of type nvgpu_gpfifo) and the + * kern gpfifo (of type nvgpu_gpfifo_entry). + */ +struct nvgpu_gpfifo_entry { + u32 entry0; + u32 entry1; +}; + struct nvgpu_gpfifo_args { u32 num_entries; u32 num_inflight_jobs; -- cgit v1.2.2