Received: by 10.213.65.68 with SMTP id h4csp508354imn; Wed, 4 Apr 2018 02:19:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Rj8BrfUCRzQh9jLTGNQmNFpBRB/lD5/IEtaP6OGw3GCdzKWmGQTnALegSYmXhm2o36tit X-Received: by 10.98.171.7 with SMTP id p7mr13312918pff.215.1522833541291; Wed, 04 Apr 2018 02:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522833541; cv=none; d=google.com; s=arc-20160816; b=yNjY4zIr7RgpmARzpWt6b3vInBAVPve0z+TGH0ViLpOJV0KUE4nCLuIkiBNUH72XdH 9x/hFlrDRAklwoiHiZS5E20gxg5oo+pUwcgGkbQLpfBqG2AG2Mb9OSoPEUppsfmd6pih AAV3mjANUs7xnvQtGF9Jj0ShZTgzvCYGbokej7hlwHWu/demLZZB+th06tMj80rR5++h jE5PLNwDBqEtGFKyuo+NzdqhLl9OLaAZn9c2ifEaCpFjrOTpiz5+5ZN0HNU5oHXeYkBS jH7WzV3+AmZpcKeBXtZveAOsRrpc3peK0GZ0458z/TfvVDqOvgE3HGUHc+OyAUHoVC6e 2+gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=J/B0rI2zE6nIybJxSFzuADTZAdz1E0nF1NvQl4PLuKA=; b=YElKyYUWUUGV214lsLKHTVkHsJ5Yc2Ef06+ukqtQ7O9aZC9Kyw8HB4CJyR83E9TGKX KFXPXtsWgERzkNlcG0X7B7zFxjdlVAe8TMHUQ0gUodTuhTrhbn1TrZZvY45ovbOE5wXe 5HjIjcz9EZ7T46ds7nZvD9ME39Un0pU/1CgIFLUraCSI/luGPPwcIuWhoZ88shCn6AEV 0pgLVi7mHkNoufi7Ppej6CQGyEbljitQPI8TIUkeP1aLf13kYK2DfJ8XTj9cwj61LxWh ZRlOLPSMc12yIT+wcJuLOZ2azYmlaFqXt06AwRNZ/48PTf2mKp7Ond89nlHfLERQVGBZ SP3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 s4si1294661pgp.607.2018.04.04.02.18.46; Wed, 04 Apr 2018 02:19:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751435AbeDDJRi (ORCPT + 99 others); Wed, 4 Apr 2018 05:17:38 -0400 Received: from mx01.hxt-semitech.com.96.203.223.in-addr.arpa ([223.203.96.7]:51239 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751155AbeDDJRg (ORCPT ); Wed, 4 Apr 2018 05:17:36 -0400 X-ASG-Debug-ID: 1522833443-093b7e10b323ed0001-xx1T2L Received: from HXTBJIDCEMVIW01.hxtcorp.net (localhost [10.128.0.14]) by barracuda.hxt-semitech.com with ESMTP id iGRoh8nkqIKnDf1w (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 04 Apr 2018 17:17:23 +0800 (CST) X-Barracuda-Envelope-From: shunyong.yang@hxt-semitech.com Received: from y.localdomain (10.5.21.109) by HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) with Microsoft SMTP Server (TLS) id 15.0.847.32; Wed, 4 Apr 2018 17:17:25 +0800 From: Shunyong Yang To: CC: , , , Shunyong Yang , Joey Zheng Subject: [PATCH v2] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities Date: Wed, 4 Apr 2018 17:16:20 +0800 X-ASG-Orig-Subj: [PATCH v2] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities Message-ID: <1522833380-18438-1-git-send-email-shunyong.yang@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.5.21.109] X-ClientProxiedBy: HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) To HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) X-Barracuda-Connect: localhost[10.128.0.14] X-Barracuda-Start-Time: 1522833443 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.7723 1.0000 1.9682 X-Barracuda-Spam-Score: 1.97 X-Barracuda-Spam-Status: No, SCORE=1.97 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.49579 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When multiple cpus are related in one cpufreq policy, the first online cpu will be chosen by default to handle cpufreq operations. Let's take cpu0 and cpu1 as an example. When cpu0 is offline, policy->cpu will be shifted to cpu1. Cpu1's perf capabilities should be initialized. Otherwise, perf capabilities are 0s and speed change can not take effect. This patch copies perf capabilities of the first online cpu to other shared cpus when policy shared type is CPUFREQ_SHARED_TYPE_ANY. Cc: Joey Zheng Signed-off-by: Shunyong Yang --- Changes in v2: -Add unlikely in cpu comparison per Kumar's comments. -Fix coding style per Kumar's comments. Changes in v1: -Drop RFC tag, The original RFC link, https://patchwork.kernel.org/patch/10299055/. This patch solves same issue as RFC above. Patch name is changed as code is too much different with RFC above. -Remove extra init() per Viresh Kumar's comments and only handle CPPC CPUFREQ_SHARED_TYPE_ANY case. --- drivers/cpufreq/cppc_cpufreq.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 8f7b21a4d537..679e43b9c980 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -164,9 +164,20 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = cppc_get_transition_latency(cpu_num); policy->shared_type = cpu->shared_type; - if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) + if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { + int i; + cpumask_copy(policy->cpus, cpu->shared_cpu_map); - else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) { + + for_each_cpu(i, policy->cpus) { + if (unlikely(i == policy->cpu)) + continue; + + memcpy(&all_cpu_data[i]->perf_caps, + &cpu->perf_caps, + sizeof(cpu->perf_caps)); + } + } else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) { /* Support only SW_ANY for now. */ pr_debug("Unsupported CPU co-ord type\n"); return -EFAULT; -- 1.8.3.1