From 75d7d6826dea130d5eb5ac86f1ca54bd9b05fbe1 Mon Sep 17 00:00:00 2001 From: Deepak Goyal Date: Sun, 2 Jul 2017 08:19:29 +0530 Subject: gpu: nvgpu: pmu: check before initializing perfmon We should check if perfmon is enabled before sending perfmon init command. This is needed for debug purposes. Change-Id: Ia95a590a76074c469b5d87a5820cd5b2e50d13be Signed-off-by: Deepak Goyal Reviewed-on: https://git-master/r/1510036 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/debug_pmu.c | 7 +++++-- drivers/gpu/nvgpu/common/linux/driver_common.c | 1 + drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c | 1 + drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c | 1 + drivers/gpu/nvgpu/common/pmu/pmu_ipc.c | 4 +++- drivers/gpu/nvgpu/common/pmu/pmu_perfmon.c | 10 ++++++++++ drivers/gpu/nvgpu/gk20a/platform_gk20a.h | 3 +++ drivers/gpu/nvgpu/include/nvgpu/enabled.h | 6 ++++++ 8 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/debug_pmu.c b/drivers/gpu/nvgpu/common/linux/debug_pmu.c index 0d364fe7..8c3607b5 100644 --- a/drivers/gpu/nvgpu/common/linux/debug_pmu.c +++ b/drivers/gpu/nvgpu/common/linux/debug_pmu.c @@ -12,6 +12,7 @@ * */ +#include #include "debug_pmu.h" #include "gk20a/platform_gk20a.h" @@ -348,10 +349,12 @@ static ssize_t perfmon_events_enable_write(struct file *file, if (err) return err; - if (val && !g->pmu.perfmon_sampling_enabled) { + if (val && !g->pmu.perfmon_sampling_enabled && + nvgpu_is_enabled(g, NVGPU_PMU_PERFMON)) { g->pmu.perfmon_sampling_enabled = true; nvgpu_pmu_perfmon_start_sampling(&(g->pmu)); - } else if (!val && g->pmu.perfmon_sampling_enabled) { + } else if (!val && g->pmu.perfmon_sampling_enabled && + nvgpu_is_enabled(g, NVGPU_PMU_PERFMON)) { g->pmu.perfmon_sampling_enabled = false; nvgpu_pmu_perfmon_stop_sampling(&(g->pmu)); } diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c index b12917d6..4e2cb2b4 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c @@ -124,6 +124,7 @@ static void nvgpu_init_pm_vars(struct gk20a *g) g->support_pmu = support_gk20a_pmu(dev_from_gk20a(g)); g->can_railgate = platform->can_railgate_init; g->railgate_delay = platform->railgate_delay_init; + __nvgpu_set_enabled(g, NVGPU_PMU_PERFMON, platform->enable_perfmon); /* set default values to aelpg parameters */ g->pmu.aelpg_param[0] = APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US; diff --git a/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c index 2c1709ea..000e9eee 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/common/linux/platform_gk20a_tegra.c @@ -920,6 +920,7 @@ struct gk20a_platform gm20b_tegra_platform = { .enable_elcg = true, .enable_elpg = true, .enable_aelpg = true, + .enable_perfmon = true, .ptimer_src_freq = 19200000, .force_reset_in_do_idle = false, diff --git a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c index 61b8053f..83d3634c 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c @@ -377,6 +377,7 @@ struct gk20a_platform gp10b_tegra_platform = { .enable_slcg = true, .enable_elcg = true, .enable_aelpg = true, + .enable_perfmon = true, /* ptimer src frequency in hz*/ .ptimer_src_freq = 31250000, diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c b/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c index 352e525f..0dbc2df3 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c @@ -11,6 +11,7 @@ * more details. */ +#include #include #include #include @@ -844,7 +845,8 @@ int nvgpu_pmu_process_message(struct nvgpu_pmu *pmu) nvgpu_pmu_process_init_msg(pmu, &msg); if (g->ops.pmu.init_wpr_region != NULL) g->ops.pmu.init_wpr_region(g); - nvgpu_pmu_init_perfmon(pmu); + if (nvgpu_is_enabled(g, NVGPU_PMU_PERFMON)) + nvgpu_pmu_init_perfmon(pmu); return 0; } diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_perfmon.c b/drivers/gpu/nvgpu/common/pmu/pmu_perfmon.c index f87bd175..34678e34 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_perfmon.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_perfmon.c @@ -11,6 +11,7 @@ * more details. */ +#include #include #include #include @@ -60,6 +61,9 @@ int nvgpu_pmu_init_perfmon(struct nvgpu_pmu *pmu) struct pmu_payload payload; u32 seq; + if (!nvgpu_is_enabled(g, NVGPU_PMU_PERFMON)) + return 0; + nvgpu_log_fn(g, " "); pmu->perfmon_ready = 0; @@ -126,6 +130,9 @@ int nvgpu_pmu_perfmon_start_sampling(struct nvgpu_pmu *pmu) struct pmu_payload payload; u32 seq; + if (!nvgpu_is_enabled(g, NVGPU_PMU_PERFMON)) + return 0; + /* PERFMON Start */ memset(&cmd, 0, sizeof(struct pmu_cmd)); cmd.hdr.unit_id = get_perfmon_id(pmu); @@ -172,6 +179,9 @@ int nvgpu_pmu_perfmon_stop_sampling(struct nvgpu_pmu *pmu) struct pmu_cmd cmd; u32 seq; + if (!nvgpu_is_enabled(g, NVGPU_PMU_PERFMON)) + return 0; + /* PERFMON Stop */ memset(&cmd, 0, sizeof(struct pmu_cmd)); cmd.hdr.unit_id = get_perfmon_id(pmu); diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h index 04ac2505..81402ad0 100644 --- a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h @@ -93,6 +93,9 @@ struct gk20a_platform { /* Adaptative ELPG: true = enable flase = disable */ bool enable_aelpg; + /* PMU Perfmon: true = enable false = disable */ + bool enable_perfmon; + /* Memory System Clock Gating: true = enable flase = disable*/ bool enable_mscg; diff --git a/drivers/gpu/nvgpu/include/nvgpu/enabled.h b/drivers/gpu/nvgpu/include/nvgpu/enabled.h index 78dea193..3bfd4899 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/enabled.h +++ b/drivers/gpu/nvgpu/include/nvgpu/enabled.h @@ -37,6 +37,12 @@ struct gk20a; /* unified or split memory with separate vidmem? */ #define NVGPU_MM_UNIFIED_MEMORY 18 +/* + * PMU flags. + */ +/* perfmon enabled or disabled for PMU */ +#define NVGPU_PMU_PERFMON 48 + /* * Must be greater than the largest bit offset in the above list. */ -- cgit v1.2.2