summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLeonid Moiseichuk <lmoiseichuk@nvidia.com>2015-08-11 06:38:51 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2015-09-04 12:03:07 -0400
commit54c2ae59f0010c75bc03719e7b5ece4040c102d3 (patch)
tree549ea910d4de7dde2d335e3f0198baab51354177 /drivers
parenteeb604c23d4ea7a6a7900b99a2ae92cff0488112 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.c10
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c13
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c11
-rw-r--r--drivers/gpu/nvgpu/gm20b/gr_gm20b.c13
5 files changed, 38 insertions, 10 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
index 2ba160dd..21a3bec5 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
@@ -467,6 +467,11 @@ static int gk20a_channel_cycle_stats(struct channel_gk20a *ch,
467 struct dma_buf *dmabuf; 467 struct dma_buf *dmabuf;
468 void *virtual_address; 468 void *virtual_address;
469 469
470 /* is it allowed to handle calls for current GPU? */
471 if (0 == (ch->g->gpu_characteristics.flags &
472 NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS))
473 return -ENOSYS;
474
470 if (args->dmabuf_fd && !ch->cyclestate.cyclestate_buffer_handler) { 475 if (args->dmabuf_fd && !ch->cyclestate.cyclestate_buffer_handler) {
471 476
472 /* set up new cyclestats buffer */ 477 /* set up new cyclestats buffer */
@@ -556,6 +561,11 @@ static int gk20a_channel_cycle_stats_snapshot(struct channel_gk20a *ch,
556{ 561{
557 int ret; 562 int ret;
558 563
564 /* is it allowed to handle calls for current GPU? */
565 if (0 == (ch->g->gpu_characteristics.flags &
566 NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT))
567 return -ENOSYS;
568
559 if (!args->dmabuf_fd) 569 if (!args->dmabuf_fd)
560 return -EINVAL; 570 return -EINVAL;
561 571
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 7875d621..c0889571 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -1965,20 +1965,13 @@ int gk20a_init_gpu_characteristics(struct gk20a *g)
1965 gk20a_platform_has_syncpoints(g->dev)) 1965 gk20a_platform_has_syncpoints(g->dev))
1966 gpu->flags |= NVGPU_GPU_FLAGS_HAS_SYNCPOINTS; 1966 gpu->flags |= NVGPU_GPU_FLAGS_HAS_SYNCPOINTS;
1967 1967
1968 if (IS_ENABLED(CONFIG_GK20A_CYCLE_STATS)) {
1969 gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS;
1970 /* the snapshots must be supported only for t210 */
1971 if (NVGPU_GPU_ARCH_GM200 == gpu->arch &&
1972 NVGPU_GPU_IMPL_GM20B == gpu->impl) {
1973 gpu->flags |=
1974 NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT;
1975 }
1976 }
1977
1978 gpu->gpc_mask = 1; 1968 gpu->gpc_mask = 1;
1979 1969
1980 g->ops.gr.detect_sm_arch(g); 1970 g->ops.gr.detect_sm_arch(g);
1981 1971
1972 if (g->ops.gr.init_cyclestats)
1973 g->ops.gr.init_cyclestats(g);
1974
1982 gpu->gpu_ioctl_nr_last = NVGPU_GPU_IOCTL_LAST; 1975 gpu->gpu_ioctl_nr_last = NVGPU_GPU_IOCTL_LAST;
1983 gpu->tsg_ioctl_nr_last = NVGPU_TSG_IOCTL_LAST; 1976 gpu->tsg_ioctl_nr_last = NVGPU_TSG_IOCTL_LAST;
1984 gpu->dbg_gpu_ioctl_nr_last = NVGPU_DBG_GPU_IOCTL_LAST; 1977 gpu->dbg_gpu_ioctl_nr_last = NVGPU_DBG_GPU_IOCTL_LAST;
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index ed209929..d48b94aa 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -179,6 +179,7 @@ struct gpu_ops {
179 void (*init_sm_dsm_reg_info)(void); 179 void (*init_sm_dsm_reg_info)(void);
180 int (*wait_empty)(struct gk20a *g, unsigned long end_jiffies, 180 int (*wait_empty)(struct gk20a *g, unsigned long end_jiffies,
181 u32 expect_delay); 181 u32 expect_delay);
182 void (*init_cyclestats)(struct gk20a *g);
182 } gr; 183 } gr;
183 const char *name; 184 const char *name;
184 struct { 185 struct {
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index c36f2551..512a7d6b 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -7333,6 +7333,16 @@ int gr_gk20a_debugfs_init(struct gk20a *g)
7333 return 0; 7333 return 0;
7334} 7334}
7335 7335
7336static void gr_gk20a_init_cyclestats(struct gk20a *g)
7337{
7338#if defined(CONFIG_GK20A_CYCLE_STATS)
7339 g->gpu_characteristics.flags |=
7340 NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS;
7341#else
7342 (void)g;
7343#endif
7344}
7345
7336void gk20a_init_gr_ops(struct gpu_ops *gops) 7346void gk20a_init_gr_ops(struct gpu_ops *gops)
7337{ 7347{
7338 gops->gr.access_smpc_reg = gr_gk20a_access_smpc_reg; 7348 gops->gr.access_smpc_reg = gr_gk20a_access_smpc_reg;
@@ -7383,4 +7393,5 @@ void gk20a_init_gr_ops(struct gpu_ops *gops)
7383 gops->gr.get_rop_l2_en_mask = gr_gk20a_rop_l2_en_mask; 7393 gops->gr.get_rop_l2_en_mask = gr_gk20a_rop_l2_en_mask;
7384 gops->gr.init_sm_dsm_reg_info = gr_gk20a_init_sm_dsm_reg_info; 7394 gops->gr.init_sm_dsm_reg_info = gr_gk20a_init_sm_dsm_reg_info;
7385 gops->gr.wait_empty = gr_gk20a_wait_idle; 7395 gops->gr.wait_empty = gr_gk20a_wait_idle;
7396 gops->gr.init_cyclestats = gr_gk20a_init_cyclestats;
7386} 7397}
diff --git a/drivers/gpu/nvgpu/gm20b/gr_gm20b.c b/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
index 6c7831d5..17b4b8ea 100644
--- a/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/gr_gm20b.c
@@ -1040,6 +1040,18 @@ static u32 gr_gm20b_get_max_fbps_count(struct gk20a *g)
1040 return max_fbps_count; 1040 return max_fbps_count;
1041} 1041}
1042 1042
1043static void gr_gm20b_init_cyclestats(struct gk20a *g)
1044{
1045#if defined(CONFIG_GK20A_CYCLE_STATS)
1046 g->gpu_characteristics.flags |=
1047 NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS;
1048 g->gpu_characteristics.flags |=
1049 NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT;
1050#else
1051 (void)g;
1052#endif
1053}
1054
1043void gm20b_init_gr(struct gpu_ops *gops) 1055void gm20b_init_gr(struct gpu_ops *gops)
1044{ 1056{
1045 gops->gr.init_gpc_mmu = gr_gm20b_init_gpc_mmu; 1057 gops->gr.init_gpc_mmu = gr_gm20b_init_gpc_mmu;
@@ -1094,4 +1106,5 @@ void gm20b_init_gr(struct gpu_ops *gops)
1094 gops->gr.get_max_fbps_count = gr_gm20b_get_max_fbps_count; 1106 gops->gr.get_max_fbps_count = gr_gm20b_get_max_fbps_count;
1095 gops->gr.init_sm_dsm_reg_info = gr_gm20b_init_sm_dsm_reg_info; 1107 gops->gr.init_sm_dsm_reg_info = gr_gm20b_init_sm_dsm_reg_info;
1096 gops->gr.wait_empty = gr_gk20a_wait_idle; 1108 gops->gr.wait_empty = gr_gk20a_wait_idle;
1109 gops->gr.init_cyclestats = gr_gm20b_init_cyclestats;
1097} 1110}