From patchwork Thu Feb 21 11:29:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 158904 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp373151jaa; Thu, 21 Feb 2019 03:29:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IZuu7gbEzuEzMz8VAIHiHYha6cb/4MCGNLH0nC+zLODsukt2N3xnLPT/RBM9RhJp1HVDiHR X-Received: by 2002:a62:6453:: with SMTP id y80mr39509348pfb.203.1550748595792; Thu, 21 Feb 2019 03:29:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550748595; cv=none; d=google.com; s=arc-20160816; b=ABXRARq4V8rjNArqYrUXCVRT+NUErPcXjt9FORiwSNPadxqMDccnADcMmI72fCjlVI BUaVuqOUQUXqSlOYpQS9JBWJoBA/mmlQ3gIoPg0AxIQ3Qh9muPC2ea4ncH3g9jSv36H9 OCzPohfDgYS10uAj+4Fo2WmM4Dnf6eTpyLabkA7twZgC+zHcPYqc1jEMj0KYepvONuO9 jL0opD/HDqWYYCK1y19Td5pNabvwQy8kBRRgi0VVRGfGGSXIQmHnYYBno/0UasirAwbs CNvHYQrXv4nW5q6G0yY5caWU5b1ncWndN9XNR065fsJqK3iw9GUZ+WyODbrMntkWyGqm Y86A== 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=F3LLSRDQOqGMBHSWQuz4LBphwjqYjeDRnqRsCnlMxjs=; b=pEINjfzu5XdWGpT+CV2APZg3x7ZT9S0abFTTG3BTvklM8rTJ0RT4EnhmFxf58sgqsR CXx0m4sEXekBdz4JxBiIuCEEDSnN0F9kYI/ycCH770v5Ac8ypLdu4ZTgvXQyno0MHwxb X+bP5axFnDPX5vVH08pk/hIz8SKVO+qOZHOSsCCGRWzYfs9ikvRi0l6iBowJwtYnvwuh f/Xe7qQHGoS0Yeh1WtCU6ggjxlXOcVKpGK8sbKY9KHSNRIDREhavEhyRA74HuxgnT+7s 2clcg0DDfIvFGj/RmPGuwwdM8ZHkT5WBjJB4/9ffucTfIF6iDxfvhlGn8N9LOMAxoyuB YqUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lips2aEK; 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 3si21435413plr.336.2019.02.21.03.29.55; Thu, 21 Feb 2019 03:29:55 -0800 (PST) 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=Lips2aEK; 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 S1727332AbfBUL3y (ORCPT + 11 others); Thu, 21 Feb 2019 06:29:54 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37241 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbfBUL3x (ORCPT ); Thu, 21 Feb 2019 06:29:53 -0500 Received: by mail-pl1-f195.google.com with SMTP id q3so6665447pll.4 for ; Thu, 21 Feb 2019 03:29:53 -0800 (PST) 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=F3LLSRDQOqGMBHSWQuz4LBphwjqYjeDRnqRsCnlMxjs=; b=Lips2aEKIKK1upuax5qhmiKCJgKL1LmwUbdV2ZR/oYjvtu0xU/X+cH6gi5VFgepDbQ JL4mezqlDB3Fe967wMqevBiYFtCikh94TjVeXAz5BInuPBchESHQEvi19AGoFOh22Wzb q/l+RID/abLT0wMBXKa1XYzlXlmh7hg9vADcLN/K1sdclHx5R5Lyu6Qw1Isyp2jAMCpp IpMw6pzWKQgw1vEw+W5jmzcp01JnHIRhPk7k2mqWKrT8+Q9v9OllnX5DoiFEuIkKXzer NadrUK39mhkOfGUQ1nRqJ5eK/yCoQagwKBIIKixm5PZ1r8sY5TfwpSRXTXY3X67uJMl3 Jr2Q== 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=F3LLSRDQOqGMBHSWQuz4LBphwjqYjeDRnqRsCnlMxjs=; b=QSYiEyS2Bq0z9q3Z2QEpFHVlPtva35T+tebmSo7lZtHUKBYsoqyVUI2LPP/IlOX9Na fVgjol4JuUnYrJSL2VOL+aMaJMc/MFwiWjBAx2NKBrVo66y9BnKE4DUocLF/VoWkCGIA hYx8vijekrioGUmacFn4aAHoo1NqAmGgZdXE7YaqWlvjL7LxNNrU1AnybpskQZRLvgi/ utybVZ4BTthTZjbRQ0VmQ2Q+RAWSn3/JoFsaKlrqpMWzS0Kydbu2QtCmslFUcSW4NMUx aHBmNawnYmQZC1DsMwsy4C4KUexsJHwvQ3lVrpKP20y1/PLYJ2jkKRBHr7fPL7uaUEwn BtnQ== X-Gm-Message-State: AHQUAubIdbM2aQD0jE6ds9MumMdlRwv3lULFCiTDyOousysiRbfOZXhV WTHyp7pr4Tcl65aufCM1qLNLYg== X-Received: by 2002:a17:902:8f82:: with SMTP id z2mr3003556plo.163.1550748592835; Thu, 21 Feb 2019 03:29:52 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id l64sm12733460pga.87.2019.02.21.03.29.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:29:52 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson , Daniel Lezcano Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , mka@chromium.org, juri.lelli@gmail.com, Qais.Yousef@arm.com, linux-kernel@vger.kernel.org Subject: [PATCH V2 2/5] PM / QOS: Pass request type to dev_pm_qos_read_value() Date: Thu, 21 Feb 2019 16:59:28 +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 In order to use dev_pm_qos_read_value(), and other internal routines to it, to read values for different QoS requests, pass request type as a parameter to these routines. For now, it only supports resume-latency request type. Signed-off-by: Viresh Kumar --- Documentation/power/pm_qos_interface.txt | 2 +- drivers/base/power/domain_governor.c | 4 +-- drivers/base/power/qos.c | 10 +++--- drivers/base/power/runtime.c | 2 +- drivers/cpuidle/governor.c | 2 +- include/linux/pm_qos.h | 41 +++++++++++++++++------- 6 files changed, 40 insertions(+), 21 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt index ec7d662d1707..cfcb1df39799 100644 --- a/Documentation/power/pm_qos_interface.txt +++ b/Documentation/power/pm_qos_interface.txt @@ -123,7 +123,7 @@ Will remove the element. After removal it will update the aggregate target and call the notification trees if the target was changed as a result of removing the request. -s32 dev_pm_qos_read_value(device): +s32 dev_pm_qos_read_value(device, type): Returns the aggregated value for a given device's constraints list. enum pm_qos_flags_status dev_pm_qos_flags(device, mask) diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 99896fbf18e4..c36925adba69 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -32,7 +32,7 @@ static int dev_update_qos_constraint(struct device *dev, void *data) * take its current PM QoS constraint (that's the only thing * known at this point anyway). */ - constraint_ns = dev_pm_qos_read_value(dev); + constraint_ns = dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY); constraint_ns *= NSEC_PER_USEC; } @@ -65,7 +65,7 @@ static bool default_suspend_ok(struct device *dev) td->constraint_changed = false; td->cached_suspend_ok = false; td->effective_constraint_ns = 0; - constraint_ns = __dev_pm_qos_read_value(dev); + constraint_ns = __dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY); spin_unlock_irqrestore(&dev->power.lock, flags); diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index 49672f9dc8c4..fda7266970e9 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -96,27 +96,29 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_flags); /** * __dev_pm_qos_read_value - Get PM QoS constraint for a given device. * @dev: Device to get the PM QoS constraint value for. + * @type: QoS request type. * * This routine must be called with dev->power.lock held. */ -s32 __dev_pm_qos_read_value(struct device *dev) +s32 __dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type) { lockdep_assert_held(&dev->power.lock); - return dev_pm_qos_raw_read_value(dev); + return dev_pm_qos_raw_read_value(dev, type); } /** * dev_pm_qos_read_value - Get PM QoS constraint for a given device (locked). * @dev: Device to get the PM QoS constraint value for. + * @type: QoS request type. */ -s32 dev_pm_qos_read_value(struct device *dev) +s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type) { unsigned long flags; s32 ret; spin_lock_irqsave(&dev->power.lock, flags); - ret = __dev_pm_qos_read_value(dev); + ret = __dev_pm_qos_read_value(dev, type); spin_unlock_irqrestore(&dev->power.lock, flags); return ret; diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 04407d9f76fd..997cd420accc 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -267,7 +267,7 @@ static int rpm_check_suspend_allowed(struct device *dev) || (dev->power.request_pending && dev->power.request == RPM_REQ_RESUME)) retval = -EAGAIN; - else if (__dev_pm_qos_read_value(dev) == 0) + else if (__dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY) == 0) retval = -EPERM; else if (dev->power.runtime_status == RPM_SUSPENDED) retval = 1; diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c index bb93e5cf6a4a..251d3ef4a1e5 100644 --- a/drivers/cpuidle/governor.c +++ b/drivers/cpuidle/governor.c @@ -109,7 +109,7 @@ int cpuidle_governor_latency_req(unsigned int cpu) { int global_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); struct device *device = get_cpu_device(cpu); - int device_req = dev_pm_qos_raw_read_value(device); + int device_req = dev_pm_qos_raw_read_value(device, DEV_PM_QOS_RESUME_LATENCY); return device_req < global_req ? device_req : global_req; } diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 1f4d456e8fff..55814d48c39c 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -139,8 +139,8 @@ s32 pm_qos_read_value(struct pm_qos_constraints *c); #ifdef CONFIG_PM enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, s32 mask); enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, s32 mask); -s32 __dev_pm_qos_read_value(struct device *dev); -s32 dev_pm_qos_read_value(struct device *dev); +s32 __dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type); +s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type); int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, enum dev_pm_qos_req_type type, s32 value); int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value); @@ -176,11 +176,19 @@ static inline s32 dev_pm_qos_requested_flags(struct device *dev) return dev->power.qos->flags_req->data.flr.flags; } -static inline s32 dev_pm_qos_raw_read_value(struct device *dev) +static inline s32 dev_pm_qos_raw_read_value(struct device *dev, + enum dev_pm_qos_req_type type) { - return IS_ERR_OR_NULL(dev->power.qos) ? - PM_QOS_RESUME_LATENCY_NO_CONSTRAINT : - pm_qos_read_value(&dev->power.qos->resume_latency); + struct dev_pm_qos *qos = dev->power.qos; + + switch (type) { + case DEV_PM_QOS_RESUME_LATENCY: + return IS_ERR_OR_NULL(qos) ? PM_QOS_RESUME_LATENCY_NO_CONSTRAINT + : pm_qos_read_value(&qos->resume_latency); + default: + WARN_ON(1); + return 0; + } } #else static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, @@ -189,10 +197,6 @@ static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, static inline enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, s32 mask) { return PM_QOS_FLAGS_UNDEFINED; } -static inline s32 __dev_pm_qos_read_value(struct device *dev) - { return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } -static inline s32 dev_pm_qos_read_value(struct device *dev) - { return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } static inline int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, enum dev_pm_qos_req_type type, @@ -245,10 +249,23 @@ static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev) return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; } -static inline s32 dev_pm_qos_raw_read_value(struct device *dev) + +static inline s32 dev_pm_qos_raw_read_value(struct device *dev, + enum dev_pm_qos_req_type type) { - return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; + switch type { + case DEV_PM_QOS_RESUME_LATENCY: + return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; + default: + WARN_ON(1); + return 0; + } } + +static inline s32 __dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type) + { return dev_pm_qos_raw_read_value(dev, type); } +static inline s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type) + { return dev_pm_qos_raw_read_value(dev, type); } #endif #endif From patchwork Thu Feb 21 11:29:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 158905 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp373249jaa; Thu, 21 Feb 2019 03:30:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IaxuvA37V2vAW7DVrR/zE4nW4UgCys8kCkjZVgzVyWTY8Xyng69eWjQpYIh8L6GiFhSYWjY X-Received: by 2002:a17:902:7614:: with SMTP id k20mr25771017pll.298.1550748602139; Thu, 21 Feb 2019 03:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550748602; cv=none; d=google.com; s=arc-20160816; b=mbMSLgdXPSOp/6vh2CVKOnPaea/ATergWHvwig33AvBFZAIfnKZ627U5GQy2jKHB5u EjU6CMgQEtN4/hETPb+NZKa6IjUH+hkClALzcK/mUiDqjoXjicO4JRqYyPPPd4JOiv25 RxUnfs67DUayAbp1e6jMFI/APZzn8h6xLQeftPsAJSToAQzUBR4hAKr6rf0Q92wflU+c Byr78zq02X+azrzh9hWNlm7W6Ey0Xkhp/b7ti25tWDAREE3R04ilwCLYLf7mJ0Boq8OB hv7ZBI6kMfj/htk3x58Nopnd/tIkbRaM7prGYx+g0Tlvn5GiAtWv6wd2MpQWzdLRiab9 XESg== 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=HUSOtrKC0cvgq0LNDb8X2IQi37D42NUAt00uzjw6vNU=; b=Zua+ybv1UHGzwiFYc7ABA6/B+RRbAEJn2BbZiiEZICuF210zbJv0pQ/HIZNRDzC8xM PHKj4rPiWAvOvLsBLXZ9pcZCxQrLfnM7Eq7gbTtf3RLdVob51MNddKLD084gfwA8/50u dAhwEnQnYAyJmOq/YxzgBwD/4kVs8lpyHQ++O3H4H2Z4NyvxsYYnxSLXxpKwXJYapIJm wZ5Oqjs3UsUqY41KWEe5uL0iiiT5kPQRpVFL7TtreKjjbldwH/A9ccdphvfVJ+Ed+0Qr wrv/57zTVzn837+Qhj8poTKf9TQ9Q0MxoGbs8EbAQDx4b+WuB2DhCrie85cSY8pGsSW0 Da/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=knkqd6Qc; 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 l16si20997463pfb.68.2019.02.21.03.30.01; Thu, 21 Feb 2019 03:30:02 -0800 (PST) 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=knkqd6Qc; 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 S1726839AbfBULaB (ORCPT + 11 others); Thu, 21 Feb 2019 06:30:01 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39706 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727531AbfBUL37 (ORCPT ); Thu, 21 Feb 2019 06:29:59 -0500 Received: by mail-pl1-f196.google.com with SMTP id 101so14045748pld.6 for ; Thu, 21 Feb 2019 03:29:59 -0800 (PST) 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=HUSOtrKC0cvgq0LNDb8X2IQi37D42NUAt00uzjw6vNU=; b=knkqd6Qc6jhM3C6HkRhK0/1smujaW0vqStekQ6oQB0TS7nJlnyGIja7CsK4cuKj/xD M9Mg4EAIsd+gKPA/F2yZBXkXq975oIkd9pKL4M2TBhNjaElkLPHZj0lb+uL9ORop4CJ5 p4PGV9SykN4Syt07PdGwHR3imdqCksGG0QiTUCGrWZrMxwtEACkrIBb1XmMKsJAH1VzM UszuZ4ydcV6Y5mWlYuGtECgyPHvI1yneLw7cVVzswPvT/jwWx2d66i6Qx7KmLhJ/PpSV sT5J1AQg7WhyFBm9A1qHUMLYcCVrETBn5eyoDaEnFr/quEgurhAaZEQP1CpXoEhuar2K Qg9w== 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=HUSOtrKC0cvgq0LNDb8X2IQi37D42NUAt00uzjw6vNU=; b=P9xb/EU3CdalgxuqSxz4LA53fxE0GAovuE7pa2lqxM/XqSSVGqHiRGoFgD/J4jDgIU Hue32NAQWEYUUz4IKWAy2AHycEdGXxRXonNQlBOdv1LUb+7/Fpbe5a1aQQWQYde7TGfU Oi6CDOOpqFSKK+wnM3idX+GrhNnyhlBZN2R42KUsXMuEAA8UuOZPBzjc1xuy1gh4lvxb L3NeC4kiHjI1VJDiLKDrtq3pF2b1txGWKze8HeprxXrsbD7y+ED5W6PoyeUU7jBEyzTv 7vdP8UpZLrDsiXRZGscrsjXJo/7buOURXy0SyYdTbPrzUwaq+nSlcGKCROAve2F5ZF1d V8MA== X-Gm-Message-State: AHQUAuaIb3GD4Vh9FHEDV045LfMq/2+YtWpipJG6BOfJDCNBJ7/POBB/ icHc3DrvpAkDaJpuJySpqgkbiSWmWsE= X-Received: by 2002:a17:902:aa06:: with SMTP id be6mr21663518plb.57.1550748598779; Thu, 21 Feb 2019 03:29:58 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id h64sm6614216pfj.40.2019.02.21.03.29.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:29:58 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , mka@chromium.org, juri.lelli@gmail.com, Qais.Yousef@arm.com, linux-kernel@vger.kernel.org Subject: [PATCH V2 4/5] cpufreq: Register notifiers with the PM QoS framework Date: Thu, 21 Feb 2019 16:59:30 +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 registers the notifiers for min/max frequency constraints with the PM QoS framework. The constraints are also taken into consideration in cpufreq_set_policy(). This also relocates cpufreq_policy_put_kobj() as it is required to be called from cpufreq_policy_alloc() now. No constraints are added until now though. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 135 +++++++++++++++++++++++++++++++------- include/linux/cpufreq.h | 4 ++ 2 files changed, 116 insertions(+), 23 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0e626b00053b..d615bf35ac00 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1082,11 +1083,77 @@ static void handle_update(struct work_struct *work) cpufreq_update_policy(cpu); } +static void cpufreq_update_freq_work(struct work_struct *work) +{ + struct cpufreq_policy *policy = + container_of(work, struct cpufreq_policy, req_work); + struct cpufreq_policy new_policy = *policy; + + /* We should read constraint values from QoS layer */ + new_policy.min = 0; + new_policy.max = UINT_MAX; + + down_write(&policy->rwsem); + + if (!policy_is_inactive(policy)) + cpufreq_set_policy(policy, &new_policy); + + up_write(&policy->rwsem); +} + +static int cpufreq_update_freq(struct cpufreq_policy *policy) +{ + schedule_work(&policy->req_work); + return 0; +} + +static int cpufreq_notifier_min(struct notifier_block *nb, unsigned long freq, + void *data) +{ + struct cpufreq_policy *policy = container_of(nb, struct cpufreq_policy, nb_min); + + return cpufreq_update_freq(policy); +} + +static int cpufreq_notifier_max(struct notifier_block *nb, unsigned long freq, + void *data) +{ + struct cpufreq_policy *policy = container_of(nb, struct cpufreq_policy, nb_max); + + return cpufreq_update_freq(policy); +} + +static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy) +{ + struct kobject *kobj; + struct completion *cmp; + + down_write(&policy->rwsem); + cpufreq_stats_free_table(policy); + kobj = &policy->kobj; + cmp = &policy->kobj_unregister; + up_write(&policy->rwsem); + kobject_put(kobj); + + /* + * We need to make sure that the underlying kobj is + * actually not referenced anymore by anybody before we + * proceed with unloading. + */ + pr_debug("waiting for dropping of refcount\n"); + wait_for_completion(cmp); + pr_debug("wait complete\n"); +} + static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) { struct cpufreq_policy *policy; + struct device *dev = get_cpu_device(cpu); int ret; + if (!dev) + return NULL; + policy = kzalloc(sizeof(*policy), GFP_KERNEL); if (!policy) return NULL; @@ -1103,20 +1170,45 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, cpufreq_global_kobject, "policy%u", cpu); if (ret) { - pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret); + dev_err(dev, "%s: failed to init policy->kobj: %d\n", __func__, ret); goto err_free_real_cpus; } + policy->nb_min.notifier_call = cpufreq_notifier_min; + policy->nb_max.notifier_call = cpufreq_notifier_max; + + ret = dev_pm_qos_add_notifier(dev, &policy->nb_min, + DEV_PM_QOS_MIN_FREQUENCY); + if (ret) { + dev_err(dev, "Failed to register MIN QoS notifier: %d (%*pbl)\n", + ret, cpumask_pr_args(policy->cpus)); + goto err_kobj_remove; + } + + ret = dev_pm_qos_add_notifier(dev, &policy->nb_max, + DEV_PM_QOS_MAX_FREQUENCY); + if (ret) { + dev_err(dev, "Failed to register MAX QoS notifier: %d (%*pbl)\n", + ret, cpumask_pr_args(policy->cpus)); + goto err_min_qos_notifier; + } + INIT_LIST_HEAD(&policy->policy_list); init_rwsem(&policy->rwsem); spin_lock_init(&policy->transition_lock); init_waitqueue_head(&policy->transition_wait); init_completion(&policy->kobj_unregister); INIT_WORK(&policy->update, handle_update); + INIT_WORK(&policy->req_work, cpufreq_update_freq_work); policy->cpu = cpu; return policy; +err_min_qos_notifier: + dev_pm_qos_remove_notifier(dev, &policy->nb_min, + DEV_PM_QOS_MIN_FREQUENCY); +err_kobj_remove: + cpufreq_policy_put_kobj(policy); err_free_real_cpus: free_cpumask_var(policy->real_cpus); err_free_rcpumask: @@ -1129,30 +1221,9 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) return NULL; } -static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy) -{ - struct kobject *kobj; - struct completion *cmp; - - down_write(&policy->rwsem); - cpufreq_stats_free_table(policy); - kobj = &policy->kobj; - cmp = &policy->kobj_unregister; - up_write(&policy->rwsem); - kobject_put(kobj); - - /* - * We need to make sure that the underlying kobj is - * actually not referenced anymore by anybody before we - * proceed with unloading. - */ - pr_debug("waiting for dropping of refcount\n"); - wait_for_completion(cmp); - pr_debug("wait complete\n"); -} - static void cpufreq_policy_free(struct cpufreq_policy *policy) { + struct device *dev = get_cpu_device(policy->cpu); unsigned long flags; int cpu; @@ -1164,6 +1235,10 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) per_cpu(cpufreq_cpu_data, cpu) = NULL; write_unlock_irqrestore(&cpufreq_driver_lock, flags); + dev_pm_qos_remove_notifier(dev, &policy->nb_max, + DEV_PM_QOS_MAX_FREQUENCY); + dev_pm_qos_remove_notifier(dev, &policy->nb_min, + DEV_PM_QOS_MIN_FREQUENCY); cpufreq_policy_put_kobj(policy); free_cpumask_var(policy->real_cpus); free_cpumask_var(policy->related_cpus); @@ -2239,6 +2314,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, struct cpufreq_policy *new_policy) { struct cpufreq_governor *old_gov; + struct device *cpu_dev = get_cpu_device(policy->cpu); + unsigned long min, max; int ret; pr_debug("setting new policy for CPU %u: %u - %u kHz\n", @@ -2253,11 +2330,23 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, if (new_policy->min > new_policy->max) return -EINVAL; + min = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MIN_FREQUENCY); + max = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MAX_FREQUENCY); + + if (min > new_policy->min) + new_policy->min = min; + if (max < new_policy->max) + new_policy->max = max; + /* verify the cpu speed can be set within this limit */ ret = cpufreq_driver->verify(new_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); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index b160e98076e3..f8f48d8a9b52 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -90,6 +90,7 @@ struct cpufreq_policy { struct work_struct update; /* if update_policy() needs to be * called, but you're in IRQ context */ + struct work_struct req_work; struct cpufreq_user_policy user_policy; struct cpufreq_frequency_table *freq_table; @@ -154,6 +155,9 @@ struct cpufreq_policy { /* Pointer to the cooling device if used for thermal mitigation */ struct thermal_cooling_device *cdev; + + struct notifier_block nb_min; + struct notifier_block nb_max; }; /* Only for ACPI */ From patchwork Thu Feb 21 11:29:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 158907 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp373349jaa; Thu, 21 Feb 2019 03:30:08 -0800 (PST) X-Google-Smtp-Source: AHgI3IY4anHV0iOX3UBSk5wsxrN0vx3IaraI/30OWZ0yn8P6j+erGHL5TyAwQu+gXRY2jKApGMEj X-Received: by 2002:a63:5b48:: with SMTP id l8mr34076742pgm.80.1550748608672; Thu, 21 Feb 2019 03:30:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550748608; cv=none; d=google.com; s=arc-20160816; b=ApO3fY7+k+f6fLY7nkbOFcq+TdthzjZuAAa7pXnOD/wOap6v5u8mqP7QxeuTtXKIcC ZnmMCVucdDNZl8WDdG0t3T9n1bHt3TX0qZ19tmXvUFfCP+L3mk0rxhIyC0WuqqKKHJ8o PErjpiL8MZzP7KzQuozfVY65dka56xXk3YR/XqD9OpX6jDnsyaEs3kfNMLHnEQU9s+p8 87NaUI37EEudia2Wg1HnXJUR61gghFPnwhQHGmhh39vtoXgXqWOiA4WTxJz49GRqHLRg ut0aQizYbdXwoTd0BDhjXVdji49duZoqo78tkRCWNSEaAEtchPm0Uwh/qJL//Ti+PdYb jvhg== 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=v8CWopyixq34AiRgOm8puxabKKI7UFBsPsA1o/X8rdw=; b=oeIn6fURuh6P6K0Yw0rJdg7ATzf4h/rNDtrP5DNiZF41MJ5avO/qFg+LAXL/qUbaVQ pxLO7keg5ZzilLYJojOnYxpFWl/R+DFuLltBA+l+ECbg9JRqBjUol8wHnyTwA+1T9dFD vXoiWYvqWhWoI8bowcG1bzVtmI75RAd8+A6UTPkKUsisyRXKcOQyYhotGZOLbykGLTBC NfGh7WWY+sRuqPNW8xFwOk7TjNXvZivT52zRclONVtE2EPoqOwmsWUO4sU8rbj9ENVaG MJVxTsCEkSIuF9/GLV5pSULePfW3KX0mlBOdxgdsyF5M/tE521jymnMD3g7Vop3EREEv 3ILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X4q3uxq4; 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 s2si15173242plq.345.2019.02.21.03.30.08; Thu, 21 Feb 2019 03:30:08 -0800 (PST) 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=X4q3uxq4; 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 S1727674AbfBULaH (ORCPT + 11 others); Thu, 21 Feb 2019 06:30:07 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38613 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbfBULaC (ORCPT ); Thu, 21 Feb 2019 06:30:02 -0500 Received: by mail-pg1-f195.google.com with SMTP id m2so11391684pgl.5 for ; Thu, 21 Feb 2019 03:30:02 -0800 (PST) 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=v8CWopyixq34AiRgOm8puxabKKI7UFBsPsA1o/X8rdw=; b=X4q3uxq4IzX2nBwYAJ50GcQ1s3yTiujwomaPRHq5eND/2R+cmLJsBGOssA/DBCXumW 6IdEe5G6ZeIezl5yQPiRNcSd/EifLpOWlFjzSn4zZUbx9Z2ZwlnbJuv9fbqBKmt6ww/i YEg39FzuZMt7f+QLdTNCj5+NDBCLV3u4sxR26hyhS16+S3Sf6YEn9CuFaQRXjK+Yx0It a1ysOeHW1+3ZsIHVxVXk5dXdXuirAPnLzQhr3vQt+vEj03NuJfJICThHkiHb9BMp94Ch Y0Q9PXqatJpVkytpMa2KiPjNRxHWEhXGj/dGpLoA9N/3qHPZePCHSGlTG8+ZuzlbteDI M+bQ== 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=v8CWopyixq34AiRgOm8puxabKKI7UFBsPsA1o/X8rdw=; b=T/rnoXTrnVY1dTp8rb1mnNwyijllxzdyF2Jq6LRWft3wPi+koKGqo7WrmEZgRHM8v9 u2BnEJ1sJXJ6wUZAxhHvDcrxFaQHXvZVB9smCVsGyRrW+FRbEpWMt2D6uOohSDePEVer nl4+0/9A0JPQyalHnd6wAKpSItdye5EBV27soQW9IqeL5nZXxYixbablxqjL2nxvljEg W/0U1PgHXNUU8N4Zrj5OxAgd8fs6TbIiydehiq6mjtU8wPoH/ORbJMAFHfAEk/5cWiqb N7c76P7Zk5dMWG5s9qZUL3wPq9blZnGaRMrizriL2VD6HanbxrZP0UrnxskQFW8baL89 sjyA== X-Gm-Message-State: AHQUAubNWAfrNvSK7kdDXP90bWB5sVm7/LD0QH/CgVQGuJedLy6H6r7v Gwx7vZtRFoUFbr3eIfF8HtR8GQ== X-Received: by 2002:a62:36c7:: with SMTP id d190mr28587428pfa.178.1550748601816; Thu, 21 Feb 2019 03:30:01 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id y21sm35862030pfi.150.2019.02.21.03.30.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:30:00 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , mka@chromium.org, juri.lelli@gmail.com, Qais.Yousef@arm.com, linux-kernel@vger.kernel.org Subject: [PATCH V2 5/5] cpufreq: Add QoS requests for userspace constraints Date: Thu, 21 Feb 2019 16:59:31 +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 implements QoS requests to manage userspace configuration of min and max frequency. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 93 +++++++++++++++++++-------------------- include/linux/cpufreq.h | 8 +--- 2 files changed, 48 insertions(+), 53 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d615bf35ac00..403e4540aea7 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -686,23 +686,15 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, static ssize_t store_##file_name \ (struct cpufreq_policy *policy, const char *buf, size_t count) \ { \ - int ret, temp; \ - struct cpufreq_policy new_policy; \ + unsigned long val; \ + int ret; \ \ - memcpy(&new_policy, policy, sizeof(*policy)); \ - new_policy.min = policy->user_policy.min; \ - new_policy.max = policy->user_policy.max; \ - \ - ret = sscanf(buf, "%u", &new_policy.object); \ + ret = sscanf(buf, "%lu", &val); \ if (ret != 1) \ return -EINVAL; \ \ - temp = new_policy.object; \ - ret = cpufreq_set_policy(policy, &new_policy); \ - if (!ret) \ - policy->user_policy.object = temp; \ - \ - return ret ? ret : count; \ + ret = dev_pm_qos_update_request(policy->object##_freq_req, val);\ + return ret && ret != 1 ? ret : count; \ } store_one(scaling_min_freq, min); @@ -1089,10 +1081,6 @@ static void cpufreq_update_freq_work(struct work_struct *work) container_of(work, struct cpufreq_policy, req_work); struct cpufreq_policy new_policy = *policy; - /* We should read constraint values from QoS layer */ - new_policy.min = 0; - new_policy.max = UINT_MAX; - down_write(&policy->rwsem); if (!policy_is_inactive(policy)) @@ -1193,6 +1181,12 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) goto err_min_qos_notifier; } + policy->min_freq_req = kzalloc(2 * sizeof(*policy->min_freq_req), + GFP_KERNEL); + if (!policy->min_freq_req) + goto err_max_qos_notifier; + + policy->max_freq_req = policy->min_freq_req + 1; INIT_LIST_HEAD(&policy->policy_list); init_rwsem(&policy->rwsem); spin_lock_init(&policy->transition_lock); @@ -1204,6 +1198,9 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) policy->cpu = cpu; return policy; +err_max_qos_notifier: + dev_pm_qos_remove_notifier(dev, &policy->nb_max, + DEV_PM_QOS_MAX_FREQUENCY); err_min_qos_notifier: dev_pm_qos_remove_notifier(dev, &policy->nb_min, DEV_PM_QOS_MIN_FREQUENCY); @@ -1239,6 +1236,10 @@ 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); + dev_pm_qos_remove_request(policy->min_freq_req); + kfree(policy->min_freq_req); + cpufreq_policy_put_kobj(policy); free_cpumask_var(policy->real_cpus); free_cpumask_var(policy->related_cpus); @@ -1316,16 +1317,30 @@ static int cpufreq_online(unsigned int cpu) cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); if (new_policy) { - policy->user_policy.min = policy->min; - policy->user_policy.max = policy->max; + struct device *dev = get_cpu_device(cpu); for_each_cpu(j, policy->related_cpus) { per_cpu(cpufreq_cpu_data, j) = policy; add_cpu_dev_symlink(policy, j); } - } else { - policy->min = policy->user_policy.min; - policy->max = policy->user_policy.max; + + ret = dev_pm_qos_add_request(dev, policy->min_freq_req, + DEV_PM_QOS_MIN_FREQUENCY, + policy->min); + if (ret < 0) { + dev_err(dev, "Failed to add min-freq constraint (%d)\n", + ret); + goto out_destroy_policy; + } + + ret = dev_pm_qos_add_request(dev, policy->max_freq_req, + DEV_PM_QOS_MAX_FREQUENCY, + policy->max); + if (ret < 0) { + dev_err(dev, "Failed to add max-freq constraint (%d)\n", + ret); + goto out_destroy_policy; + } } if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { @@ -2315,7 +2330,6 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, { struct cpufreq_governor *old_gov; struct device *cpu_dev = get_cpu_device(policy->cpu); - unsigned long min, max; int ret; pr_debug("setting new policy for CPU %u: %u - %u kHz\n", @@ -2323,20 +2337,9 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, memcpy(&new_policy->cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo)); - /* - * This check works well when we store new min/max freq attributes, - * because new_policy is a copy of policy with one field updated. - */ - if (new_policy->min > new_policy->max) - return -EINVAL; - - min = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MIN_FREQUENCY); - max = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MAX_FREQUENCY); - - if (min > new_policy->min) - new_policy->min = min; - if (max < new_policy->max) - new_policy->max = max; + /* Start with min/max as seen by QoS framework */ + new_policy->min = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MIN_FREQUENCY); + new_policy->max = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MAX_FREQUENCY); /* verify the cpu speed can be set within this limit */ ret = cpufreq_driver->verify(new_policy); @@ -2425,10 +2428,9 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, * @cpu: CPU to re-evaluate the policy for. * * Update the current frequency for the cpufreq policy of @cpu and use - * cpufreq_set_policy() to re-apply the min and max limits saved in the - * user_policy sub-structure of that policy, which triggers the evaluation - * of policy notifiers and the cpufreq driver's ->verify() callback for the - * policy in question, among other things. + * cpufreq_set_policy() to re-apply the min and max limits, which triggers the + * evaluation of policy notifiers and the cpufreq driver's ->verify() callback + * for the policy in question, among other things. */ void cpufreq_update_policy(unsigned int cpu) { @@ -2453,8 +2455,6 @@ void cpufreq_update_policy(unsigned int cpu) pr_debug("updating policy for CPU %u\n", cpu); memcpy(&new_policy, policy, sizeof(*policy)); - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; cpufreq_set_policy(policy, &new_policy); @@ -2485,10 +2485,9 @@ static int cpufreq_boost_set_sw(int state) break; } - down_write(&policy->rwsem); - policy->user_policy.max = policy->max; - cpufreq_governor_limits(policy); - up_write(&policy->rwsem); + ret = dev_pm_qos_update_request(policy->max_freq_req, policy->max); + if (ret) + break; } return ret; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index f8f48d8a9b52..fc167a982c64 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -57,11 +57,6 @@ struct cpufreq_cpuinfo { unsigned int transition_latency; }; -struct cpufreq_user_policy { - unsigned int min; /* in kHz */ - unsigned int max; /* in kHz */ -}; - struct cpufreq_policy { /* CPUs sharing clock, require sw coordination */ cpumask_var_t cpus; /* Online CPUs only */ @@ -92,7 +87,8 @@ struct cpufreq_policy { * called, but you're in IRQ context */ struct work_struct req_work; - struct cpufreq_user_policy user_policy; + struct dev_pm_qos_request *min_freq_req; + struct dev_pm_qos_request *max_freq_req; struct cpufreq_frequency_table *freq_table; enum cpufreq_table_sorting freq_table_sorted;