From 585e33e4082baaf58d3714c42200f3c72bffa218 Mon Sep 17 00:00:00 2001 From: Sourab Gupta Date: Tue, 10 Apr 2018 12:05:09 +0530 Subject: gpu: nvgpu: remove usage of nvgpu_fence Remove the usage of nvgpu_fence 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: Ic3737450123dfc5e1c40ca5b6b8d8f6b3070aa0d Signed-off-by: Sourab Gupta Reviewed-on: https://git-master.nvidia.com/r/1691977 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 | 10 +++++----- drivers/gpu/nvgpu/common/linux/cde.h | 6 +++--- drivers/gpu/nvgpu/common/linux/ce2.c | 2 +- drivers/gpu/nvgpu/common/linux/channel.c | 4 ++-- drivers/gpu/nvgpu/common/linux/channel.h | 4 ++-- drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 12 +++++++++++- drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c | 2 +- drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 12 ++++++++++++ 8 files changed, 37 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/cde.c b/drivers/gpu/nvgpu/common/linux/cde.c index e5441ac9..aefef882 100644 --- a/drivers/gpu/nvgpu/common/linux/cde.c +++ b/drivers/gpu/nvgpu/common/linux/cde.c @@ -748,7 +748,7 @@ deinit_image: } static int gk20a_cde_execute_buffer(struct gk20a_cde_ctx *cde_ctx, - u32 op, struct nvgpu_fence *fence, + u32 op, struct nvgpu_channel_fence *fence, u32 flags, struct gk20a_fence **fence_out) { struct nvgpu_os_linux *l = cde_ctx->l; @@ -975,7 +975,7 @@ int gk20a_cde_convert(struct nvgpu_os_linux *l, struct dma_buf *compbits_scatter_buf, u64 compbits_byte_offset, u64 scatterbuffer_byte_offset, - struct nvgpu_fence *fence, + struct nvgpu_channel_fence *fence, u32 __flags, struct gk20a_cde_param *params, int num_params, struct gk20a_fence **fence_out) __acquires(&l->cde_app->mutex) @@ -1482,7 +1482,7 @@ static int gk20a_buffer_convert_gpu_to_cde_v1( u64 offset, u64 compbits_hoffset, u64 compbits_voffset, u64 scatterbuffer_offset, u32 width, u32 height, u32 block_height_log2, - u32 submit_flags, struct nvgpu_fence *fence_in, + u32 submit_flags, struct nvgpu_channel_fence *fence_in, struct gk20a_buffer_state *state) { struct gk20a *g = &l->g; @@ -1624,7 +1624,7 @@ static int gk20a_buffer_convert_gpu_to_cde( u64 offset, u64 compbits_hoffset, u64 compbits_voffset, u64 scatterbuffer_offset, u32 width, u32 height, u32 block_height_log2, - u32 submit_flags, struct nvgpu_fence *fence_in, + u32 submit_flags, struct nvgpu_channel_fence *fence_in, struct gk20a_buffer_state *state) { struct gk20a *g = &l->g; @@ -1656,7 +1656,7 @@ int gk20a_prepare_compressible_read( u64 compbits_hoffset, u64 compbits_voffset, u64 scatterbuffer_offset, u32 width, u32 height, u32 block_height_log2, - u32 submit_flags, struct nvgpu_fence *fence, + u32 submit_flags, struct nvgpu_channel_fence *fence, u32 *valid_compbits, u32 *zbc_color, struct gk20a_fence **fence_out) { diff --git a/drivers/gpu/nvgpu/common/linux/cde.h b/drivers/gpu/nvgpu/common/linux/cde.h index 115558dc..9ff142ea 100644 --- a/drivers/gpu/nvgpu/common/linux/cde.h +++ b/drivers/gpu/nvgpu/common/linux/cde.h @@ -44,7 +44,7 @@ struct device; struct nvgpu_os_linux; struct gk20a; struct gk20a_fence; -struct nvgpu_fence; +struct nvgpu_channel_fence; struct channel_gk20a; struct vm_gk20a; struct nvgpu_gpfifo; @@ -306,7 +306,7 @@ int gk20a_cde_convert(struct nvgpu_os_linux *l, struct dma_buf *compbits_buf, u64 compbits_byte_offset, u64 scatterbuffer_byte_offset, - struct nvgpu_fence *fence, + struct nvgpu_channel_fence *fence, u32 __flags, struct gk20a_cde_param *params, int num_params, struct gk20a_fence **fence_out); @@ -315,7 +315,7 @@ int gk20a_prepare_compressible_read( u64 compbits_hoffset, u64 compbits_voffset, u64 scatterbuffer_offset, u32 width, u32 height, u32 block_height_log2, - u32 submit_flags, struct nvgpu_fence *fence, + u32 submit_flags, struct nvgpu_channel_fence *fence, u32 *valid_compbits, u32 *zbc_color, struct gk20a_fence **fence_out); int gk20a_mark_compressible_write( diff --git a/drivers/gpu/nvgpu/common/linux/ce2.c b/drivers/gpu/nvgpu/common/linux/ce2.c index 7cb39382..d1f0ad63 100644 --- a/drivers/gpu/nvgpu/common/linux/ce2.c +++ b/drivers/gpu/nvgpu/common/linux/ce2.c @@ -56,7 +56,7 @@ int gk20a_ce_execute_ops(struct gk20a *g, u32 cmd_buf_read_offset; u32 dma_copy_class; struct nvgpu_gpfifo gpfifo; - struct nvgpu_fence fence = {0,0}; + struct nvgpu_channel_fence fence = {0, 0}; struct gk20a_fence *ce_cmd_buf_fence_out = NULL; if (!ce_app->initialised ||ce_app->app_state != NVGPU_CE_ACTIVE) diff --git a/drivers/gpu/nvgpu/common/linux/channel.c b/drivers/gpu/nvgpu/common/linux/channel.c index dc35fbc0..ad127606 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.c +++ b/drivers/gpu/nvgpu/common/linux/channel.c @@ -416,7 +416,7 @@ static void trace_write_pushbuffer_range(struct channel_gk20a *c, * Handle the submit synchronization - pre-fences and post-fences. */ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, - struct nvgpu_fence *fence, + struct nvgpu_channel_fence *fence, struct channel_gk20a_job *job, struct priv_cmd_entry **wait_cmd, struct priv_cmd_entry **incr_cmd, @@ -663,7 +663,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, struct nvgpu_submit_gpfifo_args *args, u32 num_entries, u32 flags, - struct nvgpu_fence *fence, + struct nvgpu_channel_fence *fence, struct gk20a_fence **fence_out, bool force_need_sync_fence, struct fifo_profile_gk20a *profile) diff --git a/drivers/gpu/nvgpu/common/linux/channel.h b/drivers/gpu/nvgpu/common/linux/channel.h index 35be425a..85be581a 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.h +++ b/drivers/gpu/nvgpu/common/linux/channel.h @@ -24,7 +24,7 @@ struct channel_gk20a; struct nvgpu_gpfifo; struct nvgpu_submit_gpfifo_args; -struct nvgpu_fence; +struct nvgpu_channel_fence; struct gk20a_fence; struct fifo_profile_gk20a; struct nvgpu_os_linux; @@ -75,7 +75,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, struct nvgpu_submit_gpfifo_args *args, u32 num_entries, u32 flags, - struct nvgpu_fence *fence, + struct nvgpu_channel_fence *fence, struct gk20a_fence **fence_out, bool force_need_sync_fence, struct fifo_profile_gk20a *profile); diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 9b5a850a..c75c9244 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c @@ -614,6 +614,14 @@ static void nvgpu_get_gpfifo_args( alloc_gpfifo_args->flags); } +static void nvgpu_get_fence_args( + struct nvgpu_fence *fence_args_in, + struct nvgpu_channel_fence *fence_args_out) +{ + fence_args_out->id = fence_args_in->id; + fence_args_out->value = fence_args_in->value; +} + static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch, ulong id, u32 offset, u32 payload, u32 timeout) @@ -760,6 +768,7 @@ static int gk20a_ioctl_channel_submit_gpfifo( struct channel_gk20a *ch, struct nvgpu_submit_gpfifo_args *args) { + struct nvgpu_channel_fence fence; struct gk20a_fence *fence_out; struct fifo_profile_gk20a *profile = NULL; @@ -779,8 +788,9 @@ static int gk20a_ioctl_channel_submit_gpfifo( !capable(CAP_SYS_NICE)) return -EPERM; + nvgpu_get_fence_args(&args->fence, &fence); ret = gk20a_submit_channel_gpfifo(ch, NULL, args, args->num_entries, - args->flags, &args->fence, + args->flags, &fence, &fence_out, false, profile); if (ret) diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c index c37f45dd..3392b6fa 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c @@ -339,7 +339,7 @@ static int gk20a_ctrl_prepare_compressible_read( #ifdef CONFIG_NVGPU_SUPPORT_CDE struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); - struct nvgpu_fence fence; + struct nvgpu_channel_fence fence; struct gk20a_fence *fence_out = NULL; int flags = args->submit_flags; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index cd5bf7d7..ab1c4a6f 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -47,6 +47,18 @@ struct fifo_profile_gk20a; #define NVGPU_GPFIFO_FLAGS_REPLAYABLE_FAULTS_ENABLE (1 << 2) #define NVGPU_GPFIFO_FLAGS_USERMODE_SUPPORT (1 << 3) +/* + * The binary format of 'struct nvgpu_channel_fence' introduced here + * should match that of 'struct nvgpu_fence' defined in uapi header, since + * this struct is intended to be a mirror copy of the uapi struct. This is + * not a hard requirement though because of nvgpu_get_fence_args conversion + * function. + */ +struct nvgpu_channel_fence { + u32 id; + u32 value; +}; + struct nvgpu_gpfifo_args { u32 num_entries; u32 num_inflight_jobs; -- cgit v1.2.2