From 057c6334f7f72071bc87a1793b688b34add7c681 Mon Sep 17 00:00:00 2001 From: Janne Hellsten Date: Mon, 26 Jan 2015 17:27:42 +0200 Subject: gpu: nvgpu: Get rid of legacy gpfifo type Get rid of the duplicate gpfifo struct to emphasize the fact that nvgpu_gpfifo is the only memory layout for gpfifo entries that works. This is the same layout that HW uses. Also, add a local pointer to the gpfifo memory in gk20a_submit_channel_gpfifo to get rid of repeated typecasts. Bug 1592391 Bug 1550886 Change-Id: I5432859ef8e7c1aab5907e44098994d7bb807f50 Signed-off-by: Janne Hellsten Signed-off-by: Konsta Holtta Reviewed-on: http://git-master/r/677341 (cherry picked from commit 724c8c6228af81dd440e825bddf545dd6b2b8bd7) Reviewed-on: http://git-master/r/822548 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Arto Merilainen GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 22 ++++++++++------------ drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 5 ----- include/uapi/linux/nvgpu.h | 1 + 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index f82c63be..5b5da633 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -1381,7 +1381,8 @@ int gk20a_alloc_channel_gpfifo(struct channel_gk20a *c, return -EEXIST; } - err = gk20a_gmmu_alloc_map(ch_vm, gpfifo_size * sizeof(struct gpfifo), + err = gk20a_gmmu_alloc_map(ch_vm, + gpfifo_size * sizeof(struct nvgpu_gpfifo), &c->gpfifo.mem); if (err) { gk20a_err(d, "%s: memory allocation failed\n", __func__); @@ -1812,6 +1813,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, * and one for post fence. */ const int extra_entries = 2; bool need_wfi = !(flags & NVGPU_SUBMIT_GPFIFO_FLAGS_SUPPRESS_WFI); + struct nvgpu_gpfifo *gpfifo_mem = c->gpfifo.mem.cpu_va; if (c->has_timedout) return -ETIMEDOUT; @@ -1948,10 +1950,8 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, } if (wait_cmd) { - ((struct gpfifo *)(c->gpfifo.mem.cpu_va))[c->gpfifo.put].entry0 = - u64_lo32(wait_cmd->gva); - ((struct gpfifo *)(c->gpfifo.mem.cpu_va))[c->gpfifo.put].entry1 = - u64_hi32(wait_cmd->gva) | + gpfifo_mem[c->gpfifo.put].entry0 = u64_lo32(wait_cmd->gva); + gpfifo_mem[c->gpfifo.put].entry1 = u64_hi32(wait_cmd->gva) | pbdma_gp_entry1_length_f(wait_cmd->size); trace_gk20a_push_cmdbuf(c->g->dev->name, 0, wait_cmd->size, 0, wait_cmd->ptr); @@ -1975,16 +1975,16 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, int length0 = c->gpfifo.entry_num - start; int length1 = num_entries - length0; - memcpy((struct gpfifo *)c->gpfifo.mem.cpu_va + start, gpfifo, + memcpy(gpfifo_mem + start, gpfifo, length0 * sizeof(*gpfifo)); - memcpy((struct gpfifo *)c->gpfifo.mem.cpu_va, gpfifo + length0, + memcpy(gpfifo_mem, gpfifo + length0, length1 * sizeof(*gpfifo)); trace_write_pushbuffer_range(c, gpfifo, length0); trace_write_pushbuffer_range(c, gpfifo + length0, length1); } else { - memcpy((struct gpfifo *)c->gpfifo.mem.cpu_va + start, gpfifo, + memcpy(gpfifo_mem + start, gpfifo, num_entries * sizeof(*gpfifo)); trace_write_pushbuffer_range(c, gpfifo, num_entries); @@ -1993,10 +1993,8 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, (c->gpfifo.entry_num - 1); if (incr_cmd) { - ((struct gpfifo *)(c->gpfifo.mem.cpu_va))[c->gpfifo.put].entry0 = - u64_lo32(incr_cmd->gva); - ((struct gpfifo *)(c->gpfifo.mem.cpu_va))[c->gpfifo.put].entry1 = - u64_hi32(incr_cmd->gva) | + gpfifo_mem[c->gpfifo.put].entry0 = u64_lo32(incr_cmd->gva); + gpfifo_mem[c->gpfifo.put].entry1 = u64_hi32(incr_cmd->gva) | pbdma_gp_entry1_length_f(incr_cmd->size); trace_gk20a_push_cmdbuf(c->g->dev->name, 0, incr_cmd->size, 0, incr_cmd->ptr); diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index 794d8228..29697b9f 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -38,11 +38,6 @@ struct gk20a_fence; #include "gr_gk20a.h" #include "fence_gk20a.h" -struct gpfifo { - u32 entry0; - u32 entry1; -}; - struct notification { struct { u32 nanoseconds[2]; diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h index 138d7971..6fdf4025 100644 --- a/include/uapi/linux/nvgpu.h +++ b/include/uapi/linux/nvgpu.h @@ -563,6 +563,7 @@ struct nvgpu_dbg_gpu_pc_sampling_args { #define NVGPU_PRIORITY_HIGH 150 #define NVGPU_TIMEOUT_FLAG_DISABLE_DUMP 0 +/* this is also the hardware memory format */ struct nvgpu_gpfifo { __u32 entry0; /* first word of gpfifo entry */ __u32 entry1; /* second word of gpfifo entry */ -- cgit v1.2.2