Skip to contentSkip to conversation

Thermal: build all thermal framework code into thermal_sys module

PATCH In review Zhang Rui 2 participants 7 messages Mar 29, 2013 – Apr 12, 2013

Subsystems (3)
lore
Share & tools
lore

Zhang Rui

author reviewer
#0 lore raw

v2 cover Thermal: build all thermal framework code into thermal_sys module

A regression introduced by thermal governor feature
is reported in http://marc.info/?l=linux-kernel&m=136085598604095&w=2

And the root cause is that all the thermal governors can not be registered successfully when the thermal framework is built as a module.

Thus I made this patch set to build all the thermal framework component, including governors and cpu_cooling feature into one module so that all the thermal features are loaded/unloaded altogether.

any comments?

thanks,
rui

author reviewer
#1 lore raw

PATCH v2 1/3 Thermal: rename thermal_sys.c to thermal_core.c

this is the preparation work to build all the thermal core framework source file, like governors, cpu cooling, etc, into one module.

No functional change in this patch.

---
 drivers/thermal/Makefile                          |    1 +
 drivers/thermal/{thermal_sys.c => thermal_core.c} |    0
 2 files changed, 1 insertion(+)
 rename drivers/thermal/{thermal_sys.c => thermal_core.c} (100%)
drivers/thermal/Makefile +1 -0
index d3a2b38..b2009bd 100644
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_THERMAL)		+= thermal_sys.o
+thermal_sys-y			+= thermal_core.o
 
 # governors
 obj-$(CONFIG_THERMAL_GOV_FAIR_SHARE)	+= fair_share.o
drivers/thermal/thermal_core.c renamed from drivers/thermal/thermal_sys.c +0 -0
similarity index 100%
rename from drivers/thermal/thermal_sys.c
rename to drivers/thermal/thermal_core.c
Signature · 1 line
1.7.9.5
author reviewer
#5 lore raw

PATCH v2 2/3 Thermal: build thermal governors into thermal_sys module

In reply to Zhang Rui

The thermal governors are part of the thermal framework, rather than a seperate feature/module.
Because the generic thermal layer can not work without thermal governors, and it must load the thermal governors during its initialization.

Build them into one module in this patch.

This also fix a problem that the generic thermal layer does not work when CONFIG_THERMAL=m and CONFIG_THERMAL_GOV_XXX=y.

---
 Documentation/thermal/sysfs-api.txt |    8 -----
 drivers/thermal/Makefile            |    6 ++--
 drivers/thermal/fair_share.c        |   15 ++-------
 drivers/thermal/step_wise.c         |   16 ++--------
 drivers/thermal/thermal_core.c      |   59 ++++++++++++++++++++++++++++-------
 drivers/thermal/thermal_core.h      |   27 ++++++++++++++++
 drivers/thermal/user_space.c        |   15 ++-------
 include/linux/thermal.h             |    4 ---
 8 files changed, 84 insertions(+), 66 deletions(-)
Documentation/thermal/sysfs-api.txt +0 -8
index 6859661..6eac27a 100644
@@ -375,11 +375,3 @@ platform data is provided, this uses the step_wise throttling policy.
 This function serves as an arbitrator to set the state of a cooling
 device. It sets the cooling device to the deepest cooling state if
 possible.
-
-5.5:thermal_register_governor:
-This function lets the various thermal governors to register themselves
-with the Thermal framework. At run time, depending on a zone's platform
-data, a particular governor is used for throttling.
-
-5.6:thermal_unregister_governor:
-This function unregisters a governor from the thermal framework.
drivers/thermal/Makefile +3 -3
index b2009bd..b7fffc7 100644
@@ -6,9 +6,9 @@ obj-$(CONFIG_THERMAL)		+= thermal_sys.o
 thermal_sys-y			+= thermal_core.o
 
 # governors
-obj-$(CONFIG_THERMAL_GOV_FAIR_SHARE)	+= fair_share.o
-obj-$(CONFIG_THERMAL_GOV_STEP_WISE)	+= step_wise.o
-obj-$(CONFIG_THERMAL_GOV_USER_SPACE)	+= user_space.o
+thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE)	+= fair_share.o
+thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE)	+= step_wise.o
+thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE)	+= user_space.o
 
 # cpufreq cooling
 obj-$(CONFIG_CPU_THERMAL)	+= cpu_cooling.o
