From patchwork Mon Oct 10 21:38:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaro Koskinen X-Patchwork-Id: 9369979 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 918EE60487 for ; Mon, 10 Oct 2016 21:38:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86FAD28CF0 for ; Mon, 10 Oct 2016 21:38:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79DBB2905B; Mon, 10 Oct 2016 21:38:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6617128CF0 for ; Mon, 10 Oct 2016 21:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751979AbcJJViU (ORCPT ); Mon, 10 Oct 2016 17:38:20 -0400 Received: from emh06.mail.saunalahti.fi ([62.142.5.116]:36536 "EHLO emh06.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751708AbcJJViU (ORCPT ); Mon, 10 Oct 2016 17:38:20 -0400 Received: from localhost.localdomain (85-76-139-51-nat.elisa-mobile.fi [85.76.139.51]) by emh06.mail.saunalahti.fi (Postfix) with ESMTP id C103269B21; Tue, 11 Oct 2016 00:38:16 +0300 (EEST) From: Aaro Koskinen To: Viresh Kumar , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Aaro Koskinen Subject: [PATCH] cpufreq: skip invalid entries when searching the frequency Date: Tue, 11 Oct 2016 00:38:13 +0300 Message-Id: <20161010213813.22087-1-aaro.koskinen@iki.fi> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20161007225925.GI15204@raspberrypi.musicnaut.iki.fi> References: <20161007225925.GI15204@raspberrypi.musicnaut.iki.fi> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Skip invalid entries when searching the frequency. This fixes cpufreq at least on loongson2 MIPS board. Fixes: da0c6dc00c69 ("cpufreq: Handle sorted frequency tables more efficiently") Signed-off-by: Aaro Koskinen --- include/linux/cpufreq.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 631ba33b..0c1b188 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -645,6 +645,9 @@ static inline int cpufreq_table_find_index_al(struct cpufreq_policy *policy, for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { freq = table[i].frequency; + if (freq == CPUFREQ_ENTRY_INVALID) + continue; + if (freq >= target_freq) return i; @@ -665,6 +668,9 @@ static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy, for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { freq = table[i].frequency; + if (freq == CPUFREQ_ENTRY_INVALID) + continue; + if (freq == target_freq) return i; @@ -706,6 +712,9 @@ static inline int cpufreq_table_find_index_ah(struct cpufreq_policy *policy, for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { freq = table[i].frequency; + if (freq == CPUFREQ_ENTRY_INVALID) + continue; + if (freq == target_freq) return i; @@ -735,6 +744,9 @@ static inline int cpufreq_table_find_index_dh(struct cpufreq_policy *policy, for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { freq = table[i].frequency; + if (freq == CPUFREQ_ENTRY_INVALID) + continue; + if (freq <= target_freq) return i; @@ -767,6 +779,9 @@ static inline int cpufreq_table_find_index_ac(struct cpufreq_policy *policy, for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { freq = table[i].frequency; + if (freq == CPUFREQ_ENTRY_INVALID) + continue; + if (freq == target_freq) return i; @@ -800,6 +815,9 @@ static inline int cpufreq_table_find_index_dc(struct cpufreq_policy *policy, for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { freq = table[i].frequency; + if (freq == CPUFREQ_ENTRY_INVALID) + continue; + if (freq == target_freq) return i;