All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] opp: Reinitialize the list_kref before adding the static OPPs again
@ 2019-10-18  9:28 Viresh Kumar
  2019-10-18 15:35 ` Dmitry Osipenko
  2019-10-18 21:12 ` Stephen Boyd
  0 siblings, 2 replies; 9+ messages in thread
From: Viresh Kumar @ 2019-10-18  9:28 UTC (permalink / raw)
  To: Viresh Kumar, Nishanth Menon, Stephen Boyd
  Cc: Viresh Kumar, linux-pm, Vincent Guittot, Rafael Wysocki,
	Dmitry Osipenko, linux-kernel

The list_kref reaches a count of 0 when all the static OPPs are removed,
for example when dev_pm_opp_of_cpumask_remove_table() is called, though
the actual OPP table may not get freed as it may still be referenced by
other parts of the kernel, like from a call to
dev_pm_opp_set_supported_hw(). And if we call
dev_pm_opp_of_cpumask_add_table() again at this point, we must
reinitialize the list_kref otherwise the kernel will hit a WARN() in
kref infrastructure for incrementing a kref with value 0.

Fixes: 11e1a1648298 ("opp: Don't decrement uninitialized list_kref")
Reported-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/opp/of.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 6dc41faf74b5..1cbb58240b80 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -663,6 +663,13 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
 		return 0;
 	}
 
+	/*
+	 * Re-initialize list_kref every time we add static OPPs to the OPP
+	 * table as the reference count may be 0 after the last tie static OPPs
+	 * were removed.
+	 */
+	kref_init(&opp_table->list_kref);
+
 	/* We have opp-table node now, iterate over it and add OPPs */
 	for_each_available_child_of_node(opp_table->np, np) {
 		opp = _opp_add_static_v2(opp_table, dev, np);
-- 
2.21.0.rc0.269.g1a574e7a288b


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-11-11 11:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18  9:28 [PATCH] opp: Reinitialize the list_kref before adding the static OPPs again Viresh Kumar
2019-10-18 15:35 ` Dmitry Osipenko
2019-10-21  2:18   ` Viresh Kumar
2019-10-18 21:12 ` Stephen Boyd
2019-10-21  2:25   ` Viresh Kumar
2019-10-28 12:01     ` Stephen Boyd
2019-10-30  7:50       ` Viresh Kumar
     [not found]         ` <20191030143400.1680D20656@mail.kernel.org>
2019-11-11  8:21           ` Viresh Kumar
2019-11-11 11:31             ` Viresh Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.