From patchwork Mon Jun 10 10:51:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 166304 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp873025ilk; Mon, 10 Jun 2019 03:52:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMDql/WhW6JoPEh1er0rIyOfhyR3BU4bvQrKMkQ9IKtllkOjWYunGcdC+lvr8TTz7jNjVq X-Received: by 2002:a62:78c2:: with SMTP id t185mr3853075pfc.142.1560163920879; Mon, 10 Jun 2019 03:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560163920; cv=none; d=google.com; s=arc-20160816; b=Y1zqUzsu3FD4wCJz3y/mGkDpN1SyxIZVkEPD2rCo1FtqMFkYosiUXUWP6eeHJp1fce F9RmWlAkM8gzf4Bp7WVBfIA4zrmKVATi1CV236DAm7mTDkAjWu9bdDuOAeZdiZjllkcq YqsR1UG16tV+FamyRtWp00ydgWT/jpjocGVrsVgbQ+DEI/akGkSiJ/ygtZUyPiAaR+IZ Md8Owd3U354b7KU3ovrpQexJTfTxhShATfoCx8ys2+7FxS08HMLEjkxEeCK/+ABUEFCe NCFSJA/1UuQv4uOgIN0+LjqdTQm0h67QsTTvsF6hmhf6XgAo2i6pFGeWt2jbdiiEsiqL FBHA== 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=1JRbT8rh7sDm+oNJ6ocQbxCOgIqvtm/Aqgj/m99h5BA=; b=bEd0pEI2M23fnBX2N1wHSOrV8Ksw7bwleCJ29fabRqkrKWCFnSemkfK9c5H3tOezTD /WvPZQq94Q26JUIzuI3WcL2GFtvgNPH4RraEUJ7ICTkW3Z+FSrm4M7s9RM8+NIqGkQFr 8Gdiv4G8V27deBMPh+GeLnrBnRDzNisRHuIdX93Z5S6BumbK8Np9DbESdiZCGaiYeSfz fsdYQYqn4kyXNSrCobIx4t/ViA0rIZuwJSQytFxaUJCgbK49iYYag5TpWTfzu/GI0uL1 6v+zpuCyK/JFQzsQuIVDdIP6YgwemxsYuqzAubEcCeF8NaqBUnhcc4Q9tTBHRp6gF82u 3OLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p3FNt15m; 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 t4si9938726plb.188.2019.06.10.03.52.00; Mon, 10 Jun 2019 03:52:00 -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=p3FNt15m; 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 S2389579AbfFJKvz (ORCPT + 30 others); Mon, 10 Jun 2019 06:51:55 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38905 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389567AbfFJKvz (ORCPT ); Mon, 10 Jun 2019 06:51:55 -0400 Received: by mail-pl1-f196.google.com with SMTP id f97so3505902plb.5 for ; Mon, 10 Jun 2019 03:51:54 -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=1JRbT8rh7sDm+oNJ6ocQbxCOgIqvtm/Aqgj/m99h5BA=; b=p3FNt15mcrxakgcro+qKJsvQeLa2qEBRrg69SYwrm3gOt1dylEYx2Jt7bz/VpWIFWj VcJUWXux64BdZp3sAOq1jAFSWfuHVSmLoOAnfEdnbuvQmWFPKWA09krhB3PJ+22ULTjS v9WfD4gAsT4rzY2WchpMJKdFJMstInFgtGno+cSbqjBITPdkzXMGiekkxNhMWy45HT4L MnnxqIoka147M6vI/PwBvObVXpizTJL/grWRVDVBABpzsHLrr0aW2rNwzh8uFpvhu9pR 5PFexHjw9dDpJRRk1LMaHMrFAp+wIRU722RsV/m0tS9DKfc1zJpVpRc49zjbX0IO9/Iu QpWw== 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=1JRbT8rh7sDm+oNJ6ocQbxCOgIqvtm/Aqgj/m99h5BA=; b=ral+L5KrpYzEB7gJOanzh4p/JmnsTEGCJjt+Zi3vKxteetdKi5J4Tczml1zCDW5S/W FSIGNogr/xoKqhFPZoWX10DJM2IXrSQgadARsF8ht0wRxnnToSvlRKjBKqXbWnJPBPa9 3l1njhiWCjOtgl70L675a0rEXoUMz3vWu7IBuk0UePwPBddbRa/HfU9GHP9eanghQU2e hVqkQ+u5FrLcGnP43jsOBNexR4Q7bBGV8xmfBk+BmgrG5hqTcnT8Q2WQdUEi2XEltEoT CVrSQ0IS/Hm88aRjinB/u6WZ+3cJwz9BawgGhgvs3fdvbdboa3q+37x3Y8akLBiqAtNf iBtw== X-Gm-Message-State: APjAAAXC1LvcMQmvODtvkIKZTpydESQ1J7KRgVXuaGRJhQXHfz3nWS4Z lURNyCfIzKlCdXUgRuN2IjztMQ== X-Received: by 2002:a17:902:868b:: with SMTP id g11mr67709631plo.183.1560163914404; Mon, 10 Jun 2019 03:51:54 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id v64sm10322956pjb.3.2019.06.10.03.51.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jun 2019 03:51:53 -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 , Qais.Yousef@arm.com, mka@chromium.org, juri.lelli@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH V3 1/5] PM / QOS: Pass request type to dev_pm_qos_{add|remove}_notifier() Date: Mon, 10 Jun 2019 16:21:32 +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. Signed-off-by: Viresh Kumar --- 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..1f4d456e8fff 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) {