diff --git a/drivers/gpu/nvgpu/common/fifo/submit.c b/drivers/gpu/nvgpu/common/fifo/submit.c index dcd82f515..1901cf2df 100644 --- a/drivers/gpu/nvgpu/common/fifo/submit.c +++ b/drivers/gpu/nvgpu/common/fifo/submit.c @@ -326,7 +326,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, u32 flags, struct nvgpu_channel_fence *fence, struct nvgpu_fence_type **fence_out, - struct fifo_profile_gk20a *profile) + struct nvgpu_profile *profile) { struct gk20a *g = c->g; struct priv_cmd_entry *wait_cmd = NULL; @@ -381,7 +381,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, return -EINVAL; } - gk20a_fifo_profile_snapshot(profile, PROFILE_ENTRY); + nvgpu_profile_snapshot(profile, PROFILE_ENTRY); /* update debug settings */ nvgpu_ltc_sync_enabled(g); @@ -534,7 +534,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, } } - gk20a_fifo_profile_snapshot(profile, PROFILE_JOB_TRACKING); + nvgpu_profile_snapshot(profile, PROFILE_JOB_TRACKING); if (wait_cmd != NULL) { nvgpu_submit_append_priv_cmdbuf(c, wait_cmd); @@ -562,7 +562,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, /* TODO! Check for errors... */ gk20a_channel_add_job(c, job, skip_buffer_refcounting); } - gk20a_fifo_profile_snapshot(profile, PROFILE_APPEND); + nvgpu_profile_snapshot(profile, PROFILE_APPEND); g->ops.userd.gp_put(g, c); @@ -581,7 +581,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, nvgpu_log_info(g, "post-submit put %d, get %d, size %d", c->gpfifo.put, c->gpfifo.get, c->gpfifo.entry_num); - gk20a_fifo_profile_snapshot(profile, PROFILE_END); + nvgpu_profile_snapshot(profile, PROFILE_END); nvgpu_log_fn(g, "done"); return err; @@ -606,7 +606,7 @@ int nvgpu_submit_channel_gpfifo_user(struct channel_gk20a *c, u32 flags, struct nvgpu_channel_fence *fence, struct nvgpu_fence_type **fence_out, - struct fifo_profile_gk20a *profile) + struct nvgpu_profile *profile) { return nvgpu_submit_channel_gpfifo(c, NULL, userdata, num_entries, flags, fence, fence_out, profile); diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h index 8cc88f5e2..2d307dc61 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h @@ -29,9 +29,9 @@ #include #include #include +#include struct gk20a_debug_output; -struct nvgpu_semaphore; struct channel_gk20a; struct tsg_gk20a; @@ -42,29 +42,6 @@ struct tsg_gk20a; #define FIFO_INVAL_RUNLIST_ID (~U32(0U)) #define FIFO_INVAL_SYNCPT_ID (~U32(0U)) -/* - * Number of entries in the kickoff latency buffer, used to calculate - * the profiling and histogram. This number is calculated to be statistically - * significative on a histogram on a 5% step - */ -#ifdef CONFIG_DEBUG_FS -#define FIFO_PROFILING_ENTRIES 16384U -#endif - -enum { - PROFILE_IOCTL_ENTRY = 0U, - PROFILE_ENTRY, - PROFILE_JOB_TRACKING, - PROFILE_APPEND, - PROFILE_END, - PROFILE_IOCTL_EXIT, - PROFILE_MAX -}; - -struct fifo_profile_gk20a { - u64 timestamp[PROFILE_MAX]; -}; - struct fifo_gk20a { struct gk20a *g; unsigned int num_channels; @@ -91,7 +68,7 @@ struct fifo_gk20a { u32 num_runlists; /* number of active runlists */ #ifdef CONFIG_DEBUG_FS struct { - struct fifo_profile_gk20a *data; + struct nvgpu_profile *data; nvgpu_atomic_t get; bool enabled; u64 *sorted; @@ -151,25 +128,4 @@ int gk20a_fifo_init_pbdma_map(struct gk20a *g, u32 *pbdma_map, u32 num_pbdma); u32 gk20a_fifo_get_runlist_timeslice(struct gk20a *g); u32 gk20a_fifo_get_pb_timeslice(struct gk20a *g); -#ifdef CONFIG_DEBUG_FS -struct fifo_profile_gk20a *gk20a_fifo_profile_acquire(struct gk20a *g); -void gk20a_fifo_profile_release(struct gk20a *g, - struct fifo_profile_gk20a *profile); -void gk20a_fifo_profile_snapshot(struct fifo_profile_gk20a *profile, int idx); -#else -static inline struct fifo_profile_gk20a * -gk20a_fifo_profile_acquire(struct gk20a *g) -{ - return NULL; -} -static inline void gk20a_fifo_profile_release(struct gk20a *g, - struct fifo_profile_gk20a *profile) -{ -} -static inline void gk20a_fifo_profile_snapshot( - struct fifo_profile_gk20a *profile, int idx) -{ -} -#endif - #endif /* FIFO_GK20A_H */ diff --git a/drivers/gpu/nvgpu/include/nvgpu/channel.h b/drivers/gpu/nvgpu/include/nvgpu/channel.h index 1712f6bc7..a61ce9139 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/channel.h +++ b/drivers/gpu/nvgpu/include/nvgpu/channel.h @@ -35,7 +35,7 @@ struct gk20a; struct dbg_session_gk20a; struct nvgpu_fence_type; -struct fifo_profile_gk20a; +struct nvgpu_profile; struct nvgpu_channel_sync; struct nvgpu_gpfifo_userdata; struct nvgpu_gr_subctx; @@ -507,7 +507,7 @@ int nvgpu_submit_channel_gpfifo_user(struct channel_gk20a *c, u32 flags, struct nvgpu_channel_fence *fence, struct nvgpu_fence_type **fence_out, - struct fifo_profile_gk20a *profile); + struct nvgpu_profile *profile); int nvgpu_submit_channel_gpfifo_kernel(struct channel_gk20a *c, struct nvgpu_gpfifo_entry *gpfifo, diff --git a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h index 288387a82..11cd7f912 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h @@ -119,6 +119,7 @@ typedef void (*global_ctx_mem_destroy_fn)(struct gk20a *g, #include #include #include +#include #include "hal/clk/clk_gk20a.h" #include "gk20a/fifo_gk20a.h" diff --git a/drivers/gpu/nvgpu/include/nvgpu/profile.h b/drivers/gpu/nvgpu/include/nvgpu/profile.h new file mode 100644 index 000000000..dc54e7ffe --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/profile.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2011-2019, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef NVGPU_PROFILE_H +#define NVGPU_PROFILE_H + +/* + * Number of entries in the kickoff latency buffer, used to calculate + * the profiling and histogram. This number is calculated to be statistically + * significative on a histogram on a 5% step + */ +#ifdef CONFIG_DEBUG_FS +#define FIFO_PROFILING_ENTRIES 16384U +#endif + +enum { + PROFILE_IOCTL_ENTRY = 0U, + PROFILE_ENTRY, + PROFILE_JOB_TRACKING, + PROFILE_APPEND, + PROFILE_END, + PROFILE_IOCTL_EXIT, + PROFILE_MAX +}; + +struct nvgpu_profile { + u64 timestamp[PROFILE_MAX]; +}; + +#ifdef CONFIG_DEBUG_FS +struct nvgpu_profile *nvgpu_profile_acquire(struct gk20a *g); +void nvgpu_profile_release(struct gk20a *g, + struct nvgpu_profile *profile); +void nvgpu_profile_snapshot(struct nvgpu_profile *profile, int idx); +#else +static inline struct nvgpu_profile * +nvgpu_profile_acquire(struct gk20a *g) +{ + return NULL; +} +static inline void nvgpu_profile_release(struct gk20a *g, + struct nvgpu_profile *profile) +{ +} +static inline void nvgpu_profile_snapshot( + struct nvgpu_profile *profile, int idx) +{ +} +#endif + +#endif /* NVGPU_PROFILE_H */ diff --git a/drivers/gpu/nvgpu/os/linux/channel.h b/drivers/gpu/nvgpu/os/linux/channel.h index b88a2deec..aa6a231a7 100644 --- a/drivers/gpu/nvgpu/os/linux/channel.h +++ b/drivers/gpu/nvgpu/os/linux/channel.h @@ -26,7 +26,7 @@ struct nvgpu_gpfifo; struct nvgpu_submit_gpfifo_args; struct nvgpu_channel_fence; struct nvgpu_fence_type; -struct fifo_profile_gk20a; +struct nvgpu_profile; struct nvgpu_os_linux; struct sync_fence; diff --git a/drivers/gpu/nvgpu/os/linux/debug_fifo.c b/drivers/gpu/nvgpu/os/linux/debug_fifo.c index f53df4798..b3041e197 100644 --- a/drivers/gpu/nvgpu/os/linux/debug_fifo.c +++ b/drivers/gpu/nvgpu/os/linux/debug_fifo.c @@ -23,6 +23,7 @@ #include #include #include +#include void __gk20a_fifo_profile_free(struct nvgpu_ref *ref); @@ -161,7 +162,7 @@ static int gk20a_fifo_profile_enable(void *data, u64 val) if (!nvgpu_ref_get_unless_zero(&f->profile.ref)) { f->profile.data = nvgpu_vzalloc(g, FIFO_PROFILING_ENTRIES * - sizeof(struct fifo_profile_gk20a)); + sizeof(struct nvgpu_profile)); f->profile.sorted = nvgpu_vzalloc(g, FIFO_PROFILING_ENTRIES * sizeof(u64)); @@ -206,7 +207,7 @@ static unsigned int __gk20a_fifo_create_stats(struct gk20a *g, { unsigned int nelem = 0; unsigned int index; - struct fifo_profile_gk20a *profile; + struct nvgpu_profile *profile; for (index = 0; index < FIFO_PROFILING_ENTRIES; index++) { profile = &g->fifo.profile.data[index]; @@ -329,7 +330,7 @@ void gk20a_fifo_debugfs_init(struct gk20a *g) } -void gk20a_fifo_profile_snapshot(struct fifo_profile_gk20a *profile, int idx) +void nvgpu_profile_snapshot(struct nvgpu_profile *profile, int idx) { if (profile) profile->timestamp[idx] = nvgpu_current_time_ns(); @@ -346,10 +347,10 @@ void __gk20a_fifo_profile_free(struct nvgpu_ref *ref) /* Get the next element in the ring buffer of profile entries * and grab a reference to the structure */ -struct fifo_profile_gk20a *gk20a_fifo_profile_acquire(struct gk20a *g) +struct nvgpu_profile *nvgpu_profile_acquire(struct gk20a *g) { struct fifo_gk20a *f = &g->fifo; - struct fifo_profile_gk20a *profile; + struct nvgpu_profile *profile; unsigned int index; /* If kref is zero, profiling is not enabled */ @@ -362,8 +363,8 @@ struct fifo_profile_gk20a *gk20a_fifo_profile_acquire(struct gk20a *g) } /* Free the reference to the structure. This allows deferred cleanups */ -void gk20a_fifo_profile_release(struct gk20a *g, - struct fifo_profile_gk20a *profile) +void nvgpu_profile_release(struct gk20a *g, + struct nvgpu_profile *profile) { nvgpu_ref_put(&g->fifo.profile.ref, __gk20a_fifo_profile_free); } diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index 6b7120439..f35b8b98f 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "platform_gk20a.h" #include "ioctl_channel.h" @@ -771,7 +772,7 @@ static int gk20a_ioctl_channel_submit_gpfifo( { struct nvgpu_channel_fence fence; struct nvgpu_fence_type *fence_out; - struct fifo_profile_gk20a *profile = NULL; + struct nvgpu_profile *profile = NULL; u32 submit_flags = 0; int fd = -1; struct gk20a *g = ch->g; @@ -780,8 +781,8 @@ static int gk20a_ioctl_channel_submit_gpfifo( int ret = 0; nvgpu_log_fn(g, " "); - profile = gk20a_fifo_profile_acquire(ch->g); - gk20a_fifo_profile_snapshot(profile, PROFILE_IOCTL_ENTRY); + profile = nvgpu_profile_acquire(ch->g); + nvgpu_profile_snapshot(profile, PROFILE_IOCTL_ENTRY); if (gk20a_channel_check_unserviceable(ch)) { return -ETIMEDOUT; @@ -828,9 +829,9 @@ static int gk20a_ioctl_channel_submit_gpfifo( } nvgpu_fence_put(fence_out); - gk20a_fifo_profile_snapshot(profile, PROFILE_IOCTL_EXIT); + nvgpu_profile_snapshot(profile, PROFILE_IOCTL_EXIT); if (profile) - gk20a_fifo_profile_release(ch->g, profile); + nvgpu_profile_release(ch->g, profile); clean_up: return ret;