From patchwork Wed Oct 23 11:08:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 177266 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp558323ill; Wed, 23 Oct 2019 04:08:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTq01yFvUrCRwlSXNStVEVIXcRUsaTZAQkjcsd5DAJKKUSiMZB5fvTZfWZJqe05Y9727bQ X-Received: by 2002:a17:906:5292:: with SMTP id c18mr31996786ejm.129.1571828924383; Wed, 23 Oct 2019 04:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571828924; cv=none; d=google.com; s=arc-20160816; b=YJqs64USUTZ9Giu3DgSb9AlulhKn9zcvpgEwzUyDymoQI4q1gm3/ZhT8Ryt7OLB4/E ERi1b4zlFmsq2Pv8SYG6PccV8ebw9CklRhlVjAyispeBMZjm2k2Zf4MBye7ADym6z7zH gahx7NxluvrV1Zm3/bwel80oxWzKdC2SkafaB9fga62rFu+D+mQm7ztu6Wl1R4L9eFde EnC7LRc4m+Ml35fdxrEc9Ct63rShVz4DvD9d/Jb3jvzsUU0QohJoqWkD3pL4s/c84nF+ 2dPof6XBe4b/u4Jb0uVFY+B9izk87CqhRYXA36/fglj1Yc3OPzhAIvTVRCRToKqnLaYM CBfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=IcDW6Bj/I4c35x6YwDZ7m82R2q5/YMRRJ4iAXWQT2Eo=; b=kH56u4ytMtBIg5v1cFW9ZXc7gAbBFTGcMZu6KC7/hMbANf5ezBvryQoWyb9XtEzc2C dzO35wAJ2Xg+bjhUsJ5qXY82WRkZv8t/eya2x/PROgzOCV9GvZfPZYYOl1tOv62ullmV AQe0o963vCMGXnhdmQEsCGFSTDHhyD5kPwFi51G/1gGUJAfOK6mvCwuffAC7hQNqoi0C iUNp4ajwSWg2gLQm6/fqa3kDfYvjAEJjBfwwOZby0O1DjP0DC/ZvtZrTfD6AmPZygnjc ar9Cy6r5iPsO8YljZIWxfHmBWE51uv2Azqmd8q2t6+51JXylUf0Z4ng6wvHY48QAbstd qxKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s58si8406448edm.45.2019.10.23.04.08.44; Wed, 23 Oct 2019 04:08:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391107AbfJWLIn (ORCPT + 10 others); Wed, 23 Oct 2019 07:08:43 -0400 Received: from [217.140.110.172] ([217.140.110.172]:48428 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S2391006AbfJWLIn (ORCPT ); Wed, 23 Oct 2019 07:08:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5FA35497; Wed, 23 Oct 2019 04:08:22 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7E32C3F718; Wed, 23 Oct 2019 04:08:21 -0700 (PDT) From: Sudeep Holla To: Viresh Kumar , "Rafael J . Wysocki" Cc: Sudeep Holla , 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 Message-Id: <20191023110811.15086-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023110811.15086-1-sudeep.holla@arm.com> References: <20191023110811.15086-1-sudeep.holla@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 Cc: "Rafael J. Wysocki" Signed-off-by: Sudeep Holla --- drivers/cpufreq/vexpress-spc-cpufreq.c | 35 ++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) -- 2.17.1 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;