From patchwork Tue Jan 3 11:06:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 89635 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp7951840qgi; Tue, 3 Jan 2017 03:08:10 -0800 (PST) X-Received: by 10.98.149.81 with SMTP id p78mr57110793pfd.95.1483441690742; Tue, 03 Jan 2017 03:08:10 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17si68671582pgf.67.2017.01.03.03.08.10; Tue, 03 Jan 2017 03:08:10 -0800 (PST) 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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934951AbdACLHv (ORCPT + 25 others); Tue, 3 Jan 2017 06:07:51 -0500 Received: from mail-pg0-f54.google.com ([74.125.83.54]:32949 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934782AbdACLGp (ORCPT ); Tue, 3 Jan 2017 06:06:45 -0500 Received: by mail-pg0-f54.google.com with SMTP id g1so174777484pgn.0 for ; Tue, 03 Jan 2017 03:06:44 -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 :in-reply-to:references; bh=Kj5v7xaJW7F8FQKGzDHsqQ6sd+tmPxMTEdZmy6graFE=; b=PnggY9nmquj4iGfI4arjDkzMT5NAJ3wk98KAbWJZau56KX9cIJ+beI20BYEb5Mfjmh /w84mv1vXaZitW37Y29dYrQSSatBD01FC6F4YVOiboiFylMG7mmgWA6ZKQfQSxqF4fHm ssF/bNPPAXqzM9lHgNUpGZjqZd7tCBqu5yZCw= 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:in-reply-to:references; bh=Kj5v7xaJW7F8FQKGzDHsqQ6sd+tmPxMTEdZmy6graFE=; b=mePOZsFpeoWLDaikT2DGx1Li7M/VZuqgNzb6SIpA6GqFh08INpFHV1hAIGsUiQDQ+s 9WJww2Q/dJRh6kXM9wzgF+e6VKq8yQ1svMm2xOZq4n9AHLCi0tk7xI/VweNNOOCmDSZv GjpxrCXVOS+/VQQ9ZkMWrWbfaF7gdHITidq15Jl7qxE3i0jqwRIGjSLzx5r83oRbN+ct mLuhKo1rA9MVmeMmZdZcaYc8ghDThgYsps/Ehv/HzvJhyJ8fzePsj5VTlUtyeq8POJ+i cTITgPaP26XAgzw90Fd9MuO/n/djDyyDpur2fekZGVjhenB5k+dscynhhROzGEMxClw0 r2bQ== X-Gm-Message-State: AIkVDXJU6bf7Qd20RnUuT/83FAlia90Cbtyg02GJ43vlIU930RizqRwRh9FO40uwoxQuy+dk X-Received: by 10.98.150.88 with SMTP id c85mr57355719pfe.68.1483441599268; Tue, 03 Jan 2017 03:06:39 -0800 (PST) Received: from localhost ([122.171.77.55]) by smtp.gmail.com with ESMTPSA id s4sm138865824pfb.55.2017.01.03.03.06.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jan 2017 03:06:38 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , khilman@baylibre.com, ulf.hansson@linaro.org, Len Brown , Pavel Machek , Kevin Hilman Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Boyd , Nishanth Menon , Vincent Guittot , robh+dt@kernel.org, mark.rutland@arm.com, lina.iyer@linaro.org, rnayak@codeaurora.org, Viresh Kumar Subject: [PATCH 2/6] PM / QOS: Pass request type to dev_pm_qos_{add|remove}_notifier() Date: Tue, 3 Jan 2017 16:36:08 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: 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. Signed-off-by: Viresh Kumar --- Documentation/power/pm_qos_interface.txt | 11 +++++++---- drivers/base/power/domain.c | 8 +++++--- drivers/base/power/qos.c | 14 ++++++++++++-- include/linux/pm_qos.h | 12 ++++++++---- 4 files changed, 32 insertions(+), 13 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt index 129f7c0e1483..c7989d140428 100644 --- a/Documentation/power/pm_qos_interface.txt +++ b/Documentation/power/pm_qos_interface.txt @@ -166,12 +166,15 @@ under the device's power directory. The per-device PM QoS framework has 2 different and distinct notification trees: a per-device notification tree and a global 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. Currently it only supports the notifier to be registered for resume +latency device PM QoS. -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. int dev_pm_qos_add_global_notifier(notifier): diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 2997026b4dfb..12f16d9b6b55 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1203,7 +1203,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; } @@ -1238,7 +1239,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); @@ -1263,7 +1265,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 01f615b18055..9adc208cf1fc 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -481,6 +481,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. @@ -488,10 +489,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)) @@ -514,15 +519,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 0f65d36c2a75..3b24f7d20299 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -144,9 +144,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); int dev_pm_qos_add_global_notifier(struct notifier_block *notifier); int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier); void dev_pm_qos_constraints_init(struct device *dev); @@ -195,10 +197,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 int dev_pm_qos_add_global_notifier( struct notifier_block *notifier)