From patchwork Tue Jul 16 09:48:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 169041 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp613127ilk; Tue, 16 Jul 2019 02:49:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0mhkptXhaMqzK8qddjJ7l8sl8ZLbLJmi0Jrt/HbxsGnHj2PqQcjWSqHFZxFe5f1tdXBh0 X-Received: by 2002:a63:d04e:: with SMTP id s14mr30845960pgi.189.1563270570437; Tue, 16 Jul 2019 02:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563270570; cv=none; d=google.com; s=arc-20160816; b=JtW4SyoRe6TaEHnR2ZS/NyCYD5b0TqgSs4m6plMUWJPs5VV/zWqrfQh6ASrzQXZcLx iVke9tKQEyNbXwGXQ7SHNhf5VLsew1cDNvd6srwOjj1JfXJZscNXhHxMukeaA+P5XmS8 R6gZPMO+zYEbiQc7gdLWJT9QFMuCIzK80RyWK/mXxK8q7IgfXem47BxAd3K8tP0rBdXe KasQ9744bclq4Z6jFcgl9gtXsatAq6Sq9sGaCxN1LoZgI7qciM+pNsOW1/DgSwO3fvZh kwDZwTrnp7yID7X3EqFOr6I9cGnaVVmLzE1iD1uefUTs75Zeat9mtlLIYHVdtj/lqKg3 nnmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l2pQOR1f7DHhM0Qtl8EEm1QRrX6xqQ9Jku8fM4tSlRk=; b=K2SBaXEw8a25ayHosDGJIX3N56uLT3JlUDbwHN7Vf/gXx2UIhbSVYun1tHKZEqL5Uo 0fl8elsK7B+0MKl9eLtLi+D7Gw/D1+JBMUwK9UH/2OPO+XVEPGcIisC7CE77IFYGJ6gQ UzNz2VMJv0MFF784G90WhxI1Fnfnmeu+QZLMHtOAnLNgZEkTpAeQJuZVgph19qfwQDz+ WI603Da1BtOOv+y23BGJQp/lRQiuM3UN+W//IILXNknkxuXBltY/Qy8Oq/SK7cY4E1gR +/3q2Nv2yoEDzJuDGnU/cDF6ciE5iJJY0D2mdEzordPO7blw8a/AubMho7/UHrkY7yUl T8pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eWuR4BWg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l97si18449045pje.6.2019.07.16.02.49.30; Tue, 16 Jul 2019 02:49:30 -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; dkim=pass header.i=@linaro.org header.s=google header.b=eWuR4BWg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732472AbfGPJt3 (ORCPT + 11 others); Tue, 16 Jul 2019 05:49:29 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43863 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbfGPJt3 (ORCPT ); Tue, 16 Jul 2019 05:49:29 -0400 Received: by mail-pl1-f195.google.com with SMTP id 4so2875031pld.10 for ; Tue, 16 Jul 2019 02:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l2pQOR1f7DHhM0Qtl8EEm1QRrX6xqQ9Jku8fM4tSlRk=; b=eWuR4BWgpheOmCtw4+kojvX5WouC4KSz5jV/JpYetm1IJwE8WFQ0Y3E7aQ/xgr+pyT Qj02V6mPD2oTaWBvK8eWGD/yjZqYozTdGyVRQaFef2A6zxdtGGVUieak0WTn4XKcTws/ 6f6Mgl/IVQho2TwZEldORKlOxns5g6WQwYuUwo9cI2RftvqkqKMbVQBBg8bFA//OhLai LQ+3tKZZYAIX3il6vCxYOsCSUTcVstHUp/iTKLFNEriPeHSAQoPX4RK82tH6VSWXa3cN qbGbrlFFizujBFgMXiKDSfbc9w1EYJHrb1SIy2prXfP6XkHmOcMjih7XjOAemxAeILj9 4kfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l2pQOR1f7DHhM0Qtl8EEm1QRrX6xqQ9Jku8fM4tSlRk=; b=h5u9H628CZb4/X7TKxPJXymdC8EhF9+Al8wIS9XNzIHLxNgnjasaFd2PDwysaTU+Ay cVFFr50VDhhVcv4dA8UEk7R9pwyNdKD13IEINnDDYjBl3wuUIZXVdsqIddjOl313Zsnu 5iuh5snOP3PrbX7KA9hMSwNclA6z1AQjZ8+/B/PbpO+HP/7g2dyqnQix3zULPSCH48DX wz75lDjOH3P7lIDodxKrn3eWFKxhkx3yVRrtfVRZLI2MqIg5Leu9N52W/8+u7qpOXSsn TyzkZvxvdk7ug7R98+9NeiZjh4e1QiXGvTPQMBGjie+pqRyvkGRapcQ8TqwiGGPm0hFd snRQ== X-Gm-Message-State: APjAAAWKH5T06Q5/EdGMLkHRib8l+DTPU0rrVAtRFxhWS3Fr5SI49H8H 5k/xOT3w90R/41id3K8k0X7f2USl9TA= X-Received: by 2002:a17:902:b591:: with SMTP id a17mr32950833pls.96.1563270568321; Tue, 16 Jul 2019 02:49:28 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id f12sm18339014pgo.85.2019.07.16.02.49.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 02:49:27 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 01/10] cpufreq: Add policy create/remove notifiers Date: Tue, 16 Jul 2019 15:18:57 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This reverts commit f9f41e3ef99ac9d4e91b07634362e393fb929aad. We have a new use case for policy create/remove notifiers (for allocating/freeing QoS requests per policy), lets add them back. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 15 ++++++++++++++- include/linux/cpufreq.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 4d6043ee7834..8a7eff2a3771 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1268,7 +1268,17 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) DEV_PM_QOS_MAX_FREQUENCY); dev_pm_qos_remove_notifier(dev, &policy->nb_min, DEV_PM_QOS_MIN_FREQUENCY); - dev_pm_qos_remove_request(policy->max_freq_req); + + if (policy->max_freq_req) { + /* + * CPUFREQ_CREATE_POLICY notification is sent only after + * successfully adding max_freq_req request. + */ + blocking_notifier_call_chain(&cpufreq_policy_notifier_list, + CPUFREQ_REMOVE_POLICY, policy); + dev_pm_qos_remove_request(policy->max_freq_req); + } + dev_pm_qos_remove_request(policy->min_freq_req); kfree(policy->min_freq_req); @@ -1393,6 +1403,9 @@ static int cpufreq_online(unsigned int cpu) ret); goto out_destroy_policy; } + + blocking_notifier_call_chain(&cpufreq_policy_notifier_list, + CPUFREQ_CREATE_POLICY, policy); } if (cpufreq_driver->get && has_target()) { diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index d757a56a74dc..e28c8af697d2 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -458,6 +458,8 @@ static inline void cpufreq_resume(void) {} /* Policy Notifiers */ #define CPUFREQ_ADJUST (0) #define CPUFREQ_NOTIFY (1) +#define CPUFREQ_CREATE_POLICY (2) +#define CPUFREQ_REMOVE_POLICY (3) #ifdef CONFIG_CPU_FREQ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list); From patchwork Tue Jul 16 09:54:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 169047 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp619141ilk; Tue, 16 Jul 2019 02:55:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJOQGwItaxNc1uDpqtkRjHz0IRRcfCVqDgs09G6E1Nvtq3vvNrXQ0It+Ijyc6kC+Z3SEq0 X-Received: by 2002:a63:a54:: with SMTP id z20mr15672633pgk.62.1563270920565; Tue, 16 Jul 2019 02:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563270920; cv=none; d=google.com; s=arc-20160816; b=LL4sC1pLS7hpLVB3wv+kBIKHBMU8Iu1MqfexgtmD914H4avdIk7I2c1iXvzvaoaKPA SG1cuVZQ/2yywpKx5ifgbz7r7MfrT+4s4MrD8faQoRw8PNT3ncRvX33waM4H70HOUD/m M3ddmIfIe727Dx7AjVugsFwUIqkBbzEa4UoNqW2tl5dfTZzJHfFC9jTue1eADqYXyR8q reVrd1C4La7xnh9FJlByhqyYVcN7l1btiwDvGXe06pK4woCRMul8JfoDatoIGIpKbPwi ACSVq4jz9D8/l4QaNOOdaEt/kKtBrihqSHPhLuvNNDIKVG0emLGoxIiqRkMJy9yi2Z6+ 4ofQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FCHE6jmJHvvf4ZOfPHyOAwxkEw7udl1CJtgxI9QEJbs=; b=A7c6a0l69BisbeEvsJPBj4GzN7EjrXxNRMC+2vxSM7rxyiqt5t5HmHmloWztg287fM n2rZhVSL01/ulvapkr8CWQ3dAMeaePHdD6Ncim99B23sDDV1fQ82CRuN0hssnSnmNXgC q+0TfjSvH+WVUAVbyBa3ux7dkmmABgwFFSKuik/BxrjTseslxqLqemRLUaenfb8p8ecn Cb0hW2DvIv76f3MY9fvDvUCEwRSZZvGp3FYAxK6I66ZH0scRJUFf1yZcOWQ3Ks0umjuS BiTv75K8gW0pidNEVezRzQuVZRFemi3EKwxdNyId2ZhaMFTpaLxroTdEWH950yj4OZ9o VyYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cyDgYafj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j185si19504068pge.91.2019.07.16.02.55.20; Tue, 16 Jul 2019 02:55:20 -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; dkim=pass header.i=@linaro.org header.s=google header.b=cyDgYafj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733104AbfGPJzT (ORCPT + 11 others); Tue, 16 Jul 2019 05:55:19 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39729 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfGPJzS (ORCPT ); Tue, 16 Jul 2019 05:55:18 -0400 Received: by mail-pg1-f193.google.com with SMTP id u17so9182267pgi.6 for ; Tue, 16 Jul 2019 02:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FCHE6jmJHvvf4ZOfPHyOAwxkEw7udl1CJtgxI9QEJbs=; b=cyDgYafjtQ9BTLfXLwRoWNuVpBgLISxcZazGQYNrTGFUzlsgpGS5yhv/yPp7LXUPYv rTOA5TTk/wdufu1YAISq/IoarJgOmanKbMeIuXOb6AjUvC7b3XjEsefLkgEB6vYpgSBh Uu1DYcNJYyWfjkGOTv6dSXqxGYj1jiAZZcX8LjVTTE4lMxEIiwbg6XgvEKKQvNp1QOXC LejdLEMEqdrQagKYWyxCAieW4SOivR/2TQAZ1tPzejXzJErkSV4RZwPzgP+v7bJRKhs7 tHYeH++bwkEyZWAYE1Og5vEGwfutWGp6OlbowV/sjNT0rd123qx6chxSx/PznWhvxZDQ IAyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FCHE6jmJHvvf4ZOfPHyOAwxkEw7udl1CJtgxI9QEJbs=; b=l/AiPP4b8IGoVnXMrGgJdhtl/hJrk6vauW04a/8K9XXJSoLckgsr0zNdUuCAMR+eUR J70vGjBtr3Vf/gD9s6Jif+R7cty5s4GN2QZXXE/p2RWmOTIuhGDJxdTurcHze1QHvSsx Elyj4ZM089O96efZc5Acq1G4gQl57Fdei/3LJmRgkOQSH6Kb95mwY+S+UeKh50dwICkG +GvwRo582gQgdnz7FHyz3CiBKzxj69Y94gWF0EZuPb0QMvrwIo+ptwK+mw3glTnMJDAb D22k1fz+UKX7XEgcImk/+/f9aM0BSSS7Vqm7rPdYO091n8IOtp1dgT2iQMI7tMf1edYw dW4A== X-Gm-Message-State: APjAAAVE2Wd8sYZz2aMIsAB9fz9qfgSlUPw/tFsbgr5UL5lOkr5/MAk4 dGWYjxVxVGuu+a4XSUpm6m3YfA== X-Received: by 2002:a17:90a:a410:: with SMTP id y16mr35296476pjp.62.1563270917408; Tue, 16 Jul 2019 02:55:17 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id bg3sm19071910pjb.9.2019.07.16.02.55.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 02:55:16 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 07/10] cpufreq: powerpc_cbe: Switch to QoS requests instead of cpufreq notifier Date: Tue, 16 Jul 2019 15:24:51 +0530 Message-Id: <889777691cd3de894c37f5113e4ec1cc73473a0f.1563270828.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The cpufreq core now takes the min/max frequency constraints via QoS requests and the CPUFREQ_ADJUST notifier shall get removed later on. Switch over to using the QoS request for maximum frequency constraint for ppc_cbe_cpufreq driver. Signed-off-by: Viresh Kumar --- drivers/cpufreq/ppc_cbe_cpufreq.c | 19 +++++- drivers/cpufreq/ppc_cbe_cpufreq.h | 8 +++ drivers/cpufreq/ppc_cbe_cpufreq_pmi.c | 96 +++++++++++++++++---------- 3 files changed, 86 insertions(+), 37 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c index b83f36febf03..c58abb4cca3a 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq.c @@ -110,6 +110,13 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) #endif policy->freq_table = cbe_freqs; + cbe_cpufreq_pmi_policy_init(policy); + return 0; +} + +static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy) +{ + cbe_cpufreq_pmi_policy_exit(policy); return 0; } @@ -129,6 +136,7 @@ static struct cpufreq_driver cbe_cpufreq_driver = { .verify = cpufreq_generic_frequency_table_verify, .target_index = cbe_cpufreq_target, .init = cbe_cpufreq_cpu_init, + .exit = cbe_cpufreq_cpu_exit, .name = "cbe-cpufreq", .flags = CPUFREQ_CONST_LOOPS, }; @@ -139,15 +147,24 @@ static struct cpufreq_driver cbe_cpufreq_driver = { static int __init cbe_cpufreq_init(void) { + int ret; + if (!machine_is(cell)) return -ENODEV; - return cpufreq_register_driver(&cbe_cpufreq_driver); + cbe_cpufreq_pmi_init(); + + ret = cpufreq_register_driver(&cbe_cpufreq_driver); + if (ret) + cbe_cpufreq_pmi_exit(); + + return ret; } static void __exit cbe_cpufreq_exit(void) { cpufreq_unregister_driver(&cbe_cpufreq_driver); + cbe_cpufreq_pmi_exit(); } module_init(cbe_cpufreq_init); diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.h b/drivers/cpufreq/ppc_cbe_cpufreq.h index 9d973519d669..00cd8633b0d9 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq.h +++ b/drivers/cpufreq/ppc_cbe_cpufreq.h @@ -20,6 +20,14 @@ int cbe_cpufreq_set_pmode_pmi(int cpu, unsigned int pmode); #if IS_ENABLED(CONFIG_CPU_FREQ_CBE_PMI) extern bool cbe_cpufreq_has_pmi; +void cbe_cpufreq_pmi_policy_init(struct cpufreq_policy *policy); +void cbe_cpufreq_pmi_policy_exit(struct cpufreq_policy *policy); +void cbe_cpufreq_pmi_init(void); +void cbe_cpufreq_pmi_exit(void); #else #define cbe_cpufreq_has_pmi (0) +static inline void cbe_cpufreq_pmi_policy_init(struct cpufreq_policy *policy) {} +static inline void cbe_cpufreq_pmi_policy_exit(struct cpufreq_policy *policy) {} +static inline void cbe_cpufreq_pmi_init(void) {} +static inline void cbe_cpufreq_pmi_exit(void) {} #endif diff --git a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c index 97c8ee4614b7..0babb27c1c72 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -24,8 +25,6 @@ #include "ppc_cbe_cpufreq.h" -static u8 pmi_slow_mode_limit[MAX_CBE]; - bool cbe_cpufreq_has_pmi = false; EXPORT_SYMBOL_GPL(cbe_cpufreq_has_pmi); @@ -65,64 +64,89 @@ EXPORT_SYMBOL_GPL(cbe_cpufreq_set_pmode_pmi); static void cbe_cpufreq_handle_pmi(pmi_message_t pmi_msg) { + struct cpufreq_policy *policy; + struct dev_pm_qos_request *req; u8 node, slow_mode; + int cpu, ret; BUG_ON(pmi_msg.type != PMI_TYPE_FREQ_CHANGE); node = pmi_msg.data1; slow_mode = pmi_msg.data2; - pmi_slow_mode_limit[node] = slow_mode; + cpu = cbe_node_to_cpu(node); pr_debug("cbe_handle_pmi: node: %d max_freq: %d\n", node, slow_mode); -} - -static int pmi_notifier(struct notifier_block *nb, - unsigned long event, void *data) -{ - struct cpufreq_policy *policy = data; - struct cpufreq_frequency_table *cbe_freqs = policy->freq_table; - u8 node; - - /* Should this really be called for CPUFREQ_ADJUST and CPUFREQ_NOTIFY - * policy events?) - */ - node = cbe_cpu_to_node(policy->cpu); - - pr_debug("got notified, event=%lu, node=%u\n", event, node); - if (pmi_slow_mode_limit[node] != 0) { - pr_debug("limiting node %d to slow mode %d\n", - node, pmi_slow_mode_limit[node]); + policy = cpufreq_cpu_get(cpu); + if (!policy) { + pr_warn("cpufreq policy not found cpu%d\n", cpu); + return; + } - cpufreq_verify_within_limits(policy, 0, + req = policy->driver_data; - cbe_freqs[pmi_slow_mode_limit[node]].frequency); - } + ret = dev_pm_qos_update_request(req, + policy->freq_table[slow_mode].frequency); + if (ret) + pr_warn("Failed to update freq constraint: %d\n", ret); + else + pr_debug("limiting node %d to slow mode %d\n", node, slow_mode); - return 0; + cpufreq_cpu_put(policy); } -static struct notifier_block pmi_notifier_block = { - .notifier_call = pmi_notifier, -}; - static struct pmi_handler cbe_pmi_handler = { .type = PMI_TYPE_FREQ_CHANGE, .handle_pmi_message = cbe_cpufreq_handle_pmi, }; +void cbe_cpufreq_pmi_policy_init(struct cpufreq_policy *policy) +{ + struct dev_pm_qos_request *req; + int ret; + + if (!cbe_cpufreq_has_pmi) + return; + + req = kzalloc(sizeof(*req), GFP_KERNEL); + if (!req) + return; + + ret = dev_pm_qos_add_request(get_cpu_device(policy->cpu), req, + DEV_PM_QOS_MAX_FREQUENCY, + policy->freq_table[0].frequency); + if (ret < 0) { + pr_err("Failed to add freq constraint (%d)\n", ret); + kfree(req); + return; + } + policy->driver_data = req; +} +EXPORT_SYMBOL_GPL(cbe_cpufreq_pmi_policy_init); -static int __init cbe_cpufreq_pmi_init(void) +void cbe_cpufreq_pmi_policy_exit(struct cpufreq_policy *policy) { - cbe_cpufreq_has_pmi = pmi_register_handler(&cbe_pmi_handler) == 0; + struct dev_pm_qos_request *req = policy->driver_data; - if (!cbe_cpufreq_has_pmi) - return -ENODEV; + if (cbe_cpufreq_has_pmi) { + dev_pm_qos_remove_request(req); + kfree(req); + } +} +EXPORT_SYMBOL_GPL(cbe_cpufreq_pmi_policy_exit); - cpufreq_register_notifier(&pmi_notifier_block, CPUFREQ_POLICY_NOTIFIER); +void cbe_cpufreq_pmi_init(void) +{ + if (!pmi_register_handler(&cbe_pmi_handler)) + cbe_cpufreq_has_pmi = true; +} +EXPORT_SYMBOL_GPL(cbe_cpufreq_pmi_init); - return 0; +void cbe_cpufreq_pmi_exit(void) +{ + pmi_unregister_handler(&cbe_pmi_handler); + cbe_cpufreq_has_pmi = false; } -device_initcall(cbe_cpufreq_pmi_init); +EXPORT_SYMBOL_GPL(cbe_cpufreq_pmi_exit); From patchwork Tue Jul 16 09:54:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 169049 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp619257ilk; Tue, 16 Jul 2019 02:55:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFyrjQ9zWhk6D3J01OVbROdvMVWa9PtnkF/LCq3ucIJqoIHIx6dBWSYoxwgWUyqRjKww/2 X-Received: by 2002:a17:90a:8a0b:: with SMTP id w11mr34764055pjn.125.1563270927523; Tue, 16 Jul 2019 02:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563270927; cv=none; d=google.com; s=arc-20160816; b=BkTLSXPHSFpHR16KrdiKK4UK0adxUqeQ+UNc/yR8+tRYS9st9hSuhNgeOtIqS1ct7/ VgtoYgTix8qa7l4f9Bz622FK7gjJqqyLaEO0Ow7UP6fL3NuUOxycv3OttU9qUN5rWZDi ogVzCBuk1UDtxgnao6MPUoTEsD3wUOgQAk2qkNmGgsKW6yV+gDDWedZEjJ7pacfSaG/7 0SXYjhcUzbTVjs/vYs+2FcfAvbaGV0FoFUU4BYSe5jv1nKQjb2IDkjVroTDCRUo8F37v /8l8LpnN45nxTZVMkrn3tR8HA+6CtDSc37305eYSl57SGMhp0JZF3R1Hhys5TcHhZw6f RHQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=igbw8Lq9b0TFNBWb47jJMKCAo+bPsNo96FEJcJLrXVc=; b=u9rjvuG84+c1wLTgtMzKG/41WixmbmGauhhbEUo5HttAcZRRgAcuzqKd9k77Wnj6Rw 2LvgEd4PzVJU4OukvN7N/AbrlI/RaHZZZLfu7IDxfK6apBh5v3aQvW+ujsCQtgckCROB nCIsORd3cT1FvJKbOZFNJi8H8qYbPE5MJOp+k/u88mGUy4v9sWOcvbAKHVFaDtdQgs9W g2rsUb/cDPh4DfmMW09I27G6cJciEo1uVo99PyaRcQIWvR5kPlmhklnllopol0zMKGAA xOx48kFsd9De2vLl3seT4iS9oMWhJ8t5jDLYyzL1gOa/DM4FmdLIBmeL3QSwcS+vKP59 6UQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1uaGUoA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u20si17319936plq.421.2019.07.16.02.55.27; Tue, 16 Jul 2019 02:55:27 -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; dkim=pass header.i=@linaro.org header.s=google header.b=H1uaGUoA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732199AbfGPJzZ (ORCPT + 11 others); Tue, 16 Jul 2019 05:55:25 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40921 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733186AbfGPJzY (ORCPT ); Tue, 16 Jul 2019 05:55:24 -0400 Received: by mail-pg1-f193.google.com with SMTP id w10so9180753pgj.7 for ; Tue, 16 Jul 2019 02:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=igbw8Lq9b0TFNBWb47jJMKCAo+bPsNo96FEJcJLrXVc=; b=H1uaGUoAeqRk6S2i3GDT8ntkwDm5cC2Flj+OsmfRqTVZQOoqEeOTDCKsdr3QFfWCQA jIPdgK/siD6VGKOf89ZSbHQ+j1jPeChgW95ao4XWPlukec3p7kpdOUigGHiApEVT7fAi EafM7d2Qy7MqOBAe6k5q7qDDPhMD7AdzffO+i9yl3vvgOzpHm4gVd5lgQ58XayNvMuhh 4UHcVXOZ220ePO6/sNBsel0AOBBiS4C4rr5kGcrP7M+qOUm5wTvGLrYjEKbctD6LwlTU SwW+LMRxd/hv3ImIN9xUrJOoCbpaTxkwlDmUIlUNaY9z8ypRk3RqDmqs5LVX7Tr8mz87 okiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=igbw8Lq9b0TFNBWb47jJMKCAo+bPsNo96FEJcJLrXVc=; b=S4wrekG4jWCbRl0HezNDT6qsLuiU/LrqF2WYUyzwf9aA+LwMZuXyPys92/J7wzI2f9 jpHwvcalkCwRHCXp1COzR3Osfd0goAne1v+h+WGuhBXRRucMXZKx1a7eOc4Fb3o336v2 OoB6xrG4VaWe96tXcUbQPEvooozTthN5PRLDW2ou0ycBGwENXeYnSCvpjGpwrZWwXCJL yNBvbIZXXR0+VR3qryB2qtuQHcoHPF1auS9YVlNutGLQpvSO2Hdi4s+Edd79uuiUFsfv CyL1znsZebd3+07SFeWAnLIYef6uZYp0tEB5yhBIV+K/RICpA84mjGGMQL5m6ACfp11U 7gRg== X-Gm-Message-State: APjAAAUI8LN2DDKAwRRap9y0hIPa6b1KQYJ+3A8h6O69CFdGOcN8oyCm RbD4Nor5adxsZFsj9BZyupZxvfMg9Fs= X-Received: by 2002:a17:90a:d14b:: with SMTP id t11mr34976911pjw.79.1563270923963; Tue, 16 Jul 2019 02:55:23 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id d14sm27038469pfo.154.2019.07.16.02.55.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 02:55:23 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 09/10] cpufreq: Remove CPUFREQ_ADJUST and CPUFREQ_NOTIFY policy notifier events Date: Tue, 16 Jul 2019 15:24:53 +0530 Message-Id: <77857b9eadc26c57de2637fcca014239a93551e4.1563270828.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org No driver makes reference to these events now, remove them and the code related to them. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 36 +++++++----------------------------- include/linux/cpufreq.h | 6 ++---- 2 files changed, 9 insertions(+), 33 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 8a7eff2a3771..bd91091ed6b8 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2362,15 +2362,13 @@ EXPORT_SYMBOL(cpufreq_get_policy); * @policy: Policy object to modify. * @new_policy: New policy data. * - * Pass @new_policy to the cpufreq driver's ->verify() callback, run the - * installed policy notifiers for it with the CPUFREQ_ADJUST value, pass it to - * the driver's ->verify() callback again and run the notifiers for it again - * with the CPUFREQ_NOTIFY value. Next, copy the min and max parameters - * of @new_policy to @policy and either invoke the driver's ->setpolicy() - * callback (if present) or carry out a governor update for @policy. That is, - * run the current governor's ->limits() callback (if the governor field in - * @new_policy points to the same object as the one in @policy) or replace the - * governor for @policy with the new one stored in @new_policy. + * Pass @new_policy to the cpufreq driver's ->verify() callback. Next, copy the + * min and max parameters of @new_policy to @policy and either invoke the + * driver's ->setpolicy() callback (if present) or carry out a governor update + * for @policy. That is, run the current governor's ->limits() callback (if the + * governor field in @new_policy points to the same object as the one in + * @policy) or replace the governor for @policy with the new one stored in + * @new_policy. * * The cpuinfo part of @policy is not updated by this function. */ @@ -2398,26 +2396,6 @@ int cpufreq_set_policy(struct cpufreq_policy *policy, if (ret) return ret; - /* - * The notifier-chain shall be removed once all the users of - * CPUFREQ_ADJUST are moved to use the QoS framework. - */ - /* adjust if necessary - all reasons */ - blocking_notifier_call_chain(&cpufreq_policy_notifier_list, - CPUFREQ_ADJUST, new_policy); - - /* - * verify the cpu speed can be set within this limit, which might be - * different to the first one - */ - ret = cpufreq_driver->verify(new_policy); - if (ret) - return ret; - - /* notification of the new policy */ - blocking_notifier_call_chain(&cpufreq_policy_notifier_list, - CPUFREQ_NOTIFY, new_policy); - policy->min = new_policy->min; policy->max = new_policy->max; trace_cpu_frequency_limits(policy); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index e28c8af697d2..cb1e86a14c7a 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -456,10 +456,8 @@ static inline void cpufreq_resume(void) {} #define CPUFREQ_POSTCHANGE (1) /* Policy Notifiers */ -#define CPUFREQ_ADJUST (0) -#define CPUFREQ_NOTIFY (1) -#define CPUFREQ_CREATE_POLICY (2) -#define CPUFREQ_REMOVE_POLICY (3) +#define CPUFREQ_CREATE_POLICY (0) +#define CPUFREQ_REMOVE_POLICY (1) #ifdef CONFIG_CPU_FREQ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);