drivers/thermal/fair_share.c +2 -13
index 792479f..944ba2f 100644
@@ -22,9 +22,6 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
 #include <linux/thermal.h>
 
 #include "thermal_core.h"
@@ -111,23 +108,15 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
 static struct thermal_governor thermal_gov_fair_share = {
 	.name		= "fair_share",
 	.throttle	= fair_share_throttle,
-	.owner		= THIS_MODULE,
 };
 
-static int __init thermal_gov_fair_share_init(void)
+int thermal_gov_fair_share_register(void)
 {
 	return thermal_register_governor(&thermal_gov_fair_share);
 }
 
-static void __exit thermal_gov_fair_share_exit(void)
+void thermal_gov_fair_share_unregister(void)
 {
 	thermal_unregister_governor(&thermal_gov_fair_share);
 }
 
-/* This should load after thermal framework */
-fs_initcall(thermal_gov_fair_share_init);
-module_exit(thermal_gov_fair_share_exit);
-
-MODULE_AUTHOR("Durgadoss R");
-MODULE_DESCRIPTION("A simple weight based thermal throttling governor");
-MODULE_LICENSE("GPL");
drivers/thermal/step_wise.c +2 -14
index 407cde3..a6c9666 100644
@@ -22,9 +22,6 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
 #include <linux/thermal.h>
 
 #include "thermal_core.h"
@@ -180,23 +177,14 @@ static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
 static struct thermal_governor thermal_gov_step_wise = {
 	.name		= "step_wise",
 	.throttle	= step_wise_throttle,
-	.owner		= THIS_MODULE,
 };
 
-static int __init thermal_gov_step_wise_init(void)
+int thermal_gov_step_wise_register(void)
 {
 	return thermal_register_governor(&thermal_gov_step_wise);
 }
 
-static void __exit thermal_gov_step_wise_exit(void)
+void thermal_gov_step_wise_unregister(void)
 {
 	thermal_unregister_governor(&thermal_gov_step_wise);
 }
-
-/* This should load after thermal framework */
-fs_initcall(thermal_gov_step_wise_init);
-module_exit(thermal_gov_step_wise_exit);
-
-MODULE_AUTHOR("Durgadoss R");
-MODULE_DESCRIPTION("A step-by-step thermal throttling governor");
-MODULE_LICENSE("GPL");
drivers/thermal/thermal_core.c +48 -11

92 lines not on this page · raw message

drivers/thermal/thermal_core.h +27 -0
index 0d3205a..7cf2f66 100644
@@ -50,4 +50,31 @@ struct thermal_instance {
 	struct list_head cdev_node; /* node in cdev->thermal_instances */
 };
 
+int thermal_register_governor(struct thermal_governor *);
+void thermal_unregister_governor(struct thermal_governor *);
+
+#ifdef CONFIG_THERMAL_GOV_STEP_WISE
+int thermal_gov_step_wise_register(void);
+void thermal_gov_step_wise_unregister(void);
+#else
+static inline int thermal_gov_step_wise_register(void) { return 0; }
+static inline void thermal_gov_step_wise_unregister(void) {}
+#endif /* CONFIG_THERMAL_GOV_STEP_WISE */
+
+#ifdef CONFIG_THERMAL_GOV_FAIR_SHARE
+int thermal_gov_fair_share_register(void);
+void thermal_gov_fair_share_unregister(void);
+#else
+static inline int thermal_gov_fair_share_register(void) { return 0; }
+static inline void thermal_gov_fair_share_unregister(void) {}
+#endif /* CONFIG_THERMAL_GOV_FAIR_SHARE */
+
+#ifdef CONFIG_THERMAL_GOV_USER_SPACE
+int thermal_gov_user_space_register(void);
+void thermal_gov_user_space_unregister(void);
+#else
+static inline int thermal_gov_user_space_register(void) { return 0; }
+static inline void thermal_gov_user_space_unregister(void) {}
+#endif /* CONFIG_THERMAL_GOV_USER_SPACE */
+
 #endif /* __THERMAL_CORE_H__ */
drivers/thermal/user_space.c +2 -13
index 6bbb380..10adcdd 100644
@@ -22,9 +22,6 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
 #include <linux/thermal.h>
 
 #include "thermal_core.h"
