gpu: nvgpu: cyclestats snapshot permissions rework

Cyclestats snapshot feature is expected for new devices.
The detection code was isolated in separate function and run-time
check added to validate/allow ioctl calls on the current GPU.

Bug 1674079

Change-Id: Icc2f1e5cc50d39b395d31d5292c314f99d67f3eb
Signed-off-by: Leonid Moiseichuk <lmoiseichuk@nvidia.com>
Reviewed-on: http://git-master/r/781697
(cherry picked from commit bdd23136b182c933841f91dd2829061e278a46d4)
Reviewed-on: http://git-master/r/793630
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
Leonid Moiseichuk
2015-08-11 13:38:51 +03:00
committed by Terje Bergstrom
parent eeb604c23d
commit 54c2ae59f0
5 changed files with 38 additions and 10 deletions

View File

@@ -467,6 +467,11 @@ static int gk20a_channel_cycle_stats(struct channel_gk20a *ch,
struct dma_buf *dmabuf;
void *virtual_address;
/* is it allowed to handle calls for current GPU? */
if (0 == (ch->g->gpu_characteristics.flags &
NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS))
return -ENOSYS;
if (args->dmabuf_fd && !ch->cyclestate.cyclestate_buffer_handler) {
/* set up new cyclestats buffer */
@@ -556,6 +561,11 @@ static int gk20a_channel_cycle_stats_snapshot(struct channel_gk20a *ch,
{
int ret;
/* is it allowed to handle calls for current GPU? */
if (0 == (ch->g->gpu_characteristics.flags &
NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT))
return -ENOSYS;
if (!args->dmabuf_fd)
return -EINVAL;

View File

@@ -1965,20 +1965,13 @@ int gk20a_init_gpu_characteristics(struct gk20a *g)
gk20a_platform_has_syncpoints(g->dev))
gpu->flags |= NVGPU_GPU_FLAGS_HAS_SYNCPOINTS;
if (IS_ENABLED(CONFIG_GK20A_CYCLE_STATS)) {
gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS;
/* the snapshots must be supported only for t210 */
if (NVGPU_GPU_ARCH_GM200 == gpu->arch &&
NVGPU_GPU_IMPL_GM20B == gpu->impl) {
gpu->flags |=
NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT;
}
}
gpu->gpc_mask = 1;
g->ops.gr.detect_sm_arch(g);
if (g->ops.gr.init_cyclestats)
g->ops.gr.init_cyclestats(g);
gpu->gpu_ioctl_nr_last = NVGPU_GPU_IOCTL_LAST;
gpu->tsg_ioctl_nr_last = NVGPU_TSG_IOCTL_LAST;
gpu->dbg_gpu_ioctl_nr_last = NVGPU_DBG_GPU_IOCTL_LAST;

View File

@@ -179,6 +179,7 @@ struct gpu_ops {
void (*init_sm_dsm_reg_info)(void);
int (*wait_empty)(struct gk20a *g, unsigned long end_jiffies,
u32 expect_delay);
void (*init_cyclestats)(struct gk20a *g);
} gr;
const char *name;
struct {

View File

@@ -7333,6 +7333,16 @@ int gr_gk20a_debugfs_init(struct gk20a *g)
return 0;
}
static void gr_gk20a_init_cyclestats(struct gk20a *g)
{
#if defined(CONFIG_GK20A_CYCLE_STATS)
g->gpu_characteristics.flags |=
NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS;
#else
(void)g;
#endif
}
void gk20a_init_gr_ops(struct gpu_ops *gops)
{
gops->gr.access_smpc_reg = gr_gk20a_access_smpc_reg;
@@ -7383,4 +7393,5 @@ void gk20a_init_gr_ops(struct gpu_ops *gops)
gops->gr.get_rop_l2_en_mask = gr_gk20a_rop_l2_en_mask;
gops->gr.init_sm_dsm_reg_info = gr_gk20a_init_sm_dsm_reg_info;
gops->gr.wait_empty = gr_gk20a_wait_idle;
gops->gr.init_cyclestats = gr_gk20a_init_cyclestats;
}

View File

@@ -1040,6 +1040,18 @@ static u32 gr_gm20b_get_max_fbps_count(struct gk20a *g)
return max_fbps_count;
}
static void gr_gm20b_init_cyclestats(struct gk20a *g)
{
#if defined(CONFIG_GK20A_CYCLE_STATS)
g->gpu_characteristics.flags |=
NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS;
g->gpu_characteristics.flags |=
NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT;
#else
(void)g;
#endif
}
void gm20b_init_gr(struct gpu_ops *gops)
{
gops->gr.init_gpc_mmu = gr_gm20b_init_gpc_mmu;
@@ -1094,4 +1106,5 @@ void gm20b_init_gr(struct gpu_ops *gops)
gops->gr.get_max_fbps_count = gr_gm20b_get_max_fbps_count;
gops->gr.init_sm_dsm_reg_info = gr_gm20b_init_sm_dsm_reg_info;
gops->gr.wait_empty = gr_gk20a_wait_idle;
gops->gr.init_cyclestats = gr_gm20b_init_cyclestats;
}