From patchwork Thu Feb 21 11:29:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 158903 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp373122jaa; Thu, 21 Feb 2019 03:29:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IaKWIqKyuAvRN2nsVVpKRvk8rxBPqFxECGmp2NE3xUjC3jug4on503VTGfPlllaB3L6mxzy X-Received: by 2002:a62:6282:: with SMTP id w124mr40038883pfb.168.1550748593726; Thu, 21 Feb 2019 03:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550748593; cv=none; d=google.com; s=arc-20160816; b=apROnR8+moITx4kMtPUlwBmxOclvsRdPVRQ/1BGUxsYetnhxEY1twlnqzMsXIPeOJn m0VIHIzOxT9aMoU6vI46MzK1YoA4VUSFp69T63NxhQSmRGRblwbf3s1PUsZVVpaLDleg eG79W7RrIXbvZs2/ByWhVc4ls5YWgsSYD9ojLON9VQEidNkFvkcKtcW9FOmRWyI2tjVv uA9PN3gS+624/Wy59Y5jUwHCaSGEqVeGbetbdUc1Gb5N1DFmUUfeXFBWqQexGYnSbdrb jUb7/m9VWYKm0VBbPHLfNa7Bnd9uNRCPL3m1CB4KD1f478LcZ+UwnrOIVRlao2w0mEny u4EQ== 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=+jNp0/kQ8orVa0y/ZTjJoci/OQMHHtlr8yMXafqVnuQ=; b=dNEAGMwtyvN//mXWfAqc/bMXyPEGMEZRSErXCeKHuSq3Goh1CZEs2ueaJAAzZc8xBh 6R+psEguG5s9w79IwO7gCrJe7/aljuon7P3clRV/59uvNSf6Gji78M15plseEpvEQsxE cpRUazq/EpatWE6QRLjKjWvsmHgxs7RrIvCUnyCSpnAQPcXt6oZWk2uw1ar8pw7bOiVl tts/nYlVL2cVixVPRGLvNsuIpH+IOJjTk/nDBDDmfFA+Wv6XAVNISw7UjicMgcNOB3Uw wI1G+1rxOvF698LdxPorNKx9mFzohJHOwsS8TEsQ0AA5CafSullXa4efdUdaI4aODF94 LWSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=taN2BHoN; 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 3si21435413plr.336.2019.02.21.03.29.53; Thu, 21 Feb 2019 03:29:53 -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 header.s=google header.b=taN2BHoN; 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 S1727295AbfBUL3v (ORCPT + 32 others); Thu, 21 Feb 2019 06:29:51 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39832 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbfBUL3u (ORCPT ); Thu, 21 Feb 2019 06:29:50 -0500 Received: by mail-pf1-f195.google.com with SMTP id i20so3190000pfo.6 for ; Thu, 21 Feb 2019 03:29:49 -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=+jNp0/kQ8orVa0y/ZTjJoci/OQMHHtlr8yMXafqVnuQ=; b=taN2BHoNlTS9R8Ar3MdBm4HB3aowZErPyP7/4h65JHVFDemrSVuXSFjRvckVJVqyml zSRW6EEjrqv6XsTYK6kdgmXO+r1n+WH1ENPzwNTxXlwpYaNAyRhgv/an/bspQNdOOpg6 AsWnOg62UoV/Kwfm4CBGPY3aFEbOJxcIdsZuteEinJE9vsYYkazoVWSKR+UhmupsmFDr 8vKCnPOuyENFmZdj8jq+r0lk2a7zYejJy7kvTykBrYmCg4J5b3AuR008t76sU5sb6470 M/iYdLZSsaiNrTzFgAG6g8TVCijfKKUoUWvRozkJssljx2okShip3dNSbet36S2vOhRW CJxA== 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=+jNp0/kQ8orVa0y/ZTjJoci/OQMHHtlr8yMXafqVnuQ=; b=EmT44R6a2Vx9WPspY4V5oAn8R1eaULFTJoZWfRSMjhSrISrUpkaGtutMoTUffxa7vj kusmR05Wj3HbFBZHL0KALu55sWZpW5cm3wNNyeaTSVirGqTTduYKQUyYREYvzb6fMU7s Xh4Bj7rlXT0o0R+C4+9WkEn8iuGx8q5uobtdhNpVxjaYd3Yr9lr2C8HRUtDY7ptOrxpG G7lBVwNHGu0hs70rjbmxfxeDhTQRmTNEkw3DayXlPeFHEiKeUVuF++CSHDU8b6BjkrqO UWyrc/lbuQEXTiTfnOhFugc0DBRRmTr6VD3n7K6ynrNXwv2p4khRwqUzHqalC9Bcnmf+ byyg== X-Gm-Message-State: AHQUAuaf0RdklUhFKom+3qTBGj6QQDt3pPjO4C7neeUE7gyEBbARotre VjUJ8uZbpV5Kn0xWJGnGcLY12w== X-Received: by 2002:a63:d904:: with SMTP id r4mr34271668pgg.207.1550748589118; Thu, 21 Feb 2019 03:29:49 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id u8sm5244342pfi.22.2019.02.21.03.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 03:29:48 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson 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 1/5] PM / QOS: Pass request type to dev_pm_qos_{add|remove}_notifier() Date: Thu, 21 Feb 2019 16:59:27 +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 2c334c01fc43..d8c37945a26d 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1486,7 +1486,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; } @@ -1519,7 +1520,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); @@ -1546,7 +1548,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 3382542b39b7..49672f9dc8c4 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -471,6 +471,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. @@ -478,10 +479,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)) @@ -504,15 +509,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) {