@@ -46,23 +43,15 @@ static int notify_user_space(struct thermal_zone_device *tz, int trip)
 static struct thermal_governor thermal_gov_user_space = {
 	.name		= "user_space",
 	.throttle	= notify_user_space,
-	.owner		= THIS_MODULE,
 };
 
-static int __init thermal_gov_user_space_init(void)
+int thermal_gov_user_space_register(void)
 {
 	return thermal_register_governor(&thermal_gov_user_space);
 }
 
-static void __exit thermal_gov_user_space_exit(void)
+void thermal_gov_user_space_unregister(void)
 {
 	thermal_unregister_governor(&thermal_gov_user_space);
 }
 
-/* This should load after thermal framework */
-fs_initcall(thermal_gov_user_space_init);
-module_exit(thermal_gov_user_space_exit);
-
-MODULE_AUTHOR("Durgadoss R");
-MODULE_DESCRIPTION("A user space Thermal notifier");
-MODULE_LICENSE("GPL");
include/linux/thermal.h +0 -4
index f0bd7f9..af03ea6 100644
@@ -184,7 +184,6 @@ struct thermal_governor {
 	char name[THERMAL_NAME_LENGTH];
 	int (*throttle)(struct thermal_zone_device *tz, int trip);
 	struct list_head	governor_list;
-	struct module		*owner;
 };
 
 /* Structure that holds binding parameters for a zone */
@@ -244,9 +243,6 @@ struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 void thermal_cdev_update(struct thermal_cooling_device *);
 void notify_thermal_framework(struct thermal_zone_device *, int);
 
-int thermal_register_governor(struct thermal_governor *);
-void thermal_unregister_governor(struct thermal_governor *);
-
 #ifdef CONFIG_NET
 extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
 						enum events event);
Signature · 1 line
1.7.9.5
author reviewer
#6 lore raw

PATCH v2 3/3 Thermal: build cpu_cooling code into thermal_sys module

In reply to Zhang Rui
---
 drivers/thermal/Kconfig     |    2 +-
 drivers/thermal/Makefile    |    2 +-
 include/linux/cpu_cooling.h |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/thermal/Kconfig +1 -1
index a764f16..10014de 100644
@@ -67,7 +67,7 @@ config THERMAL_GOV_USER_SPACE
 	  Enable this to let the user space manage the platform thermals.
 
 config CPU_THERMAL
-	tristate "generic cpu cooling support"
+	bool "generic cpu cooling support"
 	depends on CPU_FREQ
 	select CPU_FREQ_TABLE
 	help
drivers/thermal/Makefile +1 -1
index b7fffc7..cae124f 100644
@@ -11,7 +11,7 @@ thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE)	+= step_wise.o
 thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE)	+= user_space.o
 
 # cpufreq cooling
-obj-$(CONFIG_CPU_THERMAL)	+= cpu_cooling.o
+thermal_sys-$(CONFIG_CPU_THERMAL)	+= cpu_cooling.o
 
 # platform thermal drivers
 obj-$(CONFIG_SPEAR_THERMAL)	+= spear_thermal.o
include/linux/cpu_cooling.h +1 -1
index 40b4ef5..b30cc79c 100644
@@ -29,7 +29,7 @@
 #define CPUFREQ_COOLING_START		0
 #define CPUFREQ_COOLING_STOP		1
 
