From patchwork Thu Jul 4 07:36:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168461 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1921516ilk; Thu, 4 Jul 2019 00:36:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqywEMNHNvaXC5Up2qUD5DyiB0KNt8fdjakzvHqQRhIDDxgLqlILHc95zmseXQiO5+pdWy4u X-Received: by 2002:a63:6f8d:: with SMTP id k135mr42224943pgc.118.1562225795275; Thu, 04 Jul 2019 00:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225795; cv=none; d=google.com; s=arc-20160816; b=NcIuK1RCajSkxQaI1J7AIhJ5TnP1Fm75rGgy11nfsto7otV0+3xu6JN4Y5vvNcJTZK S+I07fIPUqelDcgm9wTgcRULmHv1HZ9OJQpFHhO7BcAIkslXtVF+32to4tjnfd3ULdNf pXgLtNICrV77ixn4g5RFXJ+hSDm7fg01pqAJUco4UivaHb4O68EZUPttfyhQkpsb6hGJ 5YJ357EOOR8Qnnma0n48kSSjWj+LfOzistMKVuNtVbjQlBL5f5APKxMa0YkqBrTtnLlk xsUkCrvZOiV10qJgizU0oRd2XeL7Z2QoqJjKZHX/Vjj908ldeUwf1w+sXbEHdCC4L4Dh 8oQg== 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=WTgpiIcLb6LZ7kKRAHE/t5osUD04AJZqzwEpAbBmdVE=; b=ix46toO5hXgyLku6Zx1/4Nlrv3vgNgt69Y3X4ym6uoZWWqGJ3HXM9KvftOFUm6wIGU 6fNFsIczOgBE6DCFWP3krS2Lzw/AVti9hHD4lGuM5IYD1zP86YELKXfpuoTTUip5/IcV vSpU/G3xv0d6xMqqvYQ0JkLYiLHwy9N3g8DvlmK56y+J5pQyjOWwJC0fevFTuAXI9GwF LZ2o6elynGxMeSgqA2t3RyzMV8zYN1IrrJ/Tv+c2g0V+fKuw684ITldtl5YZsX2FC7YJ TuraoqglWpv1UexyapIUxrrLlwIgzjuLqvWYjH12OEvpZjanZjtWsxzBhCIHhanppBz6 49Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wcY1CstA; 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; 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 71si4661093plf.156.2019.07.04.00.36.35; Thu, 04 Jul 2019 00:36:35 -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; dkim=pass header.i=@linaro.org header.s=google header.b=wcY1CstA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727487AbfGDHge (ORCPT + 30 others); Thu, 4 Jul 2019 03:36:34 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40853 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727463AbfGDHgd (ORCPT ); Thu, 4 Jul 2019 03:36:33 -0400 Received: by mail-pf1-f194.google.com with SMTP id p184so2525000pfp.7 for ; Thu, 04 Jul 2019 00:36:32 -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=WTgpiIcLb6LZ7kKRAHE/t5osUD04AJZqzwEpAbBmdVE=; b=wcY1CstAe36rGAs6ARiqZY4Evmc98ij+sTeUeI+jgm9LTWX/SN57Vqjm4CGfU5hudJ 16/+dlH0YOzBIbZ8Ki/iGgN7UZxYEtpimbdmhMtAYkuxWVYC42lgFZrXQlJl9Wjq+nfw cY5G5XZndyJ9yniTl6RrP8zqoMTQSz2tLtOuJ0rctE2NxPjj/1PqZYhUSpQCXoFFAMl8 jZo+yqA0THUt+2V2RECEGVXWT9dF5DRTag97WZ3kYh1HXrKKiXjs5fesR8HLWQhAwbRg EgMjdmgkkkbwrQYHyVdNp1jN7kqTfYf9gK0tyF5LWmYQ2j2JwnHGMAidJe0BFUeiAOpW fCOg== 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=WTgpiIcLb6LZ7kKRAHE/t5osUD04AJZqzwEpAbBmdVE=; b=JZtnuID7SGZ9ZWJaOo77dcBVcaT7a35Yz644an9HY4JJdedr8k1oiiStFCxT8GflX5 eWvh9lIAQukrRIOSRkKb4JQE7Awq3PmoXCH2lHBd7bg+fxV34qEDrtEDrDzfZBCAGQZd eZW6Eb/TEcwpjr6y1y9YjOB3lGIfYQPp/VrClGWi7ZgpuYRCRaxIiuNU3xfB3rwHby8w 6/NplCmD8xArsdBSpLKTxSOy68H1BwHLff85Vpm1Kj7+jRdZqDfheSqRAecPp6Fpfb6d 0K5r9FjPjAcm/GD50TANgAne4Axju/z8AoCWiEP2E144SdzNYhWlKKbczksHgyv0WS0N dcag== X-Gm-Message-State: APjAAAULrZhgnsVkzmIYQHaAB7NDdUMwG74CtcpBYrtRASZCxXq4Di8Q 8h0/cYs4VsYGeGDJ0zm8pR463g== X-Received: by 2002:a63:1a5c:: with SMTP id a28mr41931043pgm.418.1562225792243; Thu, 04 Jul 2019 00:36:32 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id r188sm7379288pfr.16.2019.07.04.00.36.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 00:36:31 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Matthias Kaehlcke , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH V6 1/7] PM / QOS: Pass request type to dev_pm_qos_{add|remove}_notifier() Date: Thu, 4 Jul 2019 13:06:17 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to use the same set of routines to register notifiers for different request types, update the existing dev_pm_qos_{add|remove}_notifier() routines with an additional parameter: request-type. For now, it only supports resume-latency request type but will be extended to frequency limit (min/max) constraints later on. Reviewed-by: Matthias Kaehlcke Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- Documentation/power/pm_qos_interface.txt | 10 ++++++---- drivers/base/power/domain.c | 8 +++++--- drivers/base/power/qos.c | 14 ++++++++++++-- include/linux/pm_qos.h | 12 ++++++++---- 4 files changed, 31 insertions(+), 13 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt index 19c5f7b1a7ba..ec7d662d1707 100644 --- a/Documentation/power/pm_qos_interface.txt +++ b/Documentation/power/pm_qos_interface.txt @@ -164,12 +164,14 @@ directory. Notification mechanisms: The per-device PM QoS framework has a per-device notification tree. -int dev_pm_qos_add_notifier(device, notifier): -Adds a notification callback function for the device. +int dev_pm_qos_add_notifier(device, notifier, type): +Adds a notification callback function for the device for a particular request +type. + The callback is called when the aggregated value of the device constraints list -is changed (for resume latency device PM QoS only). +is changed. -int dev_pm_qos_remove_notifier(device, notifier): +int dev_pm_qos_remove_notifier(device, notifier, type): Removes the notification callback function for the device. diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 33c30c1e6a30..b063bc41b0a9 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1536,7 +1536,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (ret) genpd_free_dev_data(dev, gpd_data); else - dev_pm_qos_add_notifier(dev, &gpd_data->nb); + dev_pm_qos_add_notifier(dev, &gpd_data->nb, + DEV_PM_QOS_RESUME_LATENCY); return ret; } @@ -1569,7 +1570,8 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, pdd = dev->power.subsys_data->domain_data; gpd_data = to_gpd_data(pdd); - dev_pm_qos_remove_notifier(dev, &gpd_data->nb); + dev_pm_qos_remove_notifier(dev, &gpd_data->nb, + DEV_PM_QOS_RESUME_LATENCY); genpd_lock(genpd); @@ -1597,7 +1599,7 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, out: genpd_unlock(genpd); - dev_pm_qos_add_notifier(dev, &gpd_data->nb); + dev_pm_qos_add_notifier(dev, &gpd_data->nb, DEV_PM_QOS_RESUME_LATENCY); return ret; } diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index 6c91f8df1d59..cfd463212513 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -467,6 +467,7 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_remove_request); * * @dev: target device for the constraint * @notifier: notifier block managed by caller. + * @type: request type. * * Will register the notifier into a notification chain that gets called * upon changes to the target value for the device. @@ -474,10 +475,14 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_remove_request); * If the device's constraints object doesn't exist when this routine is called, * it will be created (or error code will be returned if that fails). */ -int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier) +int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier, + enum dev_pm_qos_req_type type) { 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)) @@ -500,15 +505,20 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_add_notifier); * * @dev: target device for the constraint * @notifier: notifier block to be removed. + * @type: request type. * * Will remove the notifier from the notification chain that gets called * upon changes to the target value. */ int dev_pm_qos_remove_notifier(struct device *dev, - struct notifier_block *notifier) + 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; + mutex_lock(&dev_pm_qos_mtx); /* Silently return if the constraints object is not present. */ diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 6ea1ae373d77..58e8749ceac5 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -146,9 +146,11 @@ int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value); int dev_pm_qos_remove_request(struct dev_pm_qos_request *req); int dev_pm_qos_add_notifier(struct device *dev, - struct notifier_block *notifier); + struct notifier_block *notifier, + enum dev_pm_qos_req_type type); int dev_pm_qos_remove_notifier(struct device *dev, - struct notifier_block *notifier); + struct notifier_block *notifier, + enum dev_pm_qos_req_type type); void dev_pm_qos_constraints_init(struct device *dev); void dev_pm_qos_constraints_destroy(struct device *dev); int dev_pm_qos_add_ancestor_request(struct device *dev, @@ -202,10 +204,12 @@ static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req, static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req) { return 0; } static inline int dev_pm_qos_add_notifier(struct device *dev, - struct notifier_block *notifier) + struct notifier_block *notifier, + enum dev_pm_qos_req_type type) { return 0; } static inline int dev_pm_qos_remove_notifier(struct device *dev, - struct notifier_block *notifier) + struct notifier_block *notifier, + enum dev_pm_qos_req_type type) { return 0; } static inline void dev_pm_qos_constraints_init(struct device *dev) { From patchwork Thu Jul 4 07:36:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168462 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1921570ilk; Thu, 4 Jul 2019 00:36:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy+UBdsjHKlqGtpccYJFffibZJS6NsTeuUQTiuPilQYH0tFmwa1ode2qRa6bDM1ih8WG72 X-Received: by 2002:a63:494d:: with SMTP id y13mr1748868pgk.109.1562225799697; Thu, 04 Jul 2019 00:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225799; cv=none; d=google.com; s=arc-20160816; b=b6zkb4AGaEZsr3BrRqrgr906jFhxDBUnK7t9wYHf/LI3h/TP9lXRiVJO7j+tMJeLDz N/uHKv6EiUBIMetlC9a15GZtZm7KHOhvE/bypxwybFJkGFqg/rKDDBlkpsjyfWjp54S0 cnoqsoqg59YN1JKBUUtUDCF7xkLyuM4jmpJrN24zVEHmFCYmkaA9QsDGOmvHjk/J9zxs Hh2Rb/8E+feWh75GMNMxYp9A0KQrqJ7ByILNkq5nyLqHNRofid5hmQ7KwdGIFnYbQ4LO lhGEX0KM+cQ9phUkD7OFOdr2fxvly8hQBsfVUnUT6yWMOJMLUvqWfN0caZ7XWTS85k1l dcfQ== 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=URsfVb2C5YnDBdAursEkzykoBuRcfjDfpur3Oh0s0WQ=; b=YG7hfn9RZiEYb6+8phB52f7vRxTgQIFj+8JUkPuSIbw2UVYxX6mJZ7pJdOf62tYFU4 vgNLIZhSJPlRb5UBFaMl7GLLDP8NB0MFAJ4WqX+Ee+hBaghK/eoSdAAlztPHrEUja05G 7GZ/hr7myXefPA68qVw/1AP2JGa4pyFNLQVT/dQ9ossRJTLSV/yC9ETgYk27Xolwr/c8 05UQJ8A960yWUpOB1uKiCt5AivYECY3LVH/3yHXFnqkv+Bv3HCIDj7pBwEEm7mxc8ev9 IShqVoWp8FlIPh27sOBHyFM6FDAPBS75ANQ91oAkLOInR366CiELcuDVairtcMzCRVGZ b9ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yLiVb0ti; 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; 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 71si4661093plf.156.2019.07.04.00.36.39; Thu, 04 Jul 2019 00:36:39 -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; dkim=pass header.i=@linaro.org header.s=google header.b=yLiVb0ti; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727251AbfGDHgi (ORCPT + 30 others); Thu, 4 Jul 2019 03:36:38 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42478 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbfGDHgg (ORCPT ); Thu, 4 Jul 2019 03:36:36 -0400 Received: by mail-pf1-f196.google.com with SMTP id q10so2525174pff.9 for ; Thu, 04 Jul 2019 00:36:36 -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=URsfVb2C5YnDBdAursEkzykoBuRcfjDfpur3Oh0s0WQ=; b=yLiVb0ti1ToT9rynffrniwkv2vML1oc4vwTfCyXQAAdUBi4tuqOGD2S0dnIXdFl4Eo m86o4yV8wGUA/uIpu8Kl/e30ZKEL1SjkiQstNlymRPfQrrcHFkethJ+EPfRB0xtsSWLd 2kNI6t3JpkKGDhNEIbSrGDTNCLnMGztukSDreTufoFyVpR+Lh37xvOkIKjO+RPfuD26F YxemoCmSJ0/tIchNdpRLrHndHOwhLcaQ5nyTt78yG97nALYDJzqg5Ky0X+cIMcEAwtH3 BFUOOtH7No+gcHUjN210nTxgc/OnJyEIsOOxfD7m+Zb4cK/ThNV1rAfB8t4w+i6/enln crfQ== 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=URsfVb2C5YnDBdAursEkzykoBuRcfjDfpur3Oh0s0WQ=; b=dqfX47i3i4rKnhk/4egz4p5+SIwCKIiW7gy+/mbveVhgxRiSVghEoYpMGIH8+iMRHD ELblKSmvK2SBaun5RQgAWX8mR7tU+xzfj3MkigsNyEJCcZ5P2EpYcDz3VGAMDkWFbZX8 VFKjwXWrFrULQRtlOJ4IAhJGcObMRXfmrMImpzjJ/o50MPbzQAst9UG6xRX8V6CTCHrQ e1SSi9wGfG0A7s83tiUaCv3pMS/Q+PATQMsuQpISo82vee6CaxmybrcW5DF1ucxX3eIA P/YDURwA90Os3rUyyk1I1m0HhpY6QO3iXIlrlhWjC0f04mImGw42QgbZjbcgX8gPfRoU h8dA== X-Gm-Message-State: APjAAAWfy3FhjP2qI0Hu/aYSwego812MX95XOwWbfz8qJceHHMilTqal bFKwWC7e81db1DP6ZhOIvMSDfQ== X-Received: by 2002:a17:90b:8d8:: with SMTP id ds24mr17848618pjb.135.1562225795530; Thu, 04 Jul 2019 00:36:35 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id t10sm4342324pjr.13.2019.07.04.00.36.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 00:36:35 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Daniel Lezcano Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH V6 2/7] PM / QOS: Rename __dev_pm_qos_read_value() and dev_pm_qos_raw_read_value() Date: Thu, 4 Jul 2019 13:06:18 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dev_pm_qos_read_value() will soon need to support more constraint types (min/max frequency) and will have another argument to it, i.e. type of the constraint. While that is fine for the existing users of dev_pm_qos_read_value(), but not that optimal for the callers of __dev_pm_qos_read_value() and dev_pm_qos_raw_read_value() as all the callers of these two routines are only looking for resume latency constraint. Lets make these two routines care only about the resume latency constraint and rename them to __dev_pm_qos_resume_latency() and dev_pm_qos_raw_resume_latency(). Suggested-by: Rafael J. Wysocki Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- drivers/base/power/domain_governor.c | 2 +- drivers/base/power/qos.c | 13 +++++++++---- drivers/base/power/runtime.c | 2 +- drivers/cpuidle/governor.c | 2 +- include/linux/pm_qos.h | 8 ++++---- 5 files changed, 16 insertions(+), 11 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 3838045c9277..20e56a5be01f 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -66,7 +66,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_resume_latency(dev); spin_unlock_irqrestore(&dev->power.lock, flags); diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index cfd463212513..7a0d197f0809 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -90,16 +90,16 @@ enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, s32 mask) EXPORT_SYMBOL_GPL(dev_pm_qos_flags); /** - * __dev_pm_qos_read_value - Get PM QoS constraint for a given device. + * __dev_pm_qos_resume_latency - Get resume latency constraint for a given device. * @dev: Device to get the PM QoS constraint value for. * * This routine must be called with dev->power.lock held. */ -s32 __dev_pm_qos_read_value(struct device *dev) +s32 __dev_pm_qos_resume_latency(struct device *dev) { lockdep_assert_held(&dev->power.lock); - return dev_pm_qos_raw_read_value(dev); + return dev_pm_qos_raw_resume_latency(dev); } /** @@ -112,7 +112,12 @@ s32 dev_pm_qos_read_value(struct device *dev) s32 ret; spin_lock_irqsave(&dev->power.lock, flags); - ret = __dev_pm_qos_read_value(dev); + + if (IS_ERR_OR_NULL(dev->power.qos)) + ret = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; + else + ret = pm_qos_read_value(&dev->power.qos->resume_latency); + spin_unlock_irqrestore(&dev->power.lock, flags); return ret; diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 952a1e7057c7..b75335508d2c 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -275,7 +275,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_resume_latency(dev) == 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 9fddf828a76f..2e3e14192bee 100644 --- a/drivers/cpuidle/governor.c +++ b/drivers/cpuidle/governor.c @@ -110,7 +110,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_resume_latency(device); return device_req < global_req ? device_req : global_req; } diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 58e8749ceac5..5e09d4980786 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -139,7 +139,7 @@ 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_resume_latency(struct device *dev); s32 dev_pm_qos_read_value(struct device *dev); int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, enum dev_pm_qos_req_type type, s32 value); @@ -176,7 +176,7 @@ 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_resume_latency(struct device *dev) { return IS_ERR_OR_NULL(dev->power.qos) ? PM_QOS_RESUME_LATENCY_NO_CONSTRAINT : @@ -189,7 +189,7 @@ 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) +static inline s32 __dev_pm_qos_resume_latency(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; } @@ -245,7 +245,7 @@ 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_resume_latency(struct device *dev) { return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } From patchwork Thu Jul 4 07:36:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168463 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1921620ilk; Thu, 4 Jul 2019 00:36:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQttW/r3Nbp/SINGFkXibav5GC7WIoi4AhokhFLyCcrBmPEtnWSoPmLQZfgWBi0RQx+ffU X-Received: by 2002:a17:902:aa09:: with SMTP id be9mr1128775plb.52.1562225802877; Thu, 04 Jul 2019 00:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225802; cv=none; d=google.com; s=arc-20160816; b=jvRGOvCPBxV3iA700QatWptQ/tCvk/kkQpHkJEJE6BhHQTqqYL/xH664Ev2iwvFw1a ObCuqpRQpbCg919f9eP2s8hT0v2w6iBlW73b+oCG3uDmpeWSZ4iP9P9KBGw14dmuaQYt Um4qt5GqPyJmXTY4uQF2l7GJYrnBLePNedNsIhMwoIbzq+Ww5nEmt4SwbHVR0AsTAqW1 PoGN3Q/ScEllfWWa+vEkgFJTIoIznmgdCQUJL9SAjSdkxCnXOMuWxj5ha8a1za8Z36+A e8JiRsPBX1JvpvC9Mt3j05iLJQEBz8VODY47mPanVx155j3DK9WfQ8Jnbow3LxnshCIg VyKA== 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=LJkFEiuUysgePRh2tewcbbbkLJSBBfe9i4VtJ5ijDyo=; b=RUIOWzoyUCCqOh6LzGCYWFnCbHi7vtWedE0XjCKqsSKijhTjIBzQfZHI0nqyeAr8PN sKpqdb30ae5E7WGQMNQiVu+RjkBmU9RYXB9UDg6wgqFya9xqzLIC2E5m/9j7Bu2blnBe Lg/vaL0P7oRhR+Xu0b70MR0Y3zxqIoIL4P0uJAeqDRVQ266530SaPngvobEMfmt/mdci 26+d5ZesmpMuYwSQmHRIWNcrygaEH0t5GnUh/8LrPcwZhPOBYx0w2uqWJ92F8EbyIzr2 s9Aa19kSj8XD3zidy/lNvb/xefnBnVFHQ/3Oe28VM2FAefDlpWOXUgxahyeZmR7RNdUq MvRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d4qt1XA+; 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; 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 71si4661093plf.156.2019.07.04.00.36.42; Thu, 04 Jul 2019 00:36:42 -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; dkim=pass header.i=@linaro.org header.s=google header.b=d4qt1XA+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbfGDHgl (ORCPT + 30 others); Thu, 4 Jul 2019 03:36:41 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44580 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727504AbfGDHgj (ORCPT ); Thu, 4 Jul 2019 03:36:39 -0400 Received: by mail-pg1-f195.google.com with SMTP id i18so2489625pgl.11 for ; Thu, 04 Jul 2019 00:36:39 -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=LJkFEiuUysgePRh2tewcbbbkLJSBBfe9i4VtJ5ijDyo=; b=d4qt1XA+TZ0H7KjnMMTnTK7yEZTN3p4mH+JlezdoFw4mNp36T34B90viSaqTLFE5Os NDYwJum33XQE6+ppRoD5mxCIlCyik7E4LgMiGyJ7P2xkWiIxnSgd99sH8X2/jOn6FqDj 8BJLuDkZUWwNYn2njtKnzd3Sh7I5JnsWdbvkJizhVacBjOU2aBSWtRVV9aQxO4VH3wFw +Cjv70onAne77oB217Y+/JxjTySb4wDgjhAO/LIXGZ7X013uWAxBj91DrE4flMxduMiJ Kge89RKmcNoVXJaJBvrNNVHP+7JNy38hOxILtg/9nGbIXMD5K+6ZNPuwSo7zknI1iLGV CHyg== 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=LJkFEiuUysgePRh2tewcbbbkLJSBBfe9i4VtJ5ijDyo=; b=fooSdqlJBXFDCZzyaV+CHpxEunwDUt5Rnku2l3sGQDSg0kCVCd9X7m2vFllVaAVyse 5SbNmDXZCypKkxH7rCOq3MvlCtg5cADIU7Hoeu8AyQbtIcOLVeOaeMqvdjV/GYXEBGVL s841RKt9JlSN46hiJfGUPjENpwPFASBDnMIORNLpyXRK1rrtqgcH6edOzElzD/j+N6MD 2ejF7wh5UEtZAKjfbG3BntZOitz7UPGrm4droOFNizUmc7x41YIwXXUaekM5CL3dl7DP KSi3+a6wxngvedWZMf8ao7q8fe5pwoy/3uYHPm+VPEV5pu83XUFGzHR3LcK86XXIW1jd LHug== X-Gm-Message-State: APjAAAUiocMHyV7k+iyln7ZYSF6Ktijhspf7YkJHrWReHnxhJR2nQGIy SUb2beYK/cIcV6mJ0pod26wlrw== X-Received: by 2002:a17:90a:1ae2:: with SMTP id p89mr17119525pjp.26.1562225798655; Thu, 04 Jul 2019 00:36:38 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id k22sm6872919pfg.77.2019.07.04.00.36.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 00:36:38 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Matthias Kaehlcke , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH V6 3/7] PM / QOS: Pass request type to dev_pm_qos_read_value() Date: Thu, 4 Jul 2019 13:06:19 +0530 Message-Id: <8dfa21c3c99d677fdd04a2729acc00cdf4409818.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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to allow dev_pm_qos_read_value() 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 but will be extended to frequency limit (min/max) constraints later on. Reviewed-by: Matthias Kaehlcke Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- Documentation/power/pm_qos_interface.txt | 2 +- drivers/base/power/domain_governor.c | 2 +- drivers/base/power/qos.c | 17 ++++++++++++----- include/linux/pm_qos.h | 16 +++++++++++++--- 4 files changed, 27 insertions(+), 10 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 20e56a5be01f..daa8c7689f7e 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -33,7 +33,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; } diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index 7a0d197f0809..2461fed0efa0 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -105,18 +105,25 @@ s32 __dev_pm_qos_resume_latency(struct device *dev) /** * 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) { + struct dev_pm_qos *qos = dev->power.qos; unsigned long flags; s32 ret; spin_lock_irqsave(&dev->power.lock, flags); - if (IS_ERR_OR_NULL(dev->power.qos)) - ret = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; - else - ret = pm_qos_read_value(&dev->power.qos->resume_latency); + switch (type) { + case DEV_PM_QOS_RESUME_LATENCY: + ret = IS_ERR_OR_NULL(qos) ? PM_QOS_RESUME_LATENCY_NO_CONSTRAINT + : pm_qos_read_value(&qos->resume_latency); + break; + default: + WARN_ON(1); + ret = 0; + } spin_unlock_irqrestore(&dev->power.lock, flags); diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 5e09d4980786..9a21b7ba72ae 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -140,7 +140,7 @@ s32 pm_qos_read_value(struct pm_qos_constraints *c); 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_resume_latency(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); 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); @@ -191,8 +191,18 @@ static inline enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, { return PM_QOS_FLAGS_UNDEFINED; } static inline s32 __dev_pm_qos_resume_latency(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 s32 dev_pm_qos_read_value(struct device *dev, + enum dev_pm_qos_req_type type) +{ + switch (type) { + case DEV_PM_QOS_RESUME_LATENCY: + return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; + default: + WARN_ON(1); + return 0; + } +} + static inline int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, enum dev_pm_qos_req_type type, From patchwork Thu Jul 4 07:36:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168465 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1921707ilk; Thu, 4 Jul 2019 00:36:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1Or6EjTCMhnnOPfqEpvBe8tuoJnRszziKA5EjqJyDLU2T/HQHSnv8j4oFsCnJEXTWgktt X-Received: by 2002:a17:90a:22ef:: with SMTP id s102mr18519825pjc.2.1562225808566; Thu, 04 Jul 2019 00:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225808; cv=none; d=google.com; s=arc-20160816; b=yLhQgb9i9J5lXEz842iJBMupRLOdmgebNQL14oKsPSsPLtux8xLCHpTUCm6CyaJDfB /ZiKu8GkOPFRIZQ7/5buNe7qNIB0xR3c3hFdONwdNhM7KqPDAqCAt1TkRaJ6s48AsYWF AU35qgRhgUFoKz9Sy/gonvwg/3jqK1kFYf5C8/sy2GAckkbCMqTlat1l6c4P09Er9mL3 gO8M0StLKg9G5Da7m8pO8g95nueMUMPjVjYKEX04WWkq27Sybv2MZnpWOmvTnUdR2Qaq OKuTSnACEV1RLVNfq+U72rqO6bTV4Y1z4/nxIAFnT6VwHImkWGM7zBZ3SxVyend2UZQg Jspg== 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=ucpldABbW8/3jH3u+faZEWtKvMNLILFWVMZ6DzJhvvI=; b=0rUT3k7CjGh0WTXgtJFq4wkB72sqIcwlL27JpKaSZUZXD0pCwFGuJudue6GaTUYanO 5shkE56ZpwilG6TJs84dy0e3rqJ2xx07hJ1TkH7ZKYU7EkxaKnDCxHagfXnKgbD2TbQp vmdAeBgexZYbGA/jCpe2Q1aST4IZyO+A0jJAhav0HK+OMxnqCktA/BZw0pS6cIPQsIt0 6aIodlfj2AbFkZbzhRcTcZQvQOyrUybi6oJLTVdb//ud/wiKlvCZV/6URjHPnAnfu2ZJ ZhQbVvNbSlngc+D5GVmLbtGhNlYHJcgCggAqgF5RgP7UuzBExSwXtgHnTDsqxD/i5AJz x5xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wG8etO7Y; 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; 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 d12si4843008pla.121.2019.07.04.00.36.48; Thu, 04 Jul 2019 00:36:48 -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; dkim=pass header.i=@linaro.org header.s=google header.b=wG8etO7Y; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727544AbfGDHgr (ORCPT + 30 others); Thu, 4 Jul 2019 03:36:47 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40871 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727528AbfGDHgp (ORCPT ); Thu, 4 Jul 2019 03:36:45 -0400 Received: by mail-pf1-f194.google.com with SMTP id p184so2525259pfp.7 for ; Thu, 04 Jul 2019 00:36:45 -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=ucpldABbW8/3jH3u+faZEWtKvMNLILFWVMZ6DzJhvvI=; b=wG8etO7Yt1bBZuwRtL6oYyKvU5eSay0J+oDqZ+r4qC14aa7P3aNMTqV2JQiccaxzyA 75vIiSj0uWHz+NcO50TBcru2hp0wGBe0aJXRI2gRXYYcS4XQM+CUuTgPWgDP2zYZTnG3 VHxGMj4unTfXFsFHJLAHrXYWp/cEciVO3y4P6Ol1vVxZhKyETemVIciuggIgmT4fBOnY uCVb1q0Z1ld4NQhD7Cz38yWPsUjtZY8dcTISXE5GMt3AhLbkMSkHNzPvWOyAu5rJXUwj 2hmZMlBtt0RG4kEzaXQnvJQWvgtgO37N9qLKN/fdpSzC0fLaPSFeqreBZhRxdOcQcNl5 McmQ== 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=ucpldABbW8/3jH3u+faZEWtKvMNLILFWVMZ6DzJhvvI=; b=AeXJrjTGY3WAMvbbY9cyYgMq6cFkwtQ5EBcjd1EhV/B1KyVkp5JHm+BjlXqm2dlwdx px6YHppfYklhM25kVj5LIh7K3L8nD8oLqIx9GzYLbhKtk7QmT3og+fxAE6UwH2zNhTR6 IrNnjR7Y2qeLbAIhEZrNwBTjS0mAVAobcDW8s9MXbpquBAnnVU9I553sG5OM/rwsRGdl umW5DjLBLAgCfHfIvF4hbY+IdJvjKA44csofLoRCViTQVX+nKnu7rH+QGDqvYD55+8FT krUXGkYd9QN6zRAkbyHSN7r2rLVLptAzBuny3Gn5q2xL2McfZo9fxM3DGvdlB3ZWJJlH lX8Q== X-Gm-Message-State: APjAAAXlSko1ND0LgJDIX0NfJz2Vx9NqaAFkRrVfRrbqRhDDIlJaUuE+ 1VHA/+wvR97/YeohuEoZrW8ILXGkSIo= X-Received: by 2002:a63:5964:: with SMTP id j36mr39448142pgm.428.1562225804520; Thu, 04 Jul 2019 00:36:44 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id x14sm5926822pfq.158.2019.07.04.00.36.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 00:36:44 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki 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 5/7] cpufreq: Register notifiers with the PM QoS framework Date: Thu, 4 Jul 2019 13:06:21 +0530 Message-Id: <5ad2624194baa2f53acc1f1e627eb7684c577a19.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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. refresh_frequency_limits() is updated to have proper locking in place and avoid calling cpufreq_set_policy() for inactive policies. No constraints are added until now though. Reviewed-by: Matthias Kaehlcke Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 135 ++++++++++++++++++++++++++++++-------- include/linux/cpufreq.h | 3 + 2 files changed, 109 insertions(+), 29 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index ceb57af15ca0..81117e4d43cc 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -999,7 +1000,7 @@ static void add_cpu_dev_symlink(struct cpufreq_policy *policy, unsigned int cpu) { struct device *dev = get_cpu_device(cpu); - if (!dev) + if (unlikely(!dev)) return; if (cpumask_test_and_set_cpu(cpu, policy->real_cpus)) @@ -1117,14 +1118,20 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp static void refresh_frequency_limits(struct cpufreq_policy *policy) { - struct cpufreq_policy new_policy = *policy; + struct cpufreq_policy new_policy; - pr_debug("updating policy for CPU %u\n", policy->cpu); + down_write(&policy->rwsem); + + if (!policy_is_inactive(policy)) { + new_policy = *policy; + pr_debug("updating policy for CPU %u\n", policy->cpu); - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; + new_policy.min = policy->user_policy.min; + new_policy.max = policy->user_policy.max; + cpufreq_set_policy(policy, &new_policy); + } - cpufreq_set_policy(policy, &new_policy); + up_write(&policy->rwsem); } static void handle_update(struct work_struct *work) @@ -1136,11 +1143,55 @@ static void handle_update(struct work_struct *work) refresh_frequency_limits(policy); } +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); + + schedule_work(&policy->update); + return 0; +} + +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); + + schedule_work(&policy->update); + return 0; +} + +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; @@ -1157,7 +1208,7 @@ 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); /* * The entire policy object will be freed below, but the extra * memory allocated for the kobject name needs to be freed by @@ -1167,6 +1218,25 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) 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); @@ -1177,6 +1247,11 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) 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: @@ -1189,30 +1264,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; @@ -1224,6 +1278,11 @@ 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); @@ -2283,6 +2342,8 @@ 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", @@ -2297,11 +2358,27 @@ int cpufreq_set_policy(struct cpufreq_policy *policy, if (new_policy->min > new_policy->max) return -EINVAL; + /* + * PM QoS framework collects all the requests from users and provide us + * the final aggregated value here. + */ + 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 a1467aa7f58b..95425941f46d 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -147,6 +147,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; }; struct cpufreq_freqs { From patchwork Thu Jul 4 07:36:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168467 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1921828ilk; Thu, 4 Jul 2019 00:36:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAn4Bg+r3Z3+2dBdMGv0V5KdQ8WLgtw37BjRIV5ABxSyxxYqViIwZeQQP69UkVQ7Deg8Dm X-Received: by 2002:a17:902:467:: with SMTP id 94mr47280319ple.131.1562225815690; Thu, 04 Jul 2019 00:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225815; cv=none; d=google.com; s=arc-20160816; b=FRQf6B5ylaqKGQfh99Q5r5PyBUUcbd2IQ0IQtR6gHj7eM3zMqFHN0AT+Mv+zfwHO+n xaFlTYHGPewjxMgygk5PffH+iUMMSKVIBDOLl+5KMggyT1o9IY+6bArR9Wh5y5IX9RXv E7fljIYJNl9AOzS07K64833T2aZFpGC0ByaConiIYqd4ebLcXj3qvSjLRQWGVInaUfC4 QGCnsatGfkH+Gtk9lsnWunAOqtqwP2jge2ESJk9QThXTs/47DKdVhulkcKvoLdcvcqEn Vrp/0BDtaCl56WL96Wm5aP4Yb7jB0+EoomaylTqZeUAaz/6qxh7waxkZvLT2qRs1WeQ2 ZShw== 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=47nu70zu7IH4O5mYfwvkO2JIEeyQhRCLZhm8kmN821M=; b=xZ6zLZlDheW6Z33+R3YGmDYuHNMz+l87AUJW59qOyIu9bBFmjrvJqvnlIq0JLONquC XDkBNjImQHV6QXOyqhDVGVCZVyMat3x+5SedQ2Te6Sacke2UB6mnz/Pse/RJPMVTEAR/ iODSHM7HzuaQ18ZcYvTzzjuTcsMOsSOV6DbNJ0+ubD3hBzGPiMvgOG8Mt4LqFMmrlgHL GfJ/3HCjKsvOFaWjNWxCPpyvwUPN/HShAAjT5G7Pg3WvLTPE6wPcubPjkRBl73dT2XZz HHpv2REJCanCJvyhrA3WRNxZiG7F/piXNKXWbcaiRZ5vwk16EIncLUAFoKPj04K5lJqa +tdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=had28dnX; 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; 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 r1si4501575pjp.80.2019.07.04.00.36.55; Thu, 04 Jul 2019 00:36:55 -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; dkim=pass header.i=@linaro.org header.s=google header.b=had28dnX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727573AbfGDHgy (ORCPT + 30 others); Thu, 4 Jul 2019 03:36:54 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32978 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727558AbfGDHgv (ORCPT ); Thu, 4 Jul 2019 03:36:51 -0400 Received: by mail-pg1-f195.google.com with SMTP id m4so2516068pgk.0 for ; Thu, 04 Jul 2019 00:36:51 -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=47nu70zu7IH4O5mYfwvkO2JIEeyQhRCLZhm8kmN821M=; b=had28dnXoGd0QBJsiA7AXZG88tv+5KTH+WuLgm5O/7W526+9jgnNoUDdVTleis8Rvu T+NTaFgZD+mpuVqcvmXQ+cNULNPw27bFwc/CrYRoey1CJ9QqG08JEOkz5e78KJ1zaROX 0kQXORIFuS5Cn112TwBdqoyYr6+CdQwY9Cx8UEy6K98Gl7Qzkqjc7Du4xP7m6YuFYuBm EwdUHIjDPRZVvUW5fmxvkelU3YySPfDACg4IOy1+3f3w3/ppTSL1b2Y5fA1JkHDhXghT HCgecjYAnvvp/QpQwMgxkmcybvbd5kKa2M5MW+iF3vUZfi+qhlYlcKSyEBGMzoJG7XTr xdjg== 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=47nu70zu7IH4O5mYfwvkO2JIEeyQhRCLZhm8kmN821M=; b=fCfRDO7BFSsCI9fSgOSx/6WHqxo9zurpMPWSydPmb1Xi+wiN7AdeAU4VSjPOjTsmdE WhK5ionRvU6usgaLBF3t7l8goTI8XXWYBu9hzSWgKqdZpLpR5A7qR5QmN0eNOeLQuptN //pbApPKZY8+YgcRSNbI51JmAY38cM2k6ifKAppDbksz23PdqosCPTFhnEGxQ5gZcJeS ynEdNN75Ft3x4cfMwBiZEOMjNplhHXeJZFXG0H62zAz6iId7ryrSPBM3QEeNp0FwhUAL nEmeL/GarVJbWdnk1Cy1fasr7Y5zrRZs9h8QBbPlb3iZc9c+couZBXvQZ6K45u1InTNj oRgg== X-Gm-Message-State: APjAAAXrvr77zRVd0Hswq6GKLDAsJiLt5MExLNkIkwID2i2q4OpjczxW jbzovycH9JZG7TzHm7Ts0FaGdQ== X-Received: by 2002:a63:de50:: with SMTP id y16mr42148903pgi.431.1562225810570; Thu, 04 Jul 2019 00:36:50 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id f7sm6167329pfd.43.2019.07.04.00.36.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 00:36:50 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki 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 7/7] cpufreq: Add QoS requests for userspace constraints Date: Thu, 4 Jul 2019 13:06:23 +0530 Message-Id: <0d4c2a013b32bf18d45817011b028918220580f5.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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This implements QoS requests to manage userspace configuration of min and max frequency. Reviewed-by: Matthias Kaehlcke Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 87 ++++++++++++++++++++------------------- include/linux/cpufreq.h | 8 +--- 2 files changed, 46 insertions(+), 49 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 091789e868ee..13c2f119cc0c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -718,23 +718,15 @@ static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf) 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 >= 0 ? count : ret; \ } store_one(scaling_min_freq, min); @@ -1126,8 +1118,6 @@ void refresh_frequency_limits(struct cpufreq_policy *policy) new_policy = *policy; pr_debug("updating policy for CPU %u\n", policy->cpu); - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; cpufreq_set_policy(policy, &new_policy); } @@ -1238,6 +1228,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); @@ -1248,6 +1244,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); @@ -1283,6 +1282,9 @@ 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); @@ -1361,16 +1363,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 && has_target()) { @@ -2344,7 +2360,6 @@ 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", @@ -2352,24 +2367,12 @@ 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; - /* * PM QoS framework collects all the requests from users and provide us * the final aggregated value here. */ - 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; + 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); @@ -2458,10 +2461,9 @@ 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) { @@ -2521,10 +2523,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 1fa37b675a80..afc683021ac5 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -50,11 +50,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 */ @@ -84,7 +79,8 @@ struct cpufreq_policy { struct work_struct update; /* if update_policy() needs to be * called, but you're in IRQ context */ - 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;