Revert "OPP: Protect dev_list with opp_table lock"
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Nov 2019 13:51:46 +0000 (14:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Nov 2019 07:22:45 +0000 (08:22 +0100)
This reverts commit 714ab224a8db6e8255c61a42613de9349ceb0bba which is
commit 3d2556992a878a2210d3be498416aee39e0c32aa upstream.

Turns out to break the build on the odroid machines, so it needs to be
reverted.

Reported-by: Viresh Kumar <viresh.kumar@linaro.org>
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Cc: Niklas Cassel <niklas.cassel@linaro.org>
Cc: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/power/opp/core.c
drivers/base/power/opp/cpu.c
drivers/base/power/opp/opp.h

index 8100c87691497a6204b784366caf7f9b052e0e6d..d5e7e8cc4f221e9a7196b97b434681a6f3e4cd4b 100644 (file)
@@ -49,14 +49,9 @@ static struct opp_device *_find_opp_dev(const struct device *dev,
 static struct opp_table *_find_opp_table_unlocked(struct device *dev)
 {
        struct opp_table *opp_table;
-       bool found;
 
        list_for_each_entry(opp_table, &opp_tables, node) {
-               mutex_lock(&opp_table->lock);
-               found = !!_find_opp_dev(dev, opp_table);
-               mutex_unlock(&opp_table->lock);
-
-               if (found) {
+               if (_find_opp_dev(dev, opp_table)) {
                        _get_opp_table_kref(opp_table);
 
                        return opp_table;
@@ -716,8 +711,6 @@ struct opp_device *_add_opp_dev(const struct device *dev,
 
        /* Initialize opp-dev */
        opp_dev->dev = dev;
-
-       mutex_lock(&opp_table->lock);
        list_add(&opp_dev->node, &opp_table->dev_list);
 
        /* Create debugfs entries for the opp_table */
@@ -725,7 +718,6 @@ struct opp_device *_add_opp_dev(const struct device *dev,
        if (ret)
                dev_err(dev, "%s: Failed to register opp debugfs (%d)\n",
                        __func__, ret);
-       mutex_unlock(&opp_table->lock);
 
        return opp_dev;
 }
@@ -744,7 +736,6 @@ static struct opp_table *_allocate_opp_table(struct device *dev)
        if (!opp_table)
                return NULL;
 
-       mutex_init(&opp_table->lock);
        INIT_LIST_HEAD(&opp_table->dev_list);
 
        opp_dev = _add_opp_dev(dev, opp_table);
@@ -766,6 +757,7 @@ static struct opp_table *_allocate_opp_table(struct device *dev)
 
        BLOCKING_INIT_NOTIFIER_HEAD(&opp_table->head);
        INIT_LIST_HEAD(&opp_table->opp_list);
+       mutex_init(&opp_table->lock);
        kref_init(&opp_table->kref);
 
        /* Secure the device table modification */
@@ -807,10 +799,6 @@ static void _opp_table_kref_release(struct kref *kref)
        if (!IS_ERR(opp_table->clk))
                clk_put(opp_table->clk);
 
-       /*
-        * No need to take opp_table->lock here as we are guaranteed that no
-        * references to the OPP table are taken at this point.
-        */
        opp_dev = list_first_entry(&opp_table->dev_list, struct opp_device,
                                   node);
 
@@ -1714,9 +1702,6 @@ void _dev_pm_opp_remove_table(struct opp_table *opp_table, struct device *dev,
 {
        struct dev_pm_opp *opp, *tmp;
 
-       /* Protect dev_list */
-       mutex_lock(&opp_table->lock);
-
        /* Find if opp_table manages a single device */
        if (list_is_singular(&opp_table->dev_list)) {
                /* Free static OPPs */
@@ -1727,8 +1712,6 @@ void _dev_pm_opp_remove_table(struct opp_table *opp_table, struct device *dev,
        } else {
                _remove_opp_dev(_find_opp_dev(dev, opp_table), opp_table);
        }
-
-       mutex_unlock(&opp_table->lock);
 }
 
 void _dev_pm_opp_find_and_remove_table(struct device *dev, bool remove_all)
index 66e406bd4d628d9746abcd8d3621dc44ba1d23e4..2d87bc1adf38b682d5416a72987115eb68737000 100644 (file)
@@ -222,10 +222,8 @@ int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
        cpumask_clear(cpumask);
 
        if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED) {
-               mutex_lock(&opp_table->lock);
                list_for_each_entry(opp_dev, &opp_table->dev_list, node)
                        cpumask_set_cpu(opp_dev->dev->id, cpumask);
-               mutex_unlock(&opp_table->lock);
        } else {
                cpumask_set_cpu(cpu_dev->id, cpumask);
        }
index 0a206c6b9086820f533b92209c32c38074efd195..166eef99059955ca315126cc1f62a6f239e16616 100644 (file)
@@ -124,7 +124,7 @@ enum opp_table_access {
  * @dev_list:  list of devices that share these OPPs
  * @opp_list:  table of opps
  * @kref:      for reference count of the table.
- * @lock:      mutex protecting the opp_list and dev_list.
+ * @lock:      mutex protecting the opp_list.
  * @np:                struct device_node pointer for opp's DT node.
  * @clock_latency_ns_max: Max clock latency in nanoseconds.
  * @shared_opp: OPP is shared between multiple devices.