PM / QOS: Pass request type to dev_pm_qos_{add|remove}_notifier()
authorViresh Kumar <viresh.kumar@linaro.org>
Thu, 4 Jul 2019 07:36:17 +0000 (13:06 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 4 Jul 2019 08:40:54 +0000 (10:40 +0200)
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 <mka@chromium.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/power/pm_qos_interface.txt
drivers/base/power/domain.c
drivers/base/power/qos.c
include/linux/pm_qos.h

index 19c5f7b1a7babed3e55a5918097c36243a707f86..ec7d662d1707667b1adcf2663ce69294f4702a83 100644 (file)
@@ -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.
 
 
index 33c30c1e6a3030288856aaf8ad179bb0b72dce06..b063bc41b0a9cd9ba54fcad80955683131a65f8f 100644 (file)
@@ -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;
 }
index 6c91f8df1d59e0666c7eeb854f7b24e0f9e6b5d5..cfd46321251350928fd18c4301b10c54d6626110 100644 (file)
@@ -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. */
index 6ea1ae373d77c2efdc1369fe8391009a57a8054c..58e8749ceac55d219c7408d985f79fb6e83a4a70 100644 (file)
@@ -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)
 {