* [PATCH] [CPUFREQ] EXYNOS: bugfix on retrieving old_index from freqs.old
@ 2012-04-04 10:23 ` MyungJoo Ham
0 siblings, 0 replies; 3+ messages in thread
From: MyungJoo Ham @ 2012-04-04 10:23 UTC (permalink / raw)
To: cpufreq
Cc: Dave Jones, Jaecheol Lee, Tushar Behera, kyungmin.park,
cw00.choi, myungjoo.ham, linux-kernel
The policy might have been changed since last call of target().
Thus, using cpufreq_frequency_table_target(), which depends on
policy to find the correspoding index from a frequency, may return
inconsistent index for freqs.old. Thus, old_index should be
calculated not based on the current policy.
We have been observing such issue when scaling_min/max_freq were
updated and sometimes caused system lockups due to incorrectly
configured voltages.
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
---
drivers/cpufreq/exynos-cpufreq.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index b243a7e..1577522 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -62,8 +62,17 @@ static int exynos_target(struct cpufreq_policy *policy,
goto out;
}
- if (cpufreq_frequency_table_target(policy, freq_table,
- freqs.old, relation, &old_index)) {
+ /*
+ * The policy may have been changed so that we cannot get proper
+ * old_index with cpufreq_frequency_table_target(). Thus, ignore
+ * policy and get the index from the raw frequency table.
+ */
+ for (old_index = 0;
+ freq_table[old_index].frequency != CPUFREQ_TABLE_END;
+ old_index++)
+ if (freq_table[old_index].frequency == freqs.old)
+ break;
+ if (freq_table[old_index].frequency == CPUFREQ_TABLE_END) {
ret = -EINVAL;
goto out;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] EXYNOS: bugfix on retrieving old_index from freqs.old
@ 2012-04-04 10:23 ` MyungJoo Ham
0 siblings, 0 replies; 3+ messages in thread
From: MyungJoo Ham @ 2012-04-04 10:23 UTC (permalink / raw)
To: cpufreq
Cc: Dave Jones, Jaecheol Lee, Tushar Behera, kyungmin.park,
cw00.choi, myungjoo.ham, linux-kernel
The policy might have been changed since last call of target().
Thus, using cpufreq_frequency_table_target(), which depends on
policy to find the correspoding index from a frequency, may return
inconsistent index for freqs.old. Thus, old_index should be
calculated not based on the current policy.
We have been observing such issue when scaling_min/max_freq were
updated and sometimes caused system lockups due to incorrectly
configured voltages.
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
---
drivers/cpufreq/exynos-cpufreq.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index b243a7e..1577522 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -62,8 +62,17 @@ static int exynos_target(struct cpufreq_policy *policy,
goto out;
}
- if (cpufreq_frequency_table_target(policy, freq_table,
- freqs.old, relation, &old_index)) {
+ /*
+ * The policy may have been changed so that we cannot get proper
+ * old_index with cpufreq_frequency_table_target(). Thus, ignore
+ * policy and get the index from the raw frequency table.
+ */
+ for (old_index = 0;
+ freq_table[old_index].frequency != CPUFREQ_TABLE_END;
+ old_index++)
+ if (freq_table[old_index].frequency == freqs.old)
+ break;
+ if (freq_table[old_index].frequency == CPUFREQ_TABLE_END) {
ret = -EINVAL;
goto out;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [CPUFREQ] EXYNOS: bugfix on retrieving old_index from freqs.old
2012-04-04 10:23 ` [PATCH] " MyungJoo Ham
(?)
@ 2012-04-10 10:05 ` Inderpal Singh
-1 siblings, 0 replies; 3+ messages in thread
From: Inderpal Singh @ 2012-04-10 10:05 UTC (permalink / raw)
To: MyungJoo Ham
Cc: cpufreq, Dave Jones, Jaecheol Lee, Tushar Behera, kyungmin.park,
cw00.choi, myungjoo.ham, linux-kernel
Hi MyungJoo,
On 4 April 2012 15:53, MyungJoo Ham <myungjoo.ham@samsung.com> wrote:
> The policy might have been changed since last call of target().
> Thus, using cpufreq_frequency_table_target(), which depends on
> policy to find the correspoding index from a frequency, may return
> inconsistent index for freqs.old. Thus, old_index should be
> calculated not based on the current policy.
>
> We have been observing such issue when scaling_min/max_freq were
> updated and sometimes caused system lockups due to incorrectly
> configured voltages.
>
> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> ---
> drivers/cpufreq/exynos-cpufreq.c | 13 +++++++++++--
> 1 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
> index b243a7e..1577522 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -62,8 +62,17 @@ static int exynos_target(struct cpufreq_policy *policy,
> goto out;
> }
>
> - if (cpufreq_frequency_table_target(policy, freq_table,
> - freqs.old, relation, &old_index)) {
> + /*
> + * The policy may have been changed so that we cannot get proper
> + * old_index with cpufreq_frequency_table_target(). Thus, ignore
> + * policy and get the index from the raw frequency table.
> + */
> + for (old_index = 0;
> + freq_table[old_index].frequency != CPUFREQ_TABLE_END;
> + old_index++)
> + if (freq_table[old_index].frequency == freqs.old)
> + break;
> + if (freq_table[old_index].frequency == CPUFREQ_TABLE_END) {
> ret = -EINVAL;
> goto out;
> }
I also had the same issue and same fix while testing powertop 1.98 as
it changes the scaling_min/max_freq.
The only concern I have is when this code gets called for the very
first time, the freqs.old will be the freq set by bootloader. Now if
bootloader sets a freq which is not in the freq_table (not sure if its
practical but theoretically its possible ), this code will error out.
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe cpufreq" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Inder
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-10 10:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-04 10:23 [PATCH] [CPUFREQ] EXYNOS: bugfix on retrieving old_index from freqs.old MyungJoo Ham
2012-04-04 10:23 ` [PATCH] " MyungJoo Ham
2012-04-10 10:05 ` [PATCH] [CPUFREQ] " Inderpal Singh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.