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) {