Skip to contentSkip to conversation

PM: OPP: introduce function to free cpufreq table

PATCH Superseded Nishanth Menon 3 participants 7 messages May 23, 2011 – May 24, 2011

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: OPP: introduce function to free cpufreq table

cpufreq table allocated by opp_init_cpufreq_table is better freed by OPP layer itself. This allows future modifications to the table handling to be transparent to the users.

---

Example discussion: http://marc.info/?t=130570440600005&r=1&w=2

 Documentation/power/opp.txt |    2 ++
 drivers/base/power/opp.c    |   20 ++++++++++++++++++++
 include/linux/opp.h         |    8 ++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
Documentation/power/opp.txt +2 -0
index 5ae70a1..3035d00 100644
@@ -321,6 +321,8 @@ opp_init_cpufreq_table - cpufreq framework typically is initialized with
 	addition to CONFIG_PM as power management feature is required to
 	dynamically scale voltage and frequency in a system.
 
+opp_free_cpufreq_table - Free up the table allocated by opp_init_cpufreq_table
+
 7. Data Structures
 ==================
 Typically an SoC contains multiple voltage domains which are variable. Each
drivers/base/power/opp.c +20 -0
index 56a6899..bf0c2ee 100644
@@ -625,4 +625,24 @@ int opp_init_cpufreq_table(struct device *dev,
 
 	return 0;
 }
+
+/**
+ * opp_free_cpufreq_table() - free the cpufreq table
+ * @dev:	device for which we do this operation
+ * @table:	table to free
+ *
+ * Free up the table allocated by opp_init_cpufreq_table
+ */
+void opp_free_cpufreq_table(struct device *dev,
+				struct cpufreq_frequency_table **table)
+{
+	if (!table)
+		return;
+
+	/* Pretend as if I am an updater */
+	mutex_lock(&dev_opp_list_lock);
+	kfree(*table);
+	*table = NULL;
+	mutex_unlock(&dev_opp_list_lock);
+}
 #endif		/* CONFIG_CPU_FREQ */
include/linux/opp.h +8 -0
index 5449945..7020e97 100644
@@ -94,12 +94,20 @@ static inline int opp_disable(struct device *dev, unsigned long freq)
 #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
 int opp_init_cpufreq_table(struct device *dev,
 			    struct cpufreq_frequency_table **table);
+void opp_free_cpufreq_table(struct device *dev,
+				struct cpufreq_frequency_table **table);
 #else
 static inline int opp_init_cpufreq_table(struct device *dev,
 			    struct cpufreq_frequency_table **table)
 {
 	return -EINVAL;
 }
+
+static inline
+void opp_free_cpufreq_table(struct device *dev,
+				struct cpufreq_frequency_table **table)
+{
+}
 #endif		/* CONFIG_CPU_FREQ */
 
 #endif		/* __LINUX_OPP_H__ */
Signature · 1 line
1.7.1
#1 lore raw
Quoted 3 lines · Nishanth Menon

cpufreq table allocated by opp_init_cpufreq_table is better freed by OPP layer itself. This allows future modifications to the table handling to be transparent to the users.

...