-#if defined(CONFIG_CPU_THERMAL) || defined(CONFIG_CPU_THERMAL_MODULE)
+#ifdef CONFIG_CPU_THERMAL
 /**
  * cpufreq_cooling_register - function to create cpufreq cooling device.
  * @clip_cpus: cpumask of cpus where the frequency constraints will happen
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH V2 1/3] Thermal: rename thermal_sys.c to thermal_core.c

In reply to Zhang Rui
Quoted 6 lines · Zhang Rui

this is the preparation work to build all the thermal core framework source file, like governors, cpu cooling, etc, into one module.

No functional change in this patch.

Durga and me have already reviewed and acked this patch. Can you please add our Acked-by on this patch?

Quoted 23 lines
---
  drivers/thermal/Makefile                          |    1 +
  drivers/thermal/{thermal_sys.c => thermal_core.c} |    0
  2 files changed, 1 insertion(+)

rename drivers/thermal/{thermal_sys.c => thermal_core.c} (100%)

drivers/thermal/Makefile +1 -0
index d3a2b38..b2009bd 100644
@@ -3,6 +3,7 @@
  #
 
  obj-$(CONFIG_THERMAL)		+= thermal_sys.o
+thermal_sys-y			+= thermal_core.o
 
  # governors
  obj-$(CONFIG_THERMAL_GOV_FAIR_SHARE)	+= fair_share.o
drivers/thermal/thermal_core.c renamed from drivers/thermal/thermal_sys.c +0 -0
similarity index 100%
rename from drivers/thermal/thermal_sys.c
rename to drivers/thermal/thermal_core.c
author reviewer
#3 lore raw

Re: [PATCH V2 1/3] Thermal: rename thermal_sys.c to thermal_core.c

Quoted 10 lines · Eduardo Valentin
Quoted 6 lines · Zhang Rui

this is the preparation work to build all the thermal core framework source file, like governors, cpu cooling, etc, into one module.

No functional change in this patch.

Durga and me have already reviewed and acked this patch. Can you please add our Acked-by on this patch?

sure.
BTW, I've talked with Rafael, and we agree on adding prefix "acpi_" for ACPI drivers, and then we can rename thermal_sys.ko to thermal.ko.

But I'll try to push this patch set for 3.10, to fix the problem on hand, also for easily back porting to 3.8 and 3.9 stable kernel. Then, we'll rename a couple of ACPI drivers and then thermal driver in 3.11.

what do you think?

thanks,
rui

Quoted 25 lines
Quoted 24 lines
---
  drivers/thermal/Makefile                          |    1 +
  drivers/thermal/{thermal_sys.c => thermal_core.c} |    0
  2 files changed, 1 insertion(+)

rename drivers/thermal/{thermal_sys.c => thermal_core.c} (100%)

drivers/thermal/Makefile +1 -0
index d3a2b38..b2009bd 100644
@@ -3,6 +3,7 @@
  #
 
  obj-$(CONFIG_THERMAL)		+= thermal_sys.o
+thermal_sys-y			+= thermal_core.o
 
  # governors
  obj-$(CONFIG_THERMAL_GOV_FAIR_SHARE)	+= fair_share.o
drivers/thermal/thermal_core.c renamed from drivers/thermal/thermal_sys.c +0 -0
similarity index 100%
rename from drivers/thermal/thermal_sys.c
rename to drivers/thermal/thermal_core.c
#4 lore raw

Re: [PATCH V2 1/3] Thermal: rename thermal_sys.c to thermal_core.c

Quoted 7 lines · Zhang Rui
Quoted 6 lines · Eduardo Valentin
Quoted 5 lines · Zhang Rui

this is the preparation work to build all the thermal core framework source file, like governors, cpu cooling, etc, into one module.

No functional change in this patch.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Durga and me have already reviewed and acked this patch. Can you please add our Acked-by on this patch?

sure.
BTW, I've talked with Rafael, and we agree on adding prefix "acpi_" for ACPI drivers, and then we can rename thermal_sys.ko to thermal.ko.

Good!

Quoted 6 lines

But I'll try to push this patch set for 3.10, to fix the problem on hand, also for easily back porting to 3.8 and 3.9 stable kernel. Then, we'll rename a couple of ACPI drivers and then thermal driver in 3.11.

what do you think?

I am OK with this approach.

Thanks for keeping this up.

Quoted 33 lines

thanks,
rui

Quoted 25 lines
Quoted 24 lines
---
   drivers/thermal/Makefile                          |    1 +
   drivers/thermal/{thermal_sys.c => thermal_core.c} |    0
   2 files changed, 1 insertion(+)

rename drivers/thermal/{thermal_sys.c => thermal_core.c} (100%)

drivers/thermal/Makefile +1 -0
index d3a2b38..b2009bd 100644
@@ -3,6 +3,7 @@
   #
 
   obj-$(CONFIG_THERMAL)		+= thermal_sys.o
+thermal_sys-y			+= thermal_core.o
 
   # governors
   obj-$(CONFIG_THERMAL_GOV_FAIR_SHARE)	+= fair_share.o
drivers/thermal/thermal_core.c renamed from drivers/thermal/thermal_sys.c +0 -0
similarity index 100%
rename from drivers/thermal/thermal_sys.c
rename to drivers/thermal/thermal_core.c