Received: by 10.213.65.68 with SMTP id h4csp150842imn; Thu, 5 Apr 2018 20:06:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx49a4qahXmr9uvSvWxL7OmHDwIKMo9Wsmbfcgk4mo8aqFD/vsCSpXoPkcaqHpsPOJqmnXBr+ X-Received: by 10.99.147.25 with SMTP id b25mr16630745pge.309.1522984003284; Thu, 05 Apr 2018 20:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522984003; cv=none; d=google.com; s=arc-20160816; b=ogBt5BpGTnkxjnaCmZ1Qy/NJAObyBtyMdTA5pPnWMp8FGT9wtYtBt2vE8VQ7Lbi5B3 pNDBz1SwF+4uasGbNUhTk0tza9FcFC7UCVE9MvrfVmcGomBYuUmzHBkr2k0zCPqbD4ug OYugNhb0OvWL8KLZQAr2imESD03Fh4vCp3iwFWhHA9I29NVgH362viOow6PmNXBKe7A/ C6nrgxNxDXRW6Ace0R8Db1WG2Vj1RFl8lYM2/rzfM9UUt/pBooqGeQNQZf1iQW0qoGTF N+2m2KWcfjCf6OTynVqmfAF0mzXlqm71uvgh/yWMn0SLnxILiNRU1SR6UwvfQKSIDDxn DEow== 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=SsxS6jPgbjRM8TPEq3lz9+kVd0JMWfSs+3GY+7VAaIE=; b=PitzOlUao9NW4x5byu9XUP2FcH4+vZikTjSsvHYn1lVzsn1weKz0BZbu/fAxhuUIdR ceFN6Zgw+mLSbDcyfaVUTXW66ExO0/YodJhQVFGlPTvAkEkYnpF7dmMFwE4ibrWiPaFT 5DRdx8w8GJamctAbeVuto08fkGZ37qWVC5WPHuo11oyMC+hOss98mhmLXrGrVCBfTzNT 25rheveXnKapZWFrNpK9noIxzrFodUPfagJXuzsxRubkmEJLG+NR1wG5lHYnP5WEzx2j lhN/+/VXs7ofXI3jmGc1HVGcsKHZmXnUVxHlOFGxXZE31RRRArg9IrTRmsIjWbScWzIF ypjA== 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 g9-v6si7250185plk.60.2018.04.05.20.06.28; Thu, 05 Apr 2018 20:06:43 -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 S1751445AbeDFDFZ (ORCPT + 99 others); Thu, 5 Apr 2018 23:05:25 -0400 Received: from mx01.hxt-semitech.com.96.203.223.in-addr.arpa ([223.203.96.7]:56190 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751315AbeDFDFY (ORCPT ); Thu, 5 Apr 2018 23:05:24 -0400 X-ASG-Debug-ID: 1522982733-093b7e10b3321c0001-xx1T2L Received: from HXTBJIDCEMVIW01.hxtcorp.net (localhost [10.128.0.14]) by barracuda.hxt-semitech.com with ESMTP id IlVaPnu3yT6Q6dmF (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 06 Apr 2018 10:45:33 +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; Fri, 6 Apr 2018 10:45:35 +0800 From: Shunyong Yang To: CC: , , , Shunyong Yang , Joey Zheng Subject: [PATCH v3] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities Date: Fri, 6 Apr 2018 10:43:49 +0800 X-ASG-Orig-Subj: [PATCH v3] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities Message-ID: <1522982629-7557-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: HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) To HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) X-Barracuda-Connect: localhost[10.128.0.14] X-Barracuda-Start-Time: 1522982733 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.7998 1.0000 2.2193 X-Barracuda-Spam-Score: 2.22 X-Barracuda-Spam-Status: No, SCORE=2.22 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.49627 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 Acked-by: Viresh Kumar Signed-off-by: Shunyong Yang --- Changes in v3: -Remove unnecessary wrap per Kumar's comments. 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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 8300a9fcb80c..8b432d6e846d 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -167,9 +167,19 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) NSEC_PER_USEC; 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