Skip to contentSkip to conversation

cpufreq: tegra194: remove opp table in exit hook

PATCH In review Sumit Gupta 2 participants 4 messages Aug 25, 2023 – Aug 28, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpufreq: tegra194: remove opp table in exit hook

Add exit hook and remove OPP table when the device gets unregistered. This will fix the error messages when the CPU FREQ driver module is removed and then re-inserted. It also fixes these messages while onlining the first CPU from a policy whose all CPU's were previously offlined.

debugfs: File 'cpu5' in directory 'opp' already present!
debugfs: File 'cpu6' in directory 'opp' already present!
debugfs: File 'cpu7' in directory 'opp' already present!

Fixes f41e1442ac5b ("cpufreq: tegra194: add OPP support and set bandwidth")

---

v1[1] -> v2:
- updated commit description.

[1] https://lore.kernel.org/lkml/[email protected]/

 drivers/cpufreq/tegra194-cpufreq.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/cpufreq/tegra194-cpufreq.c +13 -0
index c90b30469165..66a9c23544db 100644
@@ -454,6 +454,8 @@ static int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy,
 		if (ret < 0)
 			return ret;
 
+		dev_pm_opp_put(opp);
+
 		freq_table[j].driver_data = pos->driver_data;
 		freq_table[j].frequency = pos->frequency;
 		j++;
@@ -508,6 +510,16 @@ static int tegra194_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
+static int tegra194_cpufreq_exit(struct cpufreq_policy *policy)
+{
+	struct device *cpu_dev = get_cpu_device(policy->cpu);
+
+	dev_pm_opp_remove_all_dynamic(cpu_dev);
+	dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
+
+	return 0;
+}
+
 static int tegra194_cpufreq_set_target(struct cpufreq_policy *policy,
 				       unsigned int index)
 {
@@ -535,6 +547,7 @@ static struct cpufreq_driver tegra194_cpufreq_driver = {
 	.target_index = tegra194_cpufreq_set_target,
 	.get = tegra194_get_speed,
 	.init = tegra194_cpufreq_init,
+	.exit = tegra194_cpufreq_exit,
 	.attr = cpufreq_generic_attr,
 };
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 27 lines · Sumit Gupta

Add exit hook and remove OPP table when the device gets unregistered. This will fix the error messages when the CPU FREQ driver module is removed and then re-inserted. It also fixes these messages while onlining the first CPU from a policy whose all CPU's were previously offlined.

debugfs: File 'cpu5' in directory 'opp' already present!
debugfs: File 'cpu6' in directory 'opp' already present!
debugfs: File 'cpu7' in directory 'opp' already present!

Fixes f41e1442ac5b ("cpufreq: tegra194: add OPP support and set bandwidth")

---

v1[1] -> v2:
- updated commit description.

[1] https://lore.kernel.org/lkml/[email protected]/

 drivers/cpufreq/tegra194-cpufreq.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/cpufreq/tegra194-cpufreq.c +0 -0
index c90b30469165..66a9c23544db 100644

drivers/cpufreq/tegra194-cpufreq.c static int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, · line 458

Quoted 5 lines
drivers/cpufreq/tegra194-cpufreq.c +2 -0
@@ -454,6 +454,8 @@ static int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy,
 		if (ret < 0)
 			return ret;
 
+		dev_pm_opp_put(opp);
+

Missed this earlier, can you please do this in a separate patch please ?

Quoted 30 lines
drivers/cpufreq/tegra194-cpufreq.c +11 -0
 		freq_table[j].driver_data = pos->driver_data;
 		freq_table[j].frequency = pos->frequency;
 		j++;
@@ -508,6 +510,16 @@ static int tegra194_cpufreq_init(struct cpufreq_policy *policy)
 	return 0;
 }
 
+static int tegra194_cpufreq_exit(struct cpufreq_policy *policy)
+{
+	struct device *cpu_dev = get_cpu_device(policy->cpu);
+
+	dev_pm_opp_remove_all_dynamic(cpu_dev);
+	dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
+
+	return 0;
+}
+
 static int tegra194_cpufreq_set_target(struct cpufreq_policy *policy,
 				       unsigned int index)
 {
@@ -535,6 +547,7 @@ static struct cpufreq_driver tegra194_cpufreq_driver = {
 	.target_index = tegra194_cpufreq_set_target,
 	.get = tegra194_get_speed,
 	.init = tegra194_cpufreq_init,
+	.exit = tegra194_cpufreq_exit,
 	.attr = cpufreq_generic_attr,
 };
 
Signature · 1 line
2.17.1
Signature · 1 line
viresh
maintainer
#2 lore raw
Quoted 31 lines · Viresh Kumar
Quoted 30 lines · Sumit Gupta

Add exit hook and remove OPP table when the device gets unregistered. This will fix the error messages when the CPU FREQ driver module is removed and then re-inserted. It also fixes these messages while onlining the first CPU from a policy whose all CPU's were previously offlined.

debugfs: File 'cpu5' in directory 'opp' already present!
debugfs: File 'cpu6' in directory 'opp' already present!
debugfs: File 'cpu7' in directory 'opp' already present!

Fixes f41e1442ac5b ("cpufreq: tegra194: add OPP support and set bandwidth")

---

v1[1] -> v2:
- updated commit description.

[1] https://lore.kernel.org/lkml/[email protected]/

 drivers/cpufreq/tegra194-cpufreq.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/cpufreq/tegra194-cpufreq.c +0 -0
index c90b30469165..66a9c23544db 100644
@@ -454,6 +454,8 @@ static int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy,
 		if (ret < 0)
 			return ret;
 
Quoted 5 lines

drivers/cpufreq/tegra194-cpufreq.c static int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, · line 458

Quoted 2 lines
drivers/cpufreq/tegra194-cpufreq.c +2 -0
+		dev_pm_opp_put(opp);
+

Missed this earlier, can you please do this in a separate patch please ?

I have pushed rest of this commit and dropped this part. Send it separately. Thanks.

Signature · 1 line
viresh
#3 lore raw
Quoted 41 lines · Viresh Kumar

External email: Use caution opening links or attachments

Quoted 31 lines · Viresh Kumar
Quoted 30 lines · Sumit Gupta

Add exit hook and remove OPP table when the device gets unregistered. This will fix the error messages when the CPU FREQ driver module is removed and then re-inserted. It also fixes these messages while onlining the first CPU from a policy whose all CPU's were previously offlined.

debugfs: File 'cpu5' in directory 'opp' already present!
debugfs: File 'cpu6' in directory 'opp' already present!
debugfs: File 'cpu7' in directory 'opp' already present!

Fixes f41e1442ac5b ("cpufreq: tegra194: add OPP support and set bandwidth")

---

v1[1] -> v2:
- updated commit description.

[1] https://lore.kernel.org/lkml/[email protected]/

  drivers/cpufreq/tegra194-cpufreq.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/cpufreq/tegra194-cpufreq.c +0 -0
index c90b30469165..66a9c23544db 100644
@@ -454,6 +454,8 @@ static int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy,
             if (ret < 0)
                     return ret;
 
Quoted 5 lines

drivers/cpufreq/tegra194-cpufreq.c static int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy, · line 458

Quoted 2 lines
drivers/cpufreq/tegra194-cpufreq.c +2 -0
+           dev_pm_opp_put(opp);
+

Missed this earlier, can you please do this in a separate patch please ?

Quoted 5 lines

I have pushed rest of this commit and dropped this part. Send it separately. Thanks.

--
viresh

Thank you.
Sent the change separately @
https://lore.kernel.org/lkml/[email protected]/

Regards,
Sumit Gupta