diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/pmu_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/pmu_gk20a.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c b/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c index f7af9035..c4872ab8 100644 --- a/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c | |||
@@ -3721,13 +3721,12 @@ int gk20a_pmu_load_update(struct gk20a *g) | |||
3721 | void gk20a_pmu_get_load_counters(struct gk20a *g, u32 *busy_cycles, | 3721 | void gk20a_pmu_get_load_counters(struct gk20a *g, u32 *busy_cycles, |
3722 | u32 *total_cycles) | 3722 | u32 *total_cycles) |
3723 | { | 3723 | { |
3724 | if (!g->power_on) { | 3724 | if (!g->power_on || gk20a_busy(g->dev)) { |
3725 | *busy_cycles = 0; | 3725 | *busy_cycles = 0; |
3726 | *total_cycles = 0; | 3726 | *total_cycles = 0; |
3727 | return; | 3727 | return; |
3728 | } | 3728 | } |
3729 | 3729 | ||
3730 | gk20a_busy(g->dev); | ||
3731 | *busy_cycles = pwr_pmu_idle_count_value_v( | 3730 | *busy_cycles = pwr_pmu_idle_count_value_v( |
3732 | gk20a_readl(g, pwr_pmu_idle_count_r(1))); | 3731 | gk20a_readl(g, pwr_pmu_idle_count_r(1))); |
3733 | rmb(); | 3732 | rmb(); |
@@ -3740,10 +3739,9 @@ void gk20a_pmu_reset_load_counters(struct gk20a *g) | |||
3740 | { | 3739 | { |
3741 | u32 reg_val = pwr_pmu_idle_count_reset_f(1); | 3740 | u32 reg_val = pwr_pmu_idle_count_reset_f(1); |
3742 | 3741 | ||
3743 | if (!g->power_on) | 3742 | if (!g->power_on || gk20a_busy(g->dev)) |
3744 | return; | 3743 | return; |
3745 | 3744 | ||
3746 | gk20a_busy(g->dev); | ||
3747 | gk20a_writel(g, pwr_pmu_idle_count_r(2), reg_val); | 3745 | gk20a_writel(g, pwr_pmu_idle_count_r(2), reg_val); |
3748 | wmb(); | 3746 | wmb(); |
3749 | gk20a_writel(g, pwr_pmu_idle_count_r(1), reg_val); | 3747 | gk20a_writel(g, pwr_pmu_idle_count_r(1), reg_val); |
@@ -3929,10 +3927,14 @@ static int elpg_residency_show(struct seq_file *s, void *data) | |||
3929 | u32 ungating_time = 0; | 3927 | u32 ungating_time = 0; |
3930 | u32 gating_cnt; | 3928 | u32 gating_cnt; |
3931 | u64 total_ingating, total_ungating, residency, divisor, dividend; | 3929 | u64 total_ingating, total_ungating, residency, divisor, dividend; |
3930 | int err; | ||
3932 | 3931 | ||
3933 | /* Don't unnecessarily power on the device */ | 3932 | /* Don't unnecessarily power on the device */ |
3934 | if (g->power_on) { | 3933 | if (g->power_on) { |
3935 | gk20a_busy(g->dev); | 3934 | err = gk20a_busy(g->dev); |
3935 | if (err) | ||
3936 | return err; | ||
3937 | |||
3936 | gk20a_pmu_get_elpg_residency_gating(g, &ingating_time, | 3938 | gk20a_pmu_get_elpg_residency_gating(g, &ingating_time, |
3937 | &ungating_time, &gating_cnt); | 3939 | &ungating_time, &gating_cnt); |
3938 | gk20a_idle(g->dev); | 3940 | gk20a_idle(g->dev); |
@@ -3974,9 +3976,13 @@ static int elpg_transitions_show(struct seq_file *s, void *data) | |||
3974 | struct gk20a *g = s->private; | 3976 | struct gk20a *g = s->private; |
3975 | u32 ingating_time, ungating_time, total_gating_cnt; | 3977 | u32 ingating_time, ungating_time, total_gating_cnt; |
3976 | u32 gating_cnt = 0; | 3978 | u32 gating_cnt = 0; |
3979 | int err; | ||
3977 | 3980 | ||
3978 | if (g->power_on) { | 3981 | if (g->power_on) { |
3979 | gk20a_busy(g->dev); | 3982 | err = gk20a_busy(g->dev); |
3983 | if (err) | ||
3984 | return err; | ||
3985 | |||
3980 | gk20a_pmu_get_elpg_residency_gating(g, &ingating_time, | 3986 | gk20a_pmu_get_elpg_residency_gating(g, &ingating_time, |
3981 | &ungating_time, &gating_cnt); | 3987 | &ungating_time, &gating_cnt); |
3982 | gk20a_idle(g->dev); | 3988 | gk20a_idle(g->dev); |
@@ -4066,6 +4072,7 @@ static ssize_t perfmon_events_enable_write(struct file *file, | |||
4066 | unsigned long val = 0; | 4072 | unsigned long val = 0; |
4067 | char buf[40]; | 4073 | char buf[40]; |
4068 | int buf_size; | 4074 | int buf_size; |
4075 | int err; | ||
4069 | 4076 | ||
4070 | memset(buf, 0, sizeof(buf)); | 4077 | memset(buf, 0, sizeof(buf)); |
4071 | buf_size = min(count, (sizeof(buf)-1)); | 4078 | buf_size = min(count, (sizeof(buf)-1)); |
@@ -4078,7 +4085,10 @@ static ssize_t perfmon_events_enable_write(struct file *file, | |||
4078 | 4085 | ||
4079 | /* Don't turn on gk20a unnecessarily */ | 4086 | /* Don't turn on gk20a unnecessarily */ |
4080 | if (g->power_on) { | 4087 | if (g->power_on) { |
4081 | gk20a_busy(g->dev); | 4088 | err = gk20a_busy(g->dev); |
4089 | if (err) | ||
4090 | return err; | ||
4091 | |||
4082 | if (val && !g->pmu.perfmon_sampling_enabled) { | 4092 | if (val && !g->pmu.perfmon_sampling_enabled) { |
4083 | g->pmu.perfmon_sampling_enabled = true; | 4093 | g->pmu.perfmon_sampling_enabled = true; |
4084 | pmu_perfmon_start_sampling(&(g->pmu)); | 4094 | pmu_perfmon_start_sampling(&(g->pmu)); |