From patchwork Thu Jul 4 07:36:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168464 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1921647ilk; Thu, 4 Jul 2019 00:36:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqy89RPsDMSgiDGlPByxKXkFmwiz0v9Zb/mmZ3DSThyqioEwJJOImxw8FkwqPLEJYfXKYff8 X-Received: by 2002:a17:90a:9b08:: with SMTP id f8mr18192649pjp.103.1562225804528; Thu, 04 Jul 2019 00:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225804; cv=none; d=google.com; s=arc-20160816; b=pZGEm83958iaUU5f2DalydO7IwmkW7PyHtR/hExp8YLMoiIj+wDb5b2jhnjbWlacla L5JJ1H/7JQ5Uh27Kd4M+HPBOg9GwYd5ql/7hvfANo1A0wxQeCcc7fVur68Ha7dHOiBIY VCMHaDrdr4qCFJzpfSCr/pa8phk5qZCGJvH81ckYjTBFYTF8O2Wax2sXT8VJ9SfsXJ44 W7PH/t7lsU00N71he0xXP3nvRw4VjxBLdChvIqkONoVTcXFh5bJbwuucuiTBtcnDMVbn gIoFrx+sDFtE806N/sP9pIwREeER/PFqR2AOfeNN2kJPihjyFo5T1KNoweF2M+vMT2Nc o+rw== 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=+s3P9qzKMAqECk8C+Sk1k3SW2lGlacp8Yo80xbrvmz8=; b=mHbZOB++E85W6msh6BGT02Y+luvyiN6ymr/Qn/gLrSF4nM8WzqRBCyUKXHGoCOQYw3 T9qd9ZVWcqFbrMW7KnGR9N6PvyxfvwaUr1Z9p74a2cHg5bPfiVLtiA5LMhTCv7WUrEN5 RV2AAEz3c+3q68vELpr/WeNt5mz7OuQiKrhY1I/bZrH/sU73FwYlAS65P1h03x4bcHm5 dhheTzWbVc0XMwGIDMueDQ9liILGo3L4nK0iktjE+nZv/w8fFeeADywcZOmVj8ljGg1J V9fqxKoNWbf7Lc3WhZviaghqRF4ov3IfOaDJigrOwWCuwwntVHdjj+WImevNs2r1gFvs 9NfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="m/vyqTn8"; 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 h2si4713241pgs.227.2019.07.04.00.36.44; Thu, 04 Jul 2019 00:36: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; dkim=pass header.i=@linaro.org header.s=google header.b="m/vyqTn8"; 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 S1727241AbfGDHgn (ORCPT + 11 others); Thu, 4 Jul 2019 03:36:43 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38590 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727184AbfGDHgm (ORCPT ); Thu, 4 Jul 2019 03:36:42 -0400 Received: by mail-pf1-f194.google.com with SMTP id y15so2534357pfn.5 for ; Thu, 04 Jul 2019 00:36:41 -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=+s3P9qzKMAqECk8C+Sk1k3SW2lGlacp8Yo80xbrvmz8=; b=m/vyqTn8o328Cj1Ebp2lyvrMWinCeSTQbUz0ivp6F7Cd6dRi1hXKZia9tEmO/AaYwn 5mGv0+DmRoidAP4iJ2xk/rusIyfbn496SGsPXRlGLQwdZwVzEUP0rqC9AJkL7aa7yB5R G0dpnQOZVH08TKWGXWEcdHPD/CCAkeoodd073rSeT5ARvDxN5eLanjYcWYmUqoupoegn vgwZAWRaB5CAZqYGwZIawAXPxN1TLlTPNW9mFbv7PUoqQz8tdeykHny733h4QFXinwza LScix5XKmaNLB/vJSOfXYbdBrofCelWCkx36kS/keM563h6VIpT2Vq2nD7F8dDFKw+7v xtDw== 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=+s3P9qzKMAqECk8C+Sk1k3SW2lGlacp8Yo80xbrvmz8=; b=uPrFWgQ+H0CLMlx8vkSyf9IF/0+jDDwydkiJdX6RTXdoA7Ri6W0lPtO8QI9URpNDWw pBPQCZ5CggdV9ge0gKD2UsFH29f0a7gwUtCjWoS+WMiEQDzP1aDVbiRdW+LtvZuOta15 UDz8RKieeFbbG3cq3wAkvEPO092XQdkBcAmQc/r+PcZZFI9oq2AGUTvS7LHmkxhrwqX5 JMCZDRsXU+XrBH+/CJ41u1xQZaUqIKm0gdI03bQODjg9VnsRvTLw0KCLj7Ras6qZa+2r UvOMwM/ODjTbeEJa0DzhIWMjq3EmSbIJLmDPAquJmcVd2FoozHludxAm7XCnInKeBjkF BuXw== X-Gm-Message-State: APjAAAVabZZU1C7hrStK7+GZNvrbwDImN9Wg30F4BIidxBvGtq+eXJ9i IPe/vow5BZm7bKZ1V9fi/yCyqA== X-Received: by 2002:a63:5d45:: with SMTP id o5mr42539882pgm.40.1562225801388; Thu, 04 Jul 2019 00:36:41 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id t4sm10505370pgj.20.2019.07.04.00.36.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 00:36:40 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Len Brown , Pavel Machek Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Matthias Kaehlcke , Ulf Hansson , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH V6 4/7] PM / QoS: Add support for MIN/MAX frequency constraints Date: Thu, 4 Jul 2019 13:06:20 +0530 Message-Id: <78618006d31732315393c428b05a243d573d8ebe.1562210705.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 This patch introduces the min-frequency and max-frequency device constraints, which will be used by the cpufreq core to begin with. Reviewed-by: Matthias Kaehlcke Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- drivers/base/power/qos.c | 111 ++++++++++++++++++++++++++++++++++----- include/linux/pm_qos.h | 12 +++++ 2 files changed, 109 insertions(+), 14 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index 2461fed0efa0..6c90fd7e2ff8 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -120,6 +120,14 @@ s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type) ret = IS_ERR_OR_NULL(qos) ? PM_QOS_RESUME_LATENCY_NO_CONSTRAINT : pm_qos_read_value(&qos->resume_latency); break; + case DEV_PM_QOS_MIN_FREQUENCY: + ret = IS_ERR_OR_NULL(qos) ? PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE + : pm_qos_read_value(&qos->min_frequency); + break; + case DEV_PM_QOS_MAX_FREQUENCY: + ret = IS_ERR_OR_NULL(qos) ? PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE + : pm_qos_read_value(&qos->max_frequency); + break; default: WARN_ON(1); ret = 0; @@ -161,6 +169,14 @@ static int apply_constraint(struct dev_pm_qos_request *req, req->dev->power.set_latency_tolerance(req->dev, value); } break; + case DEV_PM_QOS_MIN_FREQUENCY: + ret = pm_qos_update_target(&qos->min_frequency, + &req->data.pnode, action, value); + break; + case DEV_PM_QOS_MAX_FREQUENCY: + ret = pm_qos_update_target(&qos->max_frequency, + &req->data.pnode, action, value); + break; case DEV_PM_QOS_FLAGS: ret = pm_qos_update_flags(&qos->flags, &req->data.flr, action, value); @@ -189,12 +205,11 @@ static int dev_pm_qos_constraints_allocate(struct device *dev) if (!qos) return -ENOMEM; - n = kzalloc(sizeof(*n), GFP_KERNEL); + n = kzalloc(3 * sizeof(*n), GFP_KERNEL); if (!n) { kfree(qos); return -ENOMEM; } - BLOCKING_INIT_NOTIFIER_HEAD(n); c = &qos->resume_latency; plist_head_init(&c->list); @@ -203,6 +218,7 @@ static int dev_pm_qos_constraints_allocate(struct device *dev) c->no_constraint_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; c->type = PM_QOS_MIN; c->notifiers = n; + BLOCKING_INIT_NOTIFIER_HEAD(n); c = &qos->latency_tolerance; plist_head_init(&c->list); @@ -211,6 +227,24 @@ static int dev_pm_qos_constraints_allocate(struct device *dev) c->no_constraint_value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT; c->type = PM_QOS_MIN; + c = &qos->min_frequency; + plist_head_init(&c->list); + c->target_value = PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE; + c->default_value = PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE; + c->no_constraint_value = PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE; + c->type = PM_QOS_MAX; + c->notifiers = ++n; + BLOCKING_INIT_NOTIFIER_HEAD(n); + + c = &qos->max_frequency; + plist_head_init(&c->list); + c->target_value = PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE; + c->default_value = PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE; + c->no_constraint_value = PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE; + c->type = PM_QOS_MIN; + c->notifiers = ++n; + BLOCKING_INIT_NOTIFIER_HEAD(n); + INIT_LIST_HEAD(&qos->flags.list); spin_lock_irq(&dev->power.lock); @@ -264,11 +298,25 @@ void dev_pm_qos_constraints_destroy(struct device *dev) apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE); memset(req, 0, sizeof(*req)); } + c = &qos->latency_tolerance; plist_for_each_entry_safe(req, tmp, &c->list, data.pnode) { apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE); memset(req, 0, sizeof(*req)); } + + c = &qos->min_frequency; + plist_for_each_entry_safe(req, tmp, &c->list, data.pnode) { + apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE); + memset(req, 0, sizeof(*req)); + } + + c = &qos->max_frequency; + plist_for_each_entry_safe(req, tmp, &c->list, data.pnode) { + apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE); + memset(req, 0, sizeof(*req)); + } + f = &qos->flags; list_for_each_entry_safe(req, tmp, &f->list, data.flr.node) { apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE); @@ -380,6 +428,8 @@ static int __dev_pm_qos_update_request(struct dev_pm_qos_request *req, switch(req->type) { case DEV_PM_QOS_RESUME_LATENCY: case DEV_PM_QOS_LATENCY_TOLERANCE: + case DEV_PM_QOS_MIN_FREQUENCY: + case DEV_PM_QOS_MAX_FREQUENCY: curr_value = req->data.pnode.prio; break; case DEV_PM_QOS_FLAGS: @@ -492,9 +542,6 @@ int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier, { int ret = 0; - if (WARN_ON(type != DEV_PM_QOS_RESUME_LATENCY)) - return -EINVAL; - mutex_lock(&dev_pm_qos_mtx); if (IS_ERR(dev->power.qos)) @@ -502,10 +549,28 @@ int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier, else if (!dev->power.qos) ret = dev_pm_qos_constraints_allocate(dev); - if (!ret) + if (ret) + goto unlock; + + switch (type) { + case DEV_PM_QOS_RESUME_LATENCY: ret = blocking_notifier_chain_register(dev->power.qos->resume_latency.notifiers, notifier); + break; + case DEV_PM_QOS_MIN_FREQUENCY: + ret = blocking_notifier_chain_register(dev->power.qos->min_frequency.notifiers, + notifier); + break; + case DEV_PM_QOS_MAX_FREQUENCY: + ret = blocking_notifier_chain_register(dev->power.qos->max_frequency.notifiers, + notifier); + break; + default: + WARN_ON(1); + ret = -EINVAL; + } +unlock: mutex_unlock(&dev_pm_qos_mtx); return ret; } @@ -526,20 +591,35 @@ int dev_pm_qos_remove_notifier(struct device *dev, struct notifier_block *notifier, enum dev_pm_qos_req_type type) { - int retval = 0; - - if (WARN_ON(type != DEV_PM_QOS_RESUME_LATENCY)) - return -EINVAL; + int ret = 0; mutex_lock(&dev_pm_qos_mtx); /* Silently return if the constraints object is not present. */ - if (!IS_ERR_OR_NULL(dev->power.qos)) - retval = blocking_notifier_chain_unregister(dev->power.qos->resume_latency.notifiers, - notifier); + if (IS_ERR_OR_NULL(dev->power.qos)) + goto unlock; + + switch (type) { + case DEV_PM_QOS_RESUME_LATENCY: + ret = blocking_notifier_chain_unregister(dev->power.qos->resume_latency.notifiers, + notifier); + break; + case DEV_PM_QOS_MIN_FREQUENCY: + ret = blocking_notifier_chain_unregister(dev->power.qos->min_frequency.notifiers, + notifier); + break; + case DEV_PM_QOS_MAX_FREQUENCY: + ret = blocking_notifier_chain_unregister(dev->power.qos->max_frequency.notifiers, + notifier); + break; + default: + WARN_ON(1); + ret = -EINVAL; + } +unlock: mutex_unlock(&dev_pm_qos_mtx); - return retval; + return ret; } EXPORT_SYMBOL_GPL(dev_pm_qos_remove_notifier); @@ -599,6 +679,9 @@ static void __dev_pm_qos_drop_user_request(struct device *dev, req = dev->power.qos->flags_req; dev->power.qos->flags_req = NULL; break; + default: + WARN_ON(1); + return; } __dev_pm_qos_remove_request(req); kfree(req); diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 9a21b7ba72ae..2aebbc5b9950 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -40,6 +40,8 @@ enum pm_qos_flags_status { #define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT PM_QOS_LATENCY_ANY #define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS PM_QOS_LATENCY_ANY_NS #define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0 +#define PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE 0 +#define PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE (-1) #define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1) #define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) @@ -58,6 +60,8 @@ struct pm_qos_flags_request { enum dev_pm_qos_req_type { DEV_PM_QOS_RESUME_LATENCY = 1, DEV_PM_QOS_LATENCY_TOLERANCE, + DEV_PM_QOS_MIN_FREQUENCY, + DEV_PM_QOS_MAX_FREQUENCY, DEV_PM_QOS_FLAGS, }; @@ -99,10 +103,14 @@ struct pm_qos_flags { struct dev_pm_qos { struct pm_qos_constraints resume_latency; struct pm_qos_constraints latency_tolerance; + struct pm_qos_constraints min_frequency; + struct pm_qos_constraints max_frequency; struct pm_qos_flags flags; struct dev_pm_qos_request *resume_latency_req; struct dev_pm_qos_request *latency_tolerance_req; struct dev_pm_qos_request *flags_req; + struct dev_pm_qos_request *min_frequency_req; + struct dev_pm_qos_request *max_frequency_req; }; /* Action requested to pm_qos_update_target */ @@ -197,6 +205,10 @@ static inline s32 dev_pm_qos_read_value(struct device *dev, switch (type) { case DEV_PM_QOS_RESUME_LATENCY: return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; + case DEV_PM_QOS_MIN_FREQUENCY: + return PM_QOS_MIN_FREQUENCY_DEFAULT_VALUE; + case DEV_PM_QOS_MAX_FREQUENCY: + return PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE; default: WARN_ON(1); return 0; From patchwork Thu Jul 4 07:36:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168466 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1921747ilk; Thu, 4 Jul 2019 00:36:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMHlNt3zWqYYmLT2mupX0CvfUHPRie0JQnl+2aHKozs5FB4bXqZrH1zn+5oIGVMGIAZ7qm X-Received: by 2002:a17:902:1129:: with SMTP id d38mr48337113pla.220.1562225810986; Thu, 04 Jul 2019 00:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225810; cv=none; d=google.com; s=arc-20160816; b=Zh0GyXkar7jeRFlI3Nd3BUpMEjRfDtc7bkNKS5QkVs38bB00XcL5QBiJkeLWq+XxG/ dZW+JbhgFGdyjFzxfaB/tFDCg6aAy8C/YBpzifT9ejT6NPl2Js7we9KiO/oJqCe0da/3 CSi8O22mFCvdSy2j9jb4RZDOkTNmIIDKURDj5iP2Cz3J3iBUpK5Hpsbr57COtdsAIH00 wtkfT0Dlxd7PbZPgVFYtu8hv1pg0kUyIfathz47qnZc1fCsTkETR4D9NWh3QyAkyomjD GvyqBEtS4FaBlsbIZHyFacVkHwWJ9hUh0QlDZKM1b65Tm4sSoxDX7LS3qoxRg+B7rqjT luVA== 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=TxHtLXc14HRc+q+EFuMAl2ixyKPfQQHRTF5mh6/bpEU=; b=KvPL0dDiFt0Vvoi4Alb/ftjt39MlJnoWtZ5IsIW5udwKRBStSXoZtgQH7MZ161C/9C fpvj3KSePz6srWzB3EqYHghD4g1sqlJyt4gxgYKbcyJSMRGrToOSozi3P66Vzp7SbOHz LkgS4+3E/Dv+Pl9UCfP6+MjF1CGrIlO+Dd+Dr47Pag3R6+DPQ/nYImuD7aGWbX3CvS3x cyun7P2+ZjyMQQUoiJyJUdlp03lRB8uy40zswV2X8ODZUIvX8NJkfiaVCOP8XOD3fCrm WOpDZd54RU3vj3nXpANCr9kOOqLE6HEEZt+UV2VviioxEXxfWzV90nxVBEr6sZTA58KU bvSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IQT7MrQx; 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 b18si4711514pgm.82.2019.07.04.00.36.50; Thu, 04 Jul 2019 00:36:50 -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=IQT7MrQx; 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 S1727548AbfGDHgu (ORCPT + 11 others); Thu, 4 Jul 2019 03:36:50 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43914 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727528AbfGDHgs (ORCPT ); Thu, 4 Jul 2019 03:36:48 -0400 Received: by mail-pg1-f196.google.com with SMTP id f25so2493225pgv.10 for ; Thu, 04 Jul 2019 00:36:48 -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=TxHtLXc14HRc+q+EFuMAl2ixyKPfQQHRTF5mh6/bpEU=; b=IQT7MrQxceoW2i6DY1x54dzHxcQi4hu0k1Vm4r8RLMVDMIPYHzWdczor/7fo2jJ3Tx XRmbkYtpnWpqCx89MVVgU+ew0PmZZFLGzSfJVar1i2+5uXREv6Ty3D4/aItVDZ0NpMAm a0iNpxKioP+JcNoutryTVaWaP8EuFx3cyiWDvr742vz90dyY298fqT8QNDpW9NgcqNX6 kU0iBVrBYL88ifOm8R1pPNuAkJIjuK7oqBNDxByqF2vSKwUWdQmQ3NMcWNu4JukZbeC2 urQmq39fn4u+FU8RfVRTYnQvCp7ZqtR7brCH4Mro+mLrTD8/nwsZHDEAOsBnkSJa59j3 eNJg== 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=TxHtLXc14HRc+q+EFuMAl2ixyKPfQQHRTF5mh6/bpEU=; b=GMWenxxrjgywVx09Pmw70pT3xOTCneHYWce1v9s+UY9ZKj0XnVkHVhveGkT6ZpxYTC JZk7mUgzsDC7EVJLB6jGWVzdmOZy2JZLd2OwqJLlmGbE5gGDX///OZRoned+OgIsrkAo Z3yRG5OYU/8cw+A2hPeycOmo48t9RDRa0qhuX/A1IsFKTgbLRaKkflW3V5MaMozz2vhC p+8QZZ3Z9Fl1g+DFKC93BKYGInaUWQCcDsSPhuEVbXPZY6duk0h7jP6IguMd/Z50K7OG Pj38oS2bOk/FETsU7dSHi9cdB2ZNVmedy5tNf9kV0T3hHGWq8t/JnP4Q/iQRLy+XBTWI j8tg== X-Gm-Message-State: APjAAAWE2XV3s/wVaxMEQxypt/BU/JibATGgT/G0MZb85ItsOs/s2Kbv CQ9qfZeICh/wyHMT6REwNAH3mdgqC2A= X-Received: by 2002:a17:90b:d8b:: with SMTP id bg11mr18097327pjb.30.1562225807852; Thu, 04 Jul 2019 00:36:47 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id d12sm4515059pfd.96.2019.07.04.00.36.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 00:36:47 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Srinivas Pandruvada , Len Brown Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH V6 6/7] cpufreq: intel_pstate: Reuse refresh_frequency_limits() Date: Thu, 4 Jul 2019 13:06:22 +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 The implementation of intel_pstate_update_max_freq() is quite similar to refresh_frequency_limits(), lets reuse it. Finding minimum of policy->user_policy.max and policy->cpuinfo.max_freq in intel_pstate_update_max_freq() is redundant as cpufreq_set_policy() will call the ->verify() callback of intel-pstate driver, which will do this comparison anyway and so dropping it from intel_pstate_update_max_freq() doesn't harm. Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 3 ++- drivers/cpufreq/intel_pstate.c | 7 +------ include/linux/cpufreq.h | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 81117e4d43cc..091789e868ee 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1116,7 +1116,7 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp return ret; } -static void refresh_frequency_limits(struct cpufreq_policy *policy) +void refresh_frequency_limits(struct cpufreq_policy *policy) { struct cpufreq_policy new_policy; @@ -1133,6 +1133,7 @@ static void refresh_frequency_limits(struct cpufreq_policy *policy) up_write(&policy->rwsem); } +EXPORT_SYMBOL(refresh_frequency_limits); static void handle_update(struct work_struct *work) { diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index f2ff5de988c1..cc27d4c59dca 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -898,7 +898,6 @@ static void intel_pstate_update_policies(void) static void intel_pstate_update_max_freq(unsigned int cpu) { struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu); - struct cpufreq_policy new_policy; struct cpudata *cpudata; if (!policy) @@ -908,11 +907,7 @@ static void intel_pstate_update_max_freq(unsigned int cpu) policy->cpuinfo.max_freq = global.turbo_disabled_mf ? cpudata->pstate.max_freq : cpudata->pstate.turbo_freq; - memcpy(&new_policy, policy, sizeof(*policy)); - new_policy.max = min(policy->user_policy.max, policy->cpuinfo.max_freq); - new_policy.min = min(policy->user_policy.min, new_policy.max); - - cpufreq_set_policy(policy, &new_policy); + refresh_frequency_limits(policy); cpufreq_cpu_release(policy); } diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 95425941f46d..1fa37b675a80 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -207,6 +207,7 @@ void cpufreq_cpu_release(struct cpufreq_policy *policy); int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_set_policy(struct cpufreq_policy *policy, struct cpufreq_policy *new_policy); +void refresh_frequency_limits(struct cpufreq_policy *policy); void cpufreq_update_policy(unsigned int cpu); void cpufreq_update_limits(unsigned int cpu); bool have_governor_per_policy(void);