mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] cpufreq: vexpress-spc: find and skip duplicates when merging frequencies
Date: Wed, 23 Oct 2019 12:08:11 +0100	[thread overview]
Message-ID: <20191023110811.15086-2-sudeep.holla@arm.com> (raw)
In-Reply-To: <20191023110811.15086-1-sudeep.holla@arm.com>

Currently the cpufreq core aborts the validation and return error
immediately when it encounter duplicate frequency table entries.
This change was introduced long back since commit da0c6dc00c69
("cpufreq: Handle sorted frequency tables more efficiently").

However, this missed the testing with modified firmware for long time.
Inorder to make it work with default settings, we need to ensure the
merged table for bL switcher contains no duplicates. Find the duplicates
and skip them when merging the frequenct tables of A15 and A7 clusters.

Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/cpufreq/vexpress-spc-cpufreq.c | 35 ++++++++++++++++++++------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c b/drivers/cpufreq/vexpress-spc-cpufreq.c
index 093ef8d3a8d4..921dbd42b3bb 100644
--- a/drivers/cpufreq/vexpress-spc-cpufreq.c
+++ b/drivers/cpufreq/vexpress-spc-cpufreq.c
@@ -242,6 +242,19 @@ static inline u32 get_table_max(struct cpufreq_frequency_table *table)
 	return max_freq;
 }
 
+static bool search_frequency(struct cpufreq_frequency_table *table, int size,
+			     unsigned int freq)
+{
+	int count;
+
+	for (count = 0; count < size; count++) {
+		if (table[count].frequency == freq)
+			return true;
+	}
+
+	return false;
+}
+
 static int merge_cluster_tables(void)
 {
 	int i, j, k = 0, count = 1;
@@ -256,13 +269,21 @@ static int merge_cluster_tables(void)
 
 	freq_table[MAX_CLUSTERS] = table;
 
-	/* Add in reverse order to get freqs in increasing order */
-	for (i = MAX_CLUSTERS - 1; i >= 0; i--) {
-		for (j = 0; freq_table[i][j].frequency != CPUFREQ_TABLE_END;
-		     j++, k++) {
-			table[k].frequency =
-				VIRT_FREQ(i, freq_table[i][j].frequency);
-		}
+	/* Add A7_CLUSTER first to get freqs in increasing order */
+	for (j = 0; freq_table[A7_CLUSTER][j].frequency != CPUFREQ_TABLE_END;
+	     j++, k++) {
+		table[k].frequency =
+			VIRT_FREQ(A7_CLUSTER, freq_table[A7_CLUSTER][j].frequency);
+	}
+	count = k;
+
+	/* And then A15_CLUSTER checking for duplicates */
+	for (j = 0; freq_table[A15_CLUSTER][j].frequency != CPUFREQ_TABLE_END;
+	     j++) {
+		if (search_frequency(table, count,
+				     freq_table[A15_CLUSTER][j].frequency))
+			continue; /* skip duplicates */
+		table[k++].frequency = freq_table[A15_CLUSTER][j].frequency;
 	}
 
 	table[k].driver_data = k;
-- 
2.17.1


  reply	other threads:[~2019-10-23 11:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 11:08 [PATCH 1/2] cpufreq: vexpress-spc: use macros instead of hardcoded values for cluster ids Sudeep Holla
2019-10-23 11:08 ` Sudeep Holla [this message]
2019-10-23 11:25   ` [PATCH 2/2] cpufreq: vexpress-spc: find and skip duplicates when merging frequencies Viresh Kumar
2019-10-23 11:38     ` Sudeep Holla
2019-10-23 12:18   ` [PATCH v2 " Sudeep Holla
2019-10-24  3:11 ` [PATCH 1/2] cpufreq: vexpress-spc: use macros instead of hardcoded values for cluster ids Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191023110811.15086-2-sudeep.holla@arm.com \
    --to=sudeep.holla@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®