drivers/base/power/opp.c int opp_init_cpufreq_table(struct device *dev, · line 647

Quoted 12 lines
drivers/base/power/opp.c +12 -0
+void opp_free_cpufreq_table(struct device *dev,
+				struct cpufreq_frequency_table **table)
+{
+	if (!table)
+		return;
+
+	/* Pretend as if I am an updater */
+	mutex_lock(&dev_opp_list_lock);
+	kfree(*table);
+	*table = NULL;
+	mutex_unlock(&dev_opp_list_lock);
+}

Not clear what the mutex protects here. Currently it protects only device opp list modifications. opp_init_cpufreq_table holds the lock only while looking up and walking the device opp list; the cpufreq table it creates is not complete by the time the lock is dropped.

Todd

#2 lore raw
In reply to Nishanth Menon
Quoted 3 lines · Nishanth Menon

cpufreq table allocated by opp_init_cpufreq_table is better freed by OPP layer itself. This allows future modifications to the table handling to be transparent to the users.

...

drivers/base/power/opp.c int opp_init_cpufreq_table(struct device *dev, · line 647

Quoted 12 lines
drivers/base/power/opp.c +12 -0
+void opp_free_cpufreq_table(struct device *dev,
+				struct cpufreq_frequency_table **table)
+{
+	if (!table)
+		return;
+
+	/* Pretend as if I am an updater */
+	mutex_lock(&dev_opp_list_lock);
+	kfree(*table);
+	*table = NULL;
+	mutex_unlock(&dev_opp_list_lock);
+}

Not clear what the mutex protects here. Currently it protects only device opp list modifications. opp_init_cpufreq_table holds the lock only while looking up and walking the device opp list; the cpufreq table it creates is not complete by the time the lock is dropped.

Todd

#3 lore raw
Quoted 14 lines · Todd Poynor
Quoted 3 lines · Nishanth Menon

cpufreq table allocated by opp_init_cpufreq_table is better freed by OPP layer itself. This allows future modifications to the table handling to be transparent to the users.

...

Quoted 9 lines
drivers/base/power/opp.c +9 -0
+void opp_free_cpufreq_table(struct device *dev,
+                             struct cpufreq_frequency_table **table)
+{
+     if (!table)
+             return;
+
+     /* Pretend as if I am an updater */
+     mutex_lock(&dev_opp_list_lock);
+     kfree(*table);
Quoted 8 lines
Quoted 3 lines

+     *table = NULL;
+     mutex_unlock(&dev_opp_list_lock);
+}

Not clear what the mutex protects here.  Currently it protects only device opp list modifications.  opp_init_cpufreq_table holds the lock only while looking up and walking the device opp list; the cpufreq table it creates is not complete by the time the lock is dropped.

hmm.. right.. mutex protection does'nt really make sense here..

Regards,
Nishanth Menon

#4 lore raw
In reply to Todd Poynor
Quoted 14 lines · Todd Poynor
Quoted 3 lines · Nishanth Menon

cpufreq table allocated by opp_init_cpufreq_table is better freed by OPP layer itself. This allows future modifications to the table handling to be transparent to the users.

...

Quoted 9 lines
drivers/base/power/opp.c +9 -0
+void opp_free_cpufreq_table(struct device *dev,
+                             struct cpufreq_frequency_table **table)
+{
+     if (!table)
+             return;
+
+     /* Pretend as if I am an updater */
+     mutex_lock(&dev_opp_list_lock);
+     kfree(*table);
Quoted 8 lines
Quoted 3 lines

+     *table = NULL;
+     mutex_unlock(&dev_opp_list_lock);
+}

Not clear what the mutex protects here.  Currently it protects only device opp list modifications.  opp_init_cpufreq_table holds the lock only while looking up and walking the device opp list; the cpufreq table it creates is not complete by the time the lock is dropped.

hmm.. right.. mutex protection does'nt really make sense here..

Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 24 lines · Nishanth
Quoted 14 lines · Todd Poynor
Quoted 3 lines · Nishanth Menon

cpufreq table allocated by opp_init_cpufreq_table is better freed by OPP layer itself. This allows future modifications to the table handling to be transparent to the users.

...

Quoted 9 lines
drivers/base/power/opp.c +9 -0
+void opp_free_cpufreq_table(struct device *dev,
+                             struct cpufreq_frequency_table **table)
+{
+     if (!table)
+             return;
+
+     /* Pretend as if I am an updater */
+     mutex_lock(&dev_opp_list_lock);
+     kfree(*table);
Quoted 8 lines

drivers/base/power/opp.c int opp_init_cpufreq_table(struct device *dev, · line 647

Quoted 3 lines
drivers/base/power/opp.c +3 -0
+     *table = NULL;
+     mutex_unlock(&dev_opp_list_lock);
+}

Not clear what the mutex protects here. Currently it protects only device opp list modifications. opp_init_cpufreq_table holds the lock only while looking up and walking the device opp list; the cpufreq table it creates is not complete by the time the lock is dropped.

Quoted 1 line

hmm.. right.. mutex protection does'nt really make sense here..

Care to post an updated patch?

Rafael

#6 lore raw
In reply to Menon, Nishanth
Quoted 24 lines · Nishanth
Quoted 14 lines · Todd Poynor
Quoted 3 lines · Nishanth Menon

cpufreq table allocated by opp_init_cpufreq_table is better freed by OPP layer itself. This allows future modifications to the table handling to be transparent to the users.

...

Quoted 9 lines
drivers/base/power/opp.c +9 -0
+void opp_free_cpufreq_table(struct device *dev,
+                             struct cpufreq_frequency_table **table)
+{
+     if (!table)
+             return;
+
+     /* Pretend as if I am an updater */
+     mutex_lock(&dev_opp_list_lock);
+     kfree(*table);
Quoted 8 lines

drivers/base/power/opp.c int opp_init_cpufreq_table(struct device *dev, · line 647

Quoted 3 lines
drivers/base/power/opp.c +3 -0
+     *table = NULL;
+     mutex_unlock(&dev_opp_list_lock);
+}

Not clear what the mutex protects here. Currently it protects only device opp list modifications. opp_init_cpufreq_table holds the lock only while looking up and walking the device opp list; the cpufreq table it creates is not complete by the time the lock is dropped.

Quoted 1 line

hmm.. right.. mutex protection does'nt really make sense here..

Care to post an updated patch?

Rafael