2014-04-27 01:30:00

by Peter Kästle

[permalink] [raw]
Subject: [PATCH 0/4] acerhdf/thermal: adding new models and appropriate governor

Hi,

finally I found time, to do some work on acerhdf.

This patch series is intended to:

* Introduce "manual mode" support (Patch 1 & 2), which is needed to control
the fan of a few new models. Unfortunately this extends lines defining
the bios table over 80 characters, but all other methods make the code
really ugly and hard to read. So I hope for the reason of readability it
is ok to break this rule.

* Add an appropriate thermal governor (Patch 3 & 4). Manipulating and
fiddling around with the step-wise governor has been a very fragile thing
in the past and as it broke again, I used the opportunity to add a two
point thermal governor which implements the actual fan handling required by
acerhdf and puts from my point of view things straight.

Please test/review the patches and send me your comments.

Thanks and kind regards,
peter


Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Zhang Rui <[email protected]>

Peter Feuerer (4):
acerhdf: Adding support for "manual mode"
acerhdf: Adding support for new models
thermal: Added Bang-bang thermal governor
acerhdf: Use bang-bang thermal governor

drivers/platform/x86/Kconfig | 2 +-
drivers/platform/x86/acerhdf.c | 246 +++++++++++++++++++++++++---------------
drivers/thermal/Kconfig | 10 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/gov_bang_bang.c | 124 ++++++++++++++++++++
drivers/thermal/thermal_core.c | 5 +
drivers/thermal/thermal_core.h | 8 ++
7 files changed, 304 insertions(+), 92 deletions(-)
create mode 100644 drivers/thermal/gov_bang_bang.c

--
1.9.2


2014-04-27 01:30:50

by Peter Kästle

[permalink] [raw]
Subject: [PATCH 4/4] acerhdf: Use bang-bang thermal governor

From: Peter Feuerer <[email protected]>

acerhdf has been doing an on-off fan control using hysteresis by
post-manipulating the outcome of thermal subsystem trip point handling.
This patch enables acerhdf to use the bang-bang governor, which is
intended for on-off controlled fans.

CC: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/Kconfig | 2 +-
drivers/platform/x86/acerhdf.c | 45 ++++++++++++++++++++++++++++++++++--------
2 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 27df2c5..bbc5dd2 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -38,7 +38,7 @@ config ACER_WMI

config ACERHDF
tristate "Acer Aspire One temperature and fan driver"
- depends on THERMAL && ACPI
+ depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG
---help---
This is a driver for Acer Aspire One netbooks. It allows to access
the temperature sensor and to control the fan.
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 8b6466b..acba516 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.30"
+#define DRV_VER "0.5.31"

/*
* According to the Atom N270 datasheet,
@@ -130,8 +130,8 @@ struct bios_settings_t {
const char *vendor;
const char *product;
const char *version;
- unsigned char fanreg;
- unsigned char tempreg;
+ u8 fanreg;
+ u8 tempreg;
struct fancmd cmd;
struct manualcmd mcmd;
};
@@ -253,6 +253,14 @@ static const struct bios_settings_t bios_tbl[] = {

static const struct bios_settings_t *bios_cfg __read_mostly;

+/* used to force thermal to use bang_bang governor for acerhdf */
+static struct thermal_zone_params acerhdf_zone_params = {
+ .governor_name = "bang_bang",
+ .no_hwmon = 0,
+ .num_tbps = 0,
+ .tbp = 0,
+};
+
static int acerhdf_get_temp(int *temp)
{
u8 read_temp;
@@ -430,6 +438,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*type = THERMAL_TRIP_ACTIVE;
+ if (trip == 1)
+ *type = THERMAL_TRIP_CRITICAL;
+
+ return 0;
+}
+
+static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
+ unsigned long *temp)
+{
+ if (trip == 0)
+ *temp = fanon - fanoff;

return 0;
}
@@ -439,6 +458,8 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*temp = fanon;
+ else if (trip == 1)
+ *temp = ACERHDF_TEMP_CRIT;

return 0;
}
@@ -458,8 +479,10 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
.get_mode = acerhdf_get_mode,
.set_mode = acerhdf_set_mode,
.get_trip_type = acerhdf_get_trip_type,
+ .get_trip_hyst = acerhdf_get_trip_hyst,
.get_trip_temp = acerhdf_get_trip_temp,
.get_crit_temp = acerhdf_get_crit_temp,
+ .notify = NULL,
};


@@ -510,9 +533,7 @@ static int acerhdf_set_cur_state(struct thermal_cooling_device *cdev,
}

if (state == 0) {
- /* turn fan off only if below fanoff temperature */
- if ((cur_state == ACERHDF_FAN_AUTO) &&
- (cur_temp < fanoff))
+ if (cur_state == ACERHDF_FAN_AUTO)
acerhdf_change_fanstate(ACERHDF_FAN_OFF);
} else {
if (cur_state == ACERHDF_FAN_OFF)
@@ -690,12 +711,20 @@ static int acerhdf_register_thermal(void)
if (IS_ERR(cl_dev))
return -EINVAL;

- thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
- &acerhdf_dev_ops, NULL, 0,
+ thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL,
+ &acerhdf_dev_ops,
+ &acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
if (IS_ERR(thz_dev))
return -EINVAL;

+ if (strcmp(thz_dev->governor->name,
+ acerhdf_zone_params.governor_name)) {
+ pr_err("Thermal governor %s is not compiled into thermal subsystem\n",
+ acerhdf_zone_params.governor_name);
+ return -EINVAL;
+ }
+
return 0;
}

--
1.9.2

2014-04-27 01:31:30

by Peter Kästle

[permalink] [raw]
Subject: [PATCH 1/4] acerhdf: Adding support for "manual mode"

From: Peter Feuerer <[email protected]>

Some Acer models require an additional command to turn off the fan after
bios mode has been enabled. Adding new section in bios table to allow
support for those models, by writing an extra "manual mode" register.

Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 181 ++++++++++++++++++++++-------------------
1 file changed, 97 insertions(+), 84 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f94467c..eb9c94f 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.26"
+#define DRV_VER "0.5.29"

/*
* According to the Atom N270 datasheet,
@@ -119,6 +119,12 @@ struct fancmd {
u8 cmd_auto;
};

+struct manualcmd {
+ int enable;
+ u8 mreg;
+ u8 moff;
+};
+
/* BIOS settings */
struct bios_settings_t {
const char *vendor;
@@ -127,105 +133,106 @@ struct bios_settings_t {
unsigned char fanreg;
unsigned char tempreg;
struct fancmd cmd;
+ struct manualcmd mcmd;
};

/* Register addresses and values for different BIOS versions */
static const struct bios_settings_t bios_tbl[] = {
/* AOA110 */
- {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
/* AOA150 */
- {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
/* LT1005u */
- {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
/* Acer 1410 */
- {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
/* Acer 1810xx */
- {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
/* Acer 531 */
- {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
/* Acer 751 */
- {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
/* Acer 1825 */
- {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
/* Acer TravelMate 7730 */
- {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00} },
+ {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, {0, 0, 0} },
/* Gateway */
- {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
- {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} },
- {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
+ {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
+ {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
/* Packard Bell */
- {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
+ {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
/* pewpew-terminator */
- {"", "", "", 0, 0, {0, 0} }
+ {"", "", "", 0, 0, {0, 0}, {0, 0, 0} }
};

static const struct bios_settings_t *bios_cfg __read_mostly;
@@ -275,6 +282,12 @@ static void acerhdf_change_fanstate(int state)
fanstate = state;

ec_write(bios_cfg->fanreg, cmd);
+
+ if (bios_cfg->mcmd.enable && state == ACERHDF_FAN_OFF) {
+ if (verbose)
+ pr_notice("turning off fan manually\n");
+ ec_write(bios_cfg->mcmd.mreg, bios_cfg->mcmd.moff);
+ }
}

static void acerhdf_check_param(struct thermal_zone_device *thermal)
--
1.9.2

2014-04-27 01:31:28

by Peter Kästle

[permalink] [raw]
Subject: [PATCH 2/4] acerhdf: Adding support for new models

From: Peter Feuerer <[email protected]>

added following new models:
* Aspire 5755G
* AO521
* AO751h
* Aspire One 753
* Extensa 5420
* Aspire 5315
* Aspire 5739G
* TravelMate TM8573T

Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index eb9c94f..8b6466b 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.29"
+#define DRV_VER "0.5.30"

/*
* According to the Atom N270 datasheet,
@@ -194,17 +194,33 @@ static const struct bios_settings_t bios_tbl[] = {
{"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
{"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
{"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ /* Acer 5755G */
+ {"Acer", "Aspire 5755G", "V1.20", 0xab, 0xb4, {0x00, 0x08}, {0, 0, 0} },
+ {"Acer", "Aspire 5755G", "V1.21", 0xab, 0xb3, {0x00, 0x08}, {0, 0, 0} },
+ /* Acer 521 */
+ {"Acer", "AO521", "V1.11", 0x55, 0x58, {0x1f, 0x00}, {0, 0, 0} },
/* Acer 531 */
{"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
{"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
{"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
/* Acer 751 */
+ {"Acer", "AO751h", "V0.3206", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
{"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
+ /* Acer 753 */
+ {"Acer", "Aspire One 753", "V1.24", 0x93, 0xac, {0x14, 0x04}, {1, 0x94, 0xff} },
/* Acer 1825 */
{"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
{"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, {0, 0, 0} },
+ /* Acer Extensa 5420 */
+ {"Acer", "Extensa 5420", "V1.17", 0x93, 0xac, {0x14, 0x04}, {1, 0x94, 0xff} },
+ /* Acer Aspire 5315 */
+ {"Acer", "Aspire 5315", "V1.19", 0x93, 0xac, {0x14, 0x04}, {1, 0x94, 0xff} },
+ /* Acer Aspire 5739 */
+ {"Acer", "Aspire 5739G", "V1.3311", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
/* Acer TravelMate 7730 */
{"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, {0, 0, 0} },
+ /* Acer TravelMate TM8573T */
+ {"Acer", "TM8573T", "V1.13", 0x93, 0xa8, {0x14, 0x04}, {1, 0x94, 0xff} },
/* Gateway */
{"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, {0, 0, 0} },
{"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, {0, 0, 0} },
@@ -736,9 +752,14 @@ MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO751h*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1410*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1810*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5755G:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1825PTZ:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAO521*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO531*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5739G:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5315:");
MODULE_ALIAS("dmi:*:*Acer*:TravelMate*7730G:");
+MODULE_ALIAS("dmi:*:*Acer*:TM8573T:");
MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnAOA*:");
@@ -747,6 +768,7 @@ MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMU*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnENBFT*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMA*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTVR46*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnExtensa 5420*:");

module_init(acerhdf_init);
module_exit(acerhdf_exit);
--
1.9.2

2014-04-27 01:31:26

by Peter Kästle

[permalink] [raw]
Subject: [PATCH 3/4] thermal: Added Bang-bang thermal governor

From: Peter Feuerer <[email protected]>

The bang-bang thermal governor uses a hysteresis to switch abruptly on
or off a cooling device. It is intended to control fans, which can
not be throttled but just switched on or off.
Bang-bang cannot be set as default governor as it is intended for
special devices only. For those special devices the driver needs to
explicitely request it.

Cc: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/thermal/Kconfig | 10 ++++
drivers/thermal/Makefile | 1 +
drivers/thermal/gov_bang_bang.c | 124 ++++++++++++++++++++++++++++++++++++++++
drivers/thermal/thermal_core.c | 5 ++
drivers/thermal/thermal_core.h | 8 +++
5 files changed, 148 insertions(+)
create mode 100644 drivers/thermal/gov_bang_bang.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 2d51912..2ede94f 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -84,6 +84,16 @@ config THERMAL_GOV_STEP_WISE
Enable this to manage platform thermals using a simple linear
governor.

+config THERMAL_GOV_BANG_BANG
+ bool "Bang Bang thermal governor"
+ default y
+ help
+ Enable this to manage platform thermals using bang bang governor.
+
+ Say 'Y' here if you want to use two point temperature regulation
+ used for fans without throttling. Some fan drivers depend on this
+ governor to be enabled (e.g. acerhdf).
+
config THERMAL_GOV_USER_SPACE
bool "User_space thermal governor"
help
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 54e4ec9..1c32a5d 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -11,6 +11,7 @@ thermal_sys-$(CONFIG_THERMAL_OF) += of-thermal.o

# governors
thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += fair_share.o
+thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o
thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += step_wise.o
thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE) += user_space.o

diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
new file mode 100644
index 0000000..96f314d
--- /dev/null
+++ b/drivers/thermal/gov_bang_bang.c
@@ -0,0 +1,124 @@
+/*
+ * gov_bang_bang.c - A simple thermal throttling governor using hysteresis
+ *
+ * Copyright (C) 2014 Peter Feuerer <[email protected]>
+ *
+ * Based on step_wise.c with following Copyrights:
+ * Copyright (C) 2012 Intel Corp
+ * Copyright (C) 2012 Durgadoss R <[email protected]>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ */
+
+#include <linux/thermal.h>
+
+#include "thermal_core.h"
+
+static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
+{
+ long trip_temp;
+ unsigned long trip_hyst;
+ struct thermal_instance *instance;
+
+ tz->ops->get_trip_temp(tz, trip, &trip_temp);
+ tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
+
+ dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
+ trip, trip_temp, tz->temperature,
+ trip_hyst);
+
+ mutex_lock(&tz->lock);
+
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+ if (instance->trip != trip)
+ continue;
+
+ /* in case fan is neither on nor off set the fan to active */
+ if (instance->target != 0 && instance->target != 1)
+ instance->target = 1;
+
+ /*
+ * enable fan when temperature exceeds trip_temp and disable
+ * the fan in case it falls below trip_temp minus hysteresis
+ */
+ if (instance->target == 0 && tz->temperature >= trip_temp)
+ instance->target = 1;
+ else if (instance->target == 1 &&
+ tz->temperature < trip_temp - trip_hyst)
+ instance->target = 0;
+
+ dev_dbg(&instance->cdev->device, "target=%d\n",
+ (int)instance->target);
+
+ instance->cdev->updated = false; /* cdev needs update */
+ }
+
+ mutex_unlock(&tz->lock);
+}
+
+/**
+ * bang_bang_throttle - throttles devices asscciated with the given zone
+ * @tz - thermal_zone_device
+ * @trip - the trip point
+ *
+ * Throttling Logic: a two point regulation, deliver cooling state depending
+ * on the previous state shown in this diagram:
+ *
+ * Fan: OFF ON
+ *
+ * |
+ * |
+ * trip_temp: +---->+
+ * | | ^
+ * | | |
+ * | | Temperature
+ * (trip_temp - hyst): +<----+
+ * |
+ * |
+ * |
+ *
+ * * If the fan is not running and temperature exceeds trip_temp, the fan
+ * gets turned on.
+ * * In case the fan is running, temperature must fall below
+ * (trip_temp - hyst) so that the fan gets turned off again.
+ *
+ */
+static int bang_bang_throttle(struct thermal_zone_device *tz, int trip)
+{
+ struct thermal_instance *instance;
+
+ thermal_zone_trip_update(tz, trip);
+
+ mutex_lock(&tz->lock);
+
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node)
+ thermal_cdev_update(instance->cdev);
+
+ mutex_unlock(&tz->lock);
+
+ return 0;
+}
+
+static struct thermal_governor thermal_gov_bang_bang = {
+ .name = "bang_bang",
+ .throttle = bang_bang_throttle,
+};
+
+int thermal_gov_bang_bang_register(void)
+{
+ return thermal_register_governor(&thermal_gov_bang_bang);
+}
+
+void thermal_gov_bang_bang_unregister(void)
+{
+ thermal_unregister_governor(&thermal_gov_bang_bang);
+}
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 71b0ec0..4c2726b 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1790,6 +1790,10 @@ static int __init thermal_register_governors(void)
if (result)
return result;

+ result = thermal_gov_bang_bang_register();
+ if (result)
+ return result;
+
return thermal_gov_user_space_register();
}

@@ -1797,6 +1801,7 @@ static void thermal_unregister_governors(void)
{
thermal_gov_step_wise_unregister();
thermal_gov_fair_share_unregister();
+ thermal_gov_bang_bang_unregister();
thermal_gov_user_space_unregister();
}

diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 3db339f..d15d243 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -69,6 +69,14 @@ 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_BANG_BANG
+int thermal_gov_bang_bang_register(void);
+void thermal_gov_bang_bang_unregister(void);
+#else
+static inline int thermal_gov_bang_bang_register(void) { return 0; }
+static inline void thermal_gov_bang_bang_unregister(void) {}
+#endif /* CONFIG_THERMAL_GOV_BANG_BANG */
+
#ifdef CONFIG_THERMAL_GOV_USER_SPACE
int thermal_gov_user_space_register(void);
void thermal_gov_user_space_unregister(void);
--
1.9.2

2014-04-27 18:57:12

by Andreas Mohr

[permalink] [raw]
Subject: Re: [PATCH 0/4] acerhdf/thermal: adding new models and appropriate governor

Hi,

On Sun, Apr 27, 2014 at 03:23:31AM +0200, Peter Feuerer wrote:
> Hi,
>
> finally I found time, to do some work on acerhdf.

Heh, yeah. I'm starting to come to the realization
that once having entered an "extended" state of life
it might be better to "take" the time rather than "have" it ;-P

> This patch series is intended to:
>
> * Introduce "manual mode" support (Patch 1 & 2), which is needed to control
> the fan of a few new models. Unfortunately this extends lines defining
> the bios table over 80 characters, but all other methods make the code
> really ugly and hard to read. So I hope for the reason of readability it
> is ok to break this rule.

Hmm... got an idea there. Possibly it's time to do away with direct
"device name" <-> open-coded config data mappings.
After all a specific device name is not really all too meaningful,
can (and will) be invented out of thin air, with its reg config being
identical to (read: painfully duplicated)
several other names/BIOS versions in the series.
So perhaps one should have a helper struct defined,
with instances then named as particular base samples of a model series
(ideally named after the precise internal development code name of the series),
to then be referenced by all model/BIOS names which match.

struct {
struct reg_feat_1;
struct reg_feat_2;
} aao_reg_map;

static const aao_reg_map aao_reg_map_AOAxxx_Acer_orig_version;




{ "Acer", "AOA1....", &aao_reg_map_AOAxxx_Acer_orig_version },

Of course you then have the indirection of device name <-> specific
register values (quote: "really ugly and hard to read"?),
but IMHO that's ok since normally you wouldn't be too focused
on looking up register values (...right!?).

And if the next interface-breaking config change came along,
you'd otherwise have to add yet another register index pair...
(at which point some 100+ char line monsters
would be breathing down our neck...)




Model additions:
Ain't there one MODULE_ALIAS missing?? (7 new models <-> 6 entries!?!?)
"Aspire One 753"? But perhaps that's already implicitly covered by
another existing entry? [if so, the commit log did not mention it ;)]


> * Add an appropriate thermal governor (Patch 3 & 4). Manipulating and
> fiddling around with the step-wise governor has been a very fragile thing
> in the past and as it broke again, I used the opportunity to add a two
> point thermal governor which implements the actual fan handling required by
> acerhdf and puts from my point of view things straight.

I'm afraid I don't have the full picture,
but so far it seems that this factoring out of common handling
is a very good idea.



- depends on THERMAL && ACPI
+ depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG
Do we actively depend on THERMAL (code-wise, I mean?) Or is it now an
implicit dependency given that we request THERMAL_GOV_BANG_BANG? If
implicit, then THERMAL probably ought to be removed. But if we use
generic thermal APIs (which we probably do), then of course we do have
that dependency....



"bang_bang_throttle - throttles devices asscciated with the given zone"

Typo ;)


"used to force thermal" --> misleading ("we used to do this, but it's
bad so we better do that").

"intended to"? "established to"? "added to"? or some simpler wording?


pr_err("Thermal governor %s is not compiled into thermal subsystem\n"
--> you are lying here... (the only thing we can reliably indicate
is that we did not get the expected name -
so we should perhaps indicate something like we "didn't get bang-bang,
since perhaps not compiled into thermal subsystem").




> Please test/review the patches and send me your comments.

-ENODATA (my crappy JMicron JMF601 SSD had managed to break again,
this time with fatal firmware corruption, so I had to reflash
firmware to resurrect it, but I haven't restored my environment yet,
but I'll obviously report back immediately if something comes up)


> Thanks and kind regards,

Thanks definitely ought to go to the active party instead! :)

Andreas Mohr

2014-04-27 21:03:34

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH 1/4] acerhdf: Adding support for "manual mode"

On Sun, Apr 27, 2014 at 03:23:32AM +0200, Peter Feuerer wrote:
> From: Peter Feuerer <[email protected]>
>
> Some Acer models require an additional command to turn off the fan after
> bios mode has been enabled. Adding new section in bios table to allow
> support for those models, by writing an extra "manual mode" register.

Why?

That command is always the same AFAICT. So why not add a single flag to
bios_settings_t called "needs_manual" or such and then do the required
dance in acerhdf_change_fanstate() if it is set?

Btw, this "struct bios_settings_t" could lose that "_t" at the end as it
is not a typedef. We don't like typedefs anyway. :-)

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2014-04-27 22:22:52

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH 1/4] acerhdf: Adding support for "manual mode"

Borislav Petkov writes:

> On Sun, Apr 27, 2014 at 03:23:32AM +0200, Peter Feuerer wrote:
>> From: Peter Feuerer <[email protected]>
>>
>> Some Acer models require an additional command to turn off the fan after
>> bios mode has been enabled. Adding new section in bios table to allow
>> support for those models, by writing an extra "manual mode" register.
>
> Why?
>
> That command is always the same AFAICT. So why not add a single flag to
> bios_settings_t called "needs_manual" or such and then do the required
> dance in acerhdf_change_fanstate() if it is set?

I wanted to be prepared for possible upcoming models with changed registers
/ values. But I guess it would make sense to go for your proposal for now
and then afterwards we should discuss about implementing the idea of
Andreas and split the bios_tbl.


> Btw, this "struct bios_settings_t" could lose that "_t" at the end as it
> is not a typedef. We don't like typedefs anyway. :-)

True, will put this on my todo list :)

--
--peter;

2014-04-27 23:13:25

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH 0/4] acerhdf/thermal: adding new models and appropriate governor

Hi,

Andreas Mohr writes:

> On Sun, Apr 27, 2014 at 03:23:31AM +0200, Peter Feuerer wrote:
>> This patch series is intended to:
>>
>> * Introduce "manual mode" support (Patch 1 & 2), which is needed to control
>> the fan of a few new models. Unfortunately this extends lines defining
>> the bios table over 80 characters, but all other methods make the code
>> really ugly and hard to read. So I hope for the reason of readability it
>> is ok to break this rule.
>
> Hmm... got an idea there. Possibly it's time to do away with direct
> "device name" <-> open-coded config data mappings.
> After all a specific device name is not really all too meaningful,
> can (and will) be invented out of thin air, with its reg config being
> identical to (read: painfully duplicated)
> several other names/BIOS versions in the series.
> So perhaps one should have a helper struct defined,
> with instances then named as particular base samples of a model series
> (ideally named after the precise internal development code name of the series),
> to then be referenced by all model/BIOS names which match.
>
> struct {
> struct reg_feat_1;
> struct reg_feat_2;
> } aao_reg_map;
>
> static const aao_reg_map aao_reg_map_AOAxxx_Acer_orig_version;
>
>
>
>
> { "Acer", "AOA1....", &aao_reg_map_AOAxxx_Acer_orig_version },
>
> Of course you then have the indirection of device name <-> specific
> register values (quote: "really ugly and hard to read"?),
> but IMHO that's ok since normally you wouldn't be too focused
> on looking up register values (...right!?).
>
> And if the next interface-breaking config change came along,
> you'd otherwise have to add yet another register index pair...
> (at which point some 100+ char line monsters
> would be breathing down our neck...)

I think we have been discussing this solution a year ago or something and
seems like it is really time to implement it. As I wrote in the other mail
to Boris, I'd like to just do a minor modification for now and then when
those 4 patches have been applied concentrate on implementing the splitted
structs.


> Model additions:
> Ain't there one MODULE_ALIAS missing?? (7 new models <-> 6 entries!?!?)
> "Aspire One 753"? But perhaps that's already implicitly covered by
> another existing entry? [if so, the commit log did not mention it ;)]

You are right, alias for 753 is missing, will add it for the next patch set.


>> * Add an appropriate thermal governor (Patch 3 & 4). Manipulating and
>> fiddling around with the step-wise governor has been a very fragile thing
>> in the past and as it broke again, I used the opportunity to add a two
>> point thermal governor which implements the actual fan handling required by
>> acerhdf and puts from my point of view things straight.
>
> I'm afraid I don't have the full picture,
> but so far it seems that this factoring out of common handling
> is a very good idea.

ok.


> - depends on THERMAL && ACPI
> + depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG
> Do we actively depend on THERMAL (code-wise, I mean?) Or is it now an
> implicit dependency given that we request THERMAL_GOV_BANG_BANG? If
> implicit, then THERMAL probably ought to be removed. But if we use
> generic thermal APIs (which we probably do), then of course we do have
> that dependency....

There's an implicit dependency due to the request of THERMAL_GOV_BANG_BANG, so
yes, we could remove THERMAL here.


> "bang_bang_throttle - throttles devices asscciated with the given zone"
>
> Typo ;)

c != o, got it.


> "used to force thermal" --> misleading ("we used to do this, but it's
> bad so we better do that").
>
> "intended to"? "established to"? "added to"? or some simpler wording?

What do you think about this wording:
/*
* this struct is used to instruct thermal layer to use bang_bang instead of
* default governor for acerhdf
*/


> pr_err("Thermal governor %s is not compiled into thermal subsystem\n"
> --> you are lying here... (the only thing we can reliably indicate
> is that we did not get the expected name -
> so we should perhaps indicate something like we "didn't get bang-bang,
> since perhaps not compiled into thermal subsystem").

Fixed in next submit.


>> Please test/review the patches and send me your comments.
>
> -ENODATA (my crappy JMicron JMF601 SSD had managed to break again,
> this time with fatal firmware corruption, so I had to reflash
> firmware to resurrect it, but I haven't restored my environment yet,
> but I'll obviously report back immediately if something comes up)

Ok, good luck with this.

Thanks for all the good input.

--
kind regards,
--peter;

2014-04-28 04:58:13

by Andreas Mohr

[permalink] [raw]
Subject: Re: [PATCH 0/4] acerhdf/thermal: adding new models and appropriate governor

Hi,

On Mon, Apr 28, 2014 at 01:13:19AM +0200, Peter Feuerer wrote:
> Hi,
>
> Andreas Mohr writes:
>
> > { "Acer", "AOA1....", &aao_reg_map_AOAxxx_Acer_orig_version },
> >
> > Of course you then have the indirection of device name <-> specific
> > register values (quote: "really ugly and hard to read"?),
> > but IMHO that's ok since normally you wouldn't be too focused
> > on looking up register values (...right!?).
> >
> > And if the next interface-breaking config change came along,
> > you'd otherwise have to add yet another register index pair...
> > (at which point some 100+ char line monsters
> > would be breathing down our neck...)
>
> I think we have been discussing this solution a year ago or something and
> seems like it is really time to implement it. As I wrote in the other mail
> to Boris, I'd like to just do a minor modification for now and then when
> those 4 patches have been applied concentrate on implementing the splitted
> structs.

Yup, to get things out of the way now :)


[[BTW your mail environment seems configured to have trailing blanks -
might want to "optimize" that away...]]


> > - depends on THERMAL && ACPI
> > + depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG
> > Do we actively depend on THERMAL (code-wise, I mean?) Or is it now an
> > implicit dependency given that we request THERMAL_GOV_BANG_BANG? If
> > implicit, then THERMAL probably ought to be removed. But if we use
> > generic thermal APIs (which we probably do), then of course we do have
> > that dependency....
>
> There's an implicit dependency due to the request of THERMAL_GOV_BANG_BANG, so
> yes, we could remove THERMAL here.

ok. Does not seem too risky, and reduces the need for future updates.

> > "used to force thermal" --> misleading ("we used to do this, but it's
> > bad so we better do that").
> >
> > "intended to"? "established to"? "added to"? or some simpler wording?
>
> What do you think about this wording:
> /*
> * this struct is used to instruct thermal layer to use bang_bang instead of
> * default governor for acerhdf
> */

Nicely detailed.


About the _t typedef: it's said that use of "_t" is undesirable anyway
due to being reserved for POSIX.
https://en.wikipedia.org/wiki/Typedef
http://stackoverflow.com/questions/1186072/naming-scheme-for-typedefs
As an alternative using a full "_type" is ok right?
(that's what I've been doing...)

Andreas

2014-04-29 09:18:32

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v2 0/4] acerhdf/thermal: adding new models and appropriate governor

Hi,

This patch series is intended to:

* Introduce "manual mode" support (Patch 1 & 2), which is needed to control
the fan of a few new models.

* Add an appropriate thermal governor (Patch 3 & 4). Manipulating and
fiddling around with the step-wise governor has been a very fragile thing
in the past and as it broke again, I used the opportunity to add a two
point thermal governor which implements the actual fan handling required by
acerhdf and puts from my point of view things straight.

Please test/review the patches and send me your comments.

Thanks and kind regards,
peter


Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Zhang Rui <[email protected]>



Peter Feuerer (4):
acerhdf: Adding support for "manual mode"
acerhdf: Adding support for new models
thermal: Added Bang-bang thermal governor
acerhdf: Use bang-bang thermal governor

drivers/platform/x86/Kconfig | 2 +-
drivers/platform/x86/acerhdf.c | 256 ++++++++++++++++++++++++++--------------
drivers/thermal/Kconfig | 10 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/gov_bang_bang.c | 124 +++++++++++++++++++
drivers/thermal/thermal_core.c | 5 +
drivers/thermal/thermal_core.h | 8 ++
7 files changed, 314 insertions(+), 92 deletions(-)
create mode 100644 drivers/thermal/gov_bang_bang.c

--
1.9.2

2014-04-29 09:18:46

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v2 4/4] acerhdf: Use bang-bang thermal governor

acerhdf has been doing an on-off fan control using hysteresis by
post-manipulating the outcome of thermal subsystem trip point handling.
This patch enables acerhdf to use the bang-bang governor, which is
intended for on-off controlled fans.

CC: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/Kconfig | 2 +-
drivers/platform/x86/acerhdf.c | 48 +++++++++++++++++++++++++++++++++++-------
2 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 27df2c5..0c15d89 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -38,7 +38,7 @@ config ACER_WMI

config ACERHDF
tristate "Acer Aspire One temperature and fan driver"
- depends on THERMAL && ACPI
+ depends on ACPI && THERMAL_GOV_BANG_BANG
---help---
This is a driver for Acer Aspire One netbooks. It allows to access
the temperature sensor and to control the fan.
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 176edbd..f3884f9 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.30"
+#define DRV_VER "0.5.31"

/*
* According to the Atom N270 datasheet,
@@ -135,8 +135,8 @@ struct bios_settings_t {
const char *vendor;
const char *product;
const char *version;
- unsigned char fanreg;
- unsigned char tempreg;
+ u8 fanreg;
+ u8 tempreg;
struct fancmd cmd;
int mcmd_enable;
};
@@ -259,6 +259,17 @@ static const struct bios_settings_t bios_tbl[] = {

static const struct bios_settings_t *bios_cfg __read_mostly;

+/*
+ * this struct is used to instruct thermal layer to use bang_bang instead of
+ * default governor for acerhdf
+ */
+static struct thermal_zone_params acerhdf_zone_params = {
+ .governor_name = "bang_bang",
+ .no_hwmon = 0,
+ .num_tbps = 0,
+ .tbp = 0,
+};
+
static int acerhdf_get_temp(int *temp)
{
u8 read_temp;
@@ -436,6 +447,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*type = THERMAL_TRIP_ACTIVE;
+ if (trip == 1)
+ *type = THERMAL_TRIP_CRITICAL;
+
+ return 0;
+}
+
+static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
+ unsigned long *temp)
+{
+ if (trip == 0)
+ *temp = fanon - fanoff;

return 0;
}
@@ -445,6 +467,8 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*temp = fanon;
+ else if (trip == 1)
+ *temp = ACERHDF_TEMP_CRIT;

return 0;
}
@@ -464,8 +488,10 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
.get_mode = acerhdf_get_mode,
.set_mode = acerhdf_set_mode,
.get_trip_type = acerhdf_get_trip_type,
+ .get_trip_hyst = acerhdf_get_trip_hyst,
.get_trip_temp = acerhdf_get_trip_temp,
.get_crit_temp = acerhdf_get_crit_temp,
+ .notify = NULL,
};


@@ -516,9 +542,7 @@ static int acerhdf_set_cur_state(struct thermal_cooling_device *cdev,
}

if (state == 0) {
- /* turn fan off only if below fanoff temperature */
- if ((cur_state == ACERHDF_FAN_AUTO) &&
- (cur_temp < fanoff))
+ if (cur_state == ACERHDF_FAN_AUTO)
acerhdf_change_fanstate(ACERHDF_FAN_OFF);
} else {
if (cur_state == ACERHDF_FAN_OFF)
@@ -696,12 +720,20 @@ static int acerhdf_register_thermal(void)
if (IS_ERR(cl_dev))
return -EINVAL;

- thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
- &acerhdf_dev_ops, NULL, 0,
+ thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL,
+ &acerhdf_dev_ops,
+ &acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
if (IS_ERR(thz_dev))
return -EINVAL;

+ if (strcmp(thz_dev->governor->name,
+ acerhdf_zone_params.governor_name)) {
+ pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n",
+ acerhdf_zone_params.governor_name);
+ return -EINVAL;
+ }
+
return 0;
}

--
1.9.2

2014-04-29 09:18:44

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v2 1/4] acerhdf: Adding support for "manual mode"

Some Acer models require an additional command to turn off the fan after
bios mode has been enabled. Adding new section in bios table to allow
support for those models, by writing an extra "manual mode" register.

Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 187 +++++++++++++++++++++++------------------
1 file changed, 103 insertions(+), 84 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f94467c..dd63e93 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.26"
+#define DRV_VER "0.5.29"

/*
* According to the Atom N270 datasheet,
@@ -119,6 +119,17 @@ struct fancmd {
u8 cmd_auto;
};

+struct manualcmd {
+ u8 mreg;
+ u8 moff;
+};
+
+/* default register and command to disable fan in manual mode */
+static const struct manualcmd mcmd = {
+ .mreg = 0x94,
+ .moff = 0xff,
+};
+
/* BIOS settings */
struct bios_settings_t {
const char *vendor;
@@ -127,105 +138,107 @@ struct bios_settings_t {
unsigned char fanreg;
unsigned char tempreg;
struct fancmd cmd;
+ int mcmd_enable;
};

+
/* Register addresses and values for different BIOS versions */
static const struct bios_settings_t bios_tbl[] = {
/* AOA110 */
- {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00}, 0},
/* AOA150 */
- {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00}, 0},
/* LT1005u */
- {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 1410 */
- {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer 1810xx */
- {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer 531 */
- {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 751 */
- {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, 0},
/* Acer 1825 */
- {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer TravelMate 7730 */
- {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00} },
+ {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, 0},
/* Gateway */
- {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
- {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} },
- {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
+ {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Packard Bell */
- {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
+ {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
/* pewpew-terminator */
- {"", "", "", 0, 0, {0, 0} }
+ {"", "", "", 0, 0, {0, 0}, 0}
};

static const struct bios_settings_t *bios_cfg __read_mostly;
@@ -275,6 +288,12 @@ static void acerhdf_change_fanstate(int state)
fanstate = state;

ec_write(bios_cfg->fanreg, cmd);
+
+ if (bios_cfg->mcmd_enable && state == ACERHDF_FAN_OFF) {
+ if (verbose)
+ pr_notice("turning off fan manually\n");
+ ec_write(mcmd.mreg, mcmd.moff);
+ }
}

static void acerhdf_check_param(struct thermal_zone_device *thermal)
--
1.9.2

2014-04-29 09:18:43

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v2 2/4] acerhdf: Adding support for new models

added following new models:
* Aspire 5755G
* AO521
* AO751h
* Aspire One 753
* Extensa 5420
* Aspire 5315
* Aspire 5739G
* TravelMate TM8573T

Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index dd63e93..176edbd 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.29"
+#define DRV_VER "0.5.30"

/*
* According to the Atom N270 datasheet,
@@ -200,17 +200,33 @@ static const struct bios_settings_t bios_tbl[] = {
{"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
+ /* Acer 5755G */
+ {"Acer", "Aspire 5755G", "V1.20", 0xab, 0xb4, {0x00, 0x08}, 0},
+ {"Acer", "Aspire 5755G", "V1.21", 0xab, 0xb3, {0x00, 0x08}, 0},
+ /* Acer 521 */
+ {"Acer", "AO521", "V1.11", 0x55, 0x58, {0x1f, 0x00}, 0},
/* Acer 531 */
{"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, 0},
{"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, 0},
{"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 751 */
+ {"Acer", "AO751h", "V0.3206", 0x55, 0x58, {0x21, 0x00}, 0},
{"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, 0},
+ /* Acer 753 */
+ {"Acer", "Aspire One 753", "V1.24", 0x93, 0xac, {0x14, 0x04}, 1},
/* Acer 1825 */
{"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
+ /* Acer Extensa 5420 */
+ {"Acer", "Extensa 5420", "V1.17", 0x93, 0xac, {0x14, 0x04}, 1},
+ /* Acer Aspire 5315 */
+ {"Acer", "Aspire 5315", "V1.19", 0x93, 0xac, {0x14, 0x04}, 1},
+ /* Acer Aspire 5739 */
+ {"Acer", "Aspire 5739G", "V1.3311", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer TravelMate 7730 */
{"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, 0},
+ /* Acer TravelMate TM8573T */
+ {"Acer", "TM8573T", "V1.13", 0x93, 0xa8, {0x14, 0x04}, 1},
/* Gateway */
{"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, 0},
{"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, 0},
@@ -742,9 +758,15 @@ MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO751h*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1410*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1810*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5755G:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1825PTZ:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAO521*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO531*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5739G:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*One*753:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5315:");
MODULE_ALIAS("dmi:*:*Acer*:TravelMate*7730G:");
+MODULE_ALIAS("dmi:*:*Acer*:TM8573T:");
MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnAOA*:");
@@ -753,6 +775,7 @@ MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMU*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnENBFT*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMA*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTVR46*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnExtensa 5420*:");

module_init(acerhdf_init);
module_exit(acerhdf_exit);
--
1.9.2

2014-04-29 09:18:42

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v2 3/4] thermal: Added Bang-bang thermal governor

The bang-bang thermal governor uses a hysteresis to switch abruptly on
or off a cooling device. It is intended to control fans, which can
not be throttled but just switched on or off.
Bang-bang cannot be set as default governor as it is intended for
special devices only. For those special devices the driver needs to
explicitely request it.

Cc: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/thermal/Kconfig | 10 ++++
drivers/thermal/Makefile | 1 +
drivers/thermal/gov_bang_bang.c | 124 ++++++++++++++++++++++++++++++++++++++++
drivers/thermal/thermal_core.c | 5 ++
drivers/thermal/thermal_core.h | 8 +++
5 files changed, 148 insertions(+)
create mode 100644 drivers/thermal/gov_bang_bang.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 2d51912..2ede94f 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -84,6 +84,16 @@ config THERMAL_GOV_STEP_WISE
Enable this to manage platform thermals using a simple linear
governor.

+config THERMAL_GOV_BANG_BANG
+ bool "Bang Bang thermal governor"
+ default y
+ help
+ Enable this to manage platform thermals using bang bang governor.
+
+ Say 'Y' here if you want to use two point temperature regulation
+ used for fans without throttling. Some fan drivers depend on this
+ governor to be enabled (e.g. acerhdf).
+
config THERMAL_GOV_USER_SPACE
bool "User_space thermal governor"
help
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 54e4ec9..1c32a5d 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -11,6 +11,7 @@ thermal_sys-$(CONFIG_THERMAL_OF) += of-thermal.o

# governors
thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += fair_share.o
+thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o
thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += step_wise.o
thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE) += user_space.o

diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
new file mode 100644
index 0000000..328dde0
--- /dev/null
+++ b/drivers/thermal/gov_bang_bang.c
@@ -0,0 +1,124 @@
+/*
+ * gov_bang_bang.c - A simple thermal throttling governor using hysteresis
+ *
+ * Copyright (C) 2014 Peter Feuerer <[email protected]>
+ *
+ * Based on step_wise.c with following Copyrights:
+ * Copyright (C) 2012 Intel Corp
+ * Copyright (C) 2012 Durgadoss R <[email protected]>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ */
+
+#include <linux/thermal.h>
+
+#include "thermal_core.h"
+
+static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
+{
+ long trip_temp;
+ unsigned long trip_hyst;
+ struct thermal_instance *instance;
+
+ tz->ops->get_trip_temp(tz, trip, &trip_temp);
+ tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
+
+ dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
+ trip, trip_temp, tz->temperature,
+ trip_hyst);
+
+ mutex_lock(&tz->lock);
+
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+ if (instance->trip != trip)
+ continue;
+
+ /* in case fan is neither on nor off set the fan to active */
+ if (instance->target != 0 && instance->target != 1)
+ instance->target = 1;
+
+ /*
+ * enable fan when temperature exceeds trip_temp and disable
+ * the fan in case it falls below trip_temp minus hysteresis
+ */
+ if (instance->target == 0 && tz->temperature >= trip_temp)
+ instance->target = 1;
+ else if (instance->target == 1 &&
+ tz->temperature < trip_temp - trip_hyst)
+ instance->target = 0;
+
+ dev_dbg(&instance->cdev->device, "target=%d\n",
+ (int)instance->target);
+
+ instance->cdev->updated = false; /* cdev needs update */
+ }
+
+ mutex_unlock(&tz->lock);
+}
+
+/**
+ * bang_bang_throttle - throttles devices associated with the given zone
+ * @tz - thermal_zone_device
+ * @trip - the trip point
+ *
+ * Throttling Logic: a two point regulation, deliver cooling state depending
+ * on the previous state shown in this diagram:
+ *
+ * Fan: OFF ON
+ *
+ * |
+ * |
+ * trip_temp: +---->+
+ * | | ^
+ * | | |
+ * | | Temperature
+ * (trip_temp - hyst): +<----+
+ * |
+ * |
+ * |
+ *
+ * * If the fan is not running and temperature exceeds trip_temp, the fan
+ * gets turned on.
+ * * In case the fan is running, temperature must fall below
+ * (trip_temp - hyst) so that the fan gets turned off again.
+ *
+ */
+static int bang_bang_throttle(struct thermal_zone_device *tz, int trip)
+{
+ struct thermal_instance *instance;
+
+ thermal_zone_trip_update(tz, trip);
+
+ mutex_lock(&tz->lock);
+
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node)
+ thermal_cdev_update(instance->cdev);
+
+ mutex_unlock(&tz->lock);
+
+ return 0;
+}
+
+static struct thermal_governor thermal_gov_bang_bang = {
+ .name = "bang_bang",
+ .throttle = bang_bang_throttle,
+};
+
+int thermal_gov_bang_bang_register(void)
+{
+ return thermal_register_governor(&thermal_gov_bang_bang);
+}
+
+void thermal_gov_bang_bang_unregister(void)
+{
+ thermal_unregister_governor(&thermal_gov_bang_bang);
+}
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 71b0ec0..4c2726b 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1790,6 +1790,10 @@ static int __init thermal_register_governors(void)
if (result)
return result;

+ result = thermal_gov_bang_bang_register();
+ if (result)
+ return result;
+
return thermal_gov_user_space_register();
}

@@ -1797,6 +1801,7 @@ static void thermal_unregister_governors(void)
{
thermal_gov_step_wise_unregister();
thermal_gov_fair_share_unregister();
+ thermal_gov_bang_bang_unregister();
thermal_gov_user_space_unregister();
}

diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 3db339f..d15d243 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -69,6 +69,14 @@ 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_BANG_BANG
+int thermal_gov_bang_bang_register(void);
+void thermal_gov_bang_bang_unregister(void);
+#else
+static inline int thermal_gov_bang_bang_register(void) { return 0; }
+static inline void thermal_gov_bang_bang_unregister(void) {}
+#endif /* CONFIG_THERMAL_GOV_BANG_BANG */
+
#ifdef CONFIG_THERMAL_GOV_USER_SPACE
int thermal_gov_user_space_register(void);
void thermal_gov_user_space_unregister(void);
--
1.9.2

2014-04-29 15:53:29

by Javi Merino

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] thermal: Added Bang-bang thermal governor

On Tue, Apr 29, 2014 at 10:17:56AM +0100, Peter Feuerer wrote:
> The bang-bang thermal governor uses a hysteresis to switch abruptly on
> or off a cooling device. It is intended to control fans, which can
> not be throttled but just switched on or off.
> Bang-bang cannot be set as default governor as it is intended for
> special devices only. For those special devices the driver needs to
> explicitely request it.

I don't really understand why step-wise doesn't work for you (AIUI,
this governor should be a subset of it. I'll let others comment on
that, just a minor comment below.

[...]
> diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
> new file mode 100644
> index 0000000..328dde0
> --- /dev/null
> +++ b/drivers/thermal/gov_bang_bang.c
> @@ -0,0 +1,124 @@
> +/*
> + * gov_bang_bang.c - A simple thermal throttling governor using hysteresis
> + *
> + * Copyright (C) 2014 Peter Feuerer <[email protected]>
> + *
> + * Based on step_wise.c with following Copyrights:
> + * Copyright (C) 2012 Intel Corp
> + * Copyright (C) 2012 Durgadoss R <[email protected]>
> + *
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, version 2.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
> + * the GNU General Public License for more details.
> + *
> + */
> +
> +#include <linux/thermal.h>
> +
> +#include "thermal_core.h"
> +
> +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
> +{
> + long trip_temp;
> + unsigned long trip_hyst;
> + struct thermal_instance *instance;
> +
> + tz->ops->get_trip_temp(tz, trip, &trip_temp);
> + tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
> +
> + dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
> + trip, trip_temp, tz->temperature,
> + trip_hyst);
> +
> + mutex_lock(&tz->lock);
> +
> + list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
> + if (instance->trip != trip)
> + continue;
> +
> + /* in case fan is neither on nor off set the fan to active */
> + if (instance->target != 0 && instance->target != 1)
> + instance->target = 1;

I think you should add a pr_warn() here to warn the user that the
governor is being used with a cooling device that seems to support
more than one cooling state.

Cheers,
Javi

2014-04-29 16:01:05

by Javi Merino

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] acerhdf: Use bang-bang thermal governor

On Tue, Apr 29, 2014 at 10:17:57AM +0100, Peter Feuerer wrote:
> acerhdf has been doing an on-off fan control using hysteresis by
> post-manipulating the outcome of thermal subsystem trip point handling.
> This patch enables acerhdf to use the bang-bang governor, which is
> intended for on-off controlled fans.
>
> CC: Zhang Rui <[email protected]>
> Cc: Andreas Mohr <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Signed-off-by: Peter Feuerer <[email protected]>
> ---
> drivers/platform/x86/Kconfig | 2 +-
> drivers/platform/x86/acerhdf.c | 48 +++++++++++++++++++++++++++++++++++-------
> 2 files changed, 41 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 27df2c5..0c15d89 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -38,7 +38,7 @@ config ACER_WMI
>
> config ACERHDF
> tristate "Acer Aspire One temperature and fan driver"
> - depends on THERMAL && ACPI
> + depends on ACPI && THERMAL_GOV_BANG_BANG
> ---help---
> This is a driver for Acer Aspire One netbooks. It allows to access
> the temperature sensor and to control the fan.
> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
> index 176edbd..f3884f9 100644
> --- a/drivers/platform/x86/acerhdf.c
> +++ b/drivers/platform/x86/acerhdf.c
> @@ -50,7 +50,7 @@
> */
> #undef START_IN_KERNEL_MODE
>
> -#define DRV_VER "0.5.30"
> +#define DRV_VER "0.5.31"
>
> /*
> * According to the Atom N270 datasheet,
> @@ -135,8 +135,8 @@ struct bios_settings_t {
> const char *vendor;
> const char *product;
> const char *version;
> - unsigned char fanreg;
> - unsigned char tempreg;
> + u8 fanreg;
> + u8 tempreg;
> struct fancmd cmd;
> int mcmd_enable;
> };
> @@ -259,6 +259,17 @@ static const struct bios_settings_t bios_tbl[] = {
>
> static const struct bios_settings_t *bios_cfg __read_mostly;
>
> +/*
> + * this struct is used to instruct thermal layer to use bang_bang instead of
> + * default governor for acerhdf
> + */
> +static struct thermal_zone_params acerhdf_zone_params = {
> + .governor_name = "bang_bang",
> + .no_hwmon = 0,
> + .num_tbps = 0,
> + .tbp = 0,
> +};

You don't need to initialize statics to 0. checkpatch only considers
it an error if it finds it in a variable, but I think it also applies
to fields in struct.

> +
> static int acerhdf_get_temp(int *temp)
> {
> u8 read_temp;
> @@ -436,6 +447,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
> {
> if (trip == 0)
> *type = THERMAL_TRIP_ACTIVE;
> + if (trip == 1)
> + *type = THERMAL_TRIP_CRITICAL;

This looks like an unrelated change that should be on a patch on its
own.

> +
> + return 0;
> +}
> +
> +static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
> + unsigned long *temp)
> +{
> + if (trip == 0)
> + *temp = fanon - fanoff;
>
> return 0;
> }
> @@ -445,6 +467,8 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
> {
> if (trip == 0)
> *temp = fanon;
> + else if (trip == 1)
> + *temp = ACERHDF_TEMP_CRIT;
>
> return 0;
> }
> @@ -464,8 +488,10 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
> .get_mode = acerhdf_get_mode,
> .set_mode = acerhdf_set_mode,
> .get_trip_type = acerhdf_get_trip_type,
> + .get_trip_hyst = acerhdf_get_trip_hyst,
> .get_trip_temp = acerhdf_get_trip_temp,
> .get_crit_temp = acerhdf_get_crit_temp,
> + .notify = NULL,

Same as before, no need to initialize static to NULL.

Cheers,
Javi

2014-04-29 16:37:33

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] thermal: Added Bang-bang thermal governor

Javi Merino writes:

> On Tue, Apr 29, 2014 at 10:17:56AM +0100, Peter Feuerer wrote:
>> The bang-bang thermal governor uses a hysteresis to switch abruptly on
>> or off a cooling device. It is intended to control fans, which can
>> not be throttled but just switched on or off.
>> Bang-bang cannot be set as default governor as it is intended for
>> special devices only. For those special devices the driver needs to
>> explicitely request it.
>
> I don't really understand why step-wise doesn't work for you (AIUI,
> this governor should be a subset of it. I'll let others comment on
> that, just a minor comment below.

That's what we thought in the first place too and we've been doing a lot of
fiddling in the past to somehow fit acerhdf into stepwise. But it never
really fitted and it broke all the time. Furthermore stepwise has a lot of
features like trend analysis, which is just overkill for the two step
regulation of acerhdf.

If I recall correctly, even Rui claimed in some email, that inventing a
separate governor would be a good long term solution.


> [...]
>> diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
>> new file mode 100644
>> index 0000000..328dde0
>> --- /dev/null
>> +++ b/drivers/thermal/gov_bang_bang.c
>> @@ -0,0 +1,124 @@
>> +/*
>> + * gov_bang_bang.c - A simple thermal throttling governor using hysteresis
>> + *
>> + * Copyright (C) 2014 Peter Feuerer <[email protected]>
>> + *
>> + * Based on step_wise.c with following Copyrights:
>> + * Copyright (C) 2012 Intel Corp
>> + * Copyright (C) 2012 Durgadoss R <[email protected]>
>> + *
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation, version 2.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
>> + * the GNU General Public License for more details.
>> + *
>> + */
>> +
>> +#include <linux/thermal.h>
>> +
>> +#include "thermal_core.h"
>> +
>> +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
>> +{
>> + long trip_temp;
>> + unsigned long trip_hyst;
>> + struct thermal_instance *instance;
>> +
>> + tz->ops->get_trip_temp(tz, trip, &trip_temp);
>> + tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
>> +
>> + dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
>> + trip, trip_temp, tz->temperature,
>> + trip_hyst);
>> +
>> + mutex_lock(&tz->lock);
>> +
>> + list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
>> + if (instance->trip != trip)
>> + continue;
>> +
>> + /* in case fan is neither on nor off set the fan to active */
>> + if (instance->target != 0 && instance->target != 1)
>> + instance->target = 1;
>
> I think you should add a pr_warn() here to warn the user that the
> governor is being used with a cooling device that seems to support
> more than one cooling state.

Strange thing is, that the first time it is actually called with acerhdf
attached, it comes in with instance→target = -1 … I did not yet find out,
why.

I'll further investigate on this and add some warning to it.

thanks for your comments.

--
kind regards,
--peter;

2014-04-29 16:43:13

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] acerhdf: Use bang-bang thermal governor

Javi Merino writes:

> On Tue, Apr 29, 2014 at 10:17:57AM +0100, Peter Feuerer wrote:
>> acerhdf has been doing an on-off fan control using hysteresis by
>> post-manipulating the outcome of thermal subsystem trip point handling.
>> This patch enables acerhdf to use the bang-bang governor, which is
>> intended for on-off controlled fans.
>>
>> CC: Zhang Rui <[email protected]>
>> Cc: Andreas Mohr <[email protected]>
>> Cc: Borislav Petkov <[email protected]>
>> Signed-off-by: Peter Feuerer <[email protected]>
>> ---
>> drivers/platform/x86/Kconfig | 2 +-
>> drivers/platform/x86/acerhdf.c | 48 +++++++++++++++++++++++++++++++++++-------
>> 2 files changed, 41 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
>> index 27df2c5..0c15d89 100644
>> --- a/drivers/platform/x86/Kconfig
>> +++ b/drivers/platform/x86/Kconfig
>> @@ -38,7 +38,7 @@ config ACER_WMI
>>
>> config ACERHDF
>> tristate "Acer Aspire One temperature and fan driver"
>> - depends on THERMAL && ACPI
>> + depends on ACPI && THERMAL_GOV_BANG_BANG
>> ---help---
>> This is a driver for Acer Aspire One netbooks. It allows to access
>> the temperature sensor and to control the fan.
>> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
>> index 176edbd..f3884f9 100644
>> --- a/drivers/platform/x86/acerhdf.c
>> +++ b/drivers/platform/x86/acerhdf.c
>> @@ -50,7 +50,7 @@
>> */
>> #undef START_IN_KERNEL_MODE
>>
>> -#define DRV_VER "0.5.30"
>> +#define DRV_VER "0.5.31"
>>
>> /*
>> * According to the Atom N270 datasheet,
>> @@ -135,8 +135,8 @@ struct bios_settings_t {
>> const char *vendor;
>> const char *product;
>> const char *version;
>> - unsigned char fanreg;
>> - unsigned char tempreg;
>> + u8 fanreg;
>> + u8 tempreg;
>> struct fancmd cmd;
>> int mcmd_enable;
>> };
>> @@ -259,6 +259,17 @@ static const struct bios_settings_t bios_tbl[] = {
>>
>> static const struct bios_settings_t *bios_cfg __read_mostly;
>>
>> +/*
>> + * this struct is used to instruct thermal layer to use bang_bang instead of
>> + * default governor for acerhdf
>> + */
>> +static struct thermal_zone_params acerhdf_zone_params = {
>> + .governor_name = "bang_bang",
>> + .no_hwmon = 0,
>> + .num_tbps = 0,
>> + .tbp = 0,
>> +};
>
> You don't need to initialize statics to 0. checkpatch only considers
> it an error if it finds it in a variable, but I think it also applies
> to fields in struct.

I agree, this is superfluous. I'll remove those lines.


>> +
>> static int acerhdf_get_temp(int *temp)
>> {
>> u8 read_temp;
>> @@ -436,6 +447,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
>> {
>> if (trip == 0)
>> *type = THERMAL_TRIP_ACTIVE;
>> + if (trip == 1)
>> + *type = THERMAL_TRIP_CRITICAL;
>
> This looks like an unrelated change that should be on a patch on its
> own.

Yes, will do so.



>> +
>> + return 0;
>> +}
>> +
>> +static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
>> + unsigned long *temp)
>> +{
>> + if (trip == 0)
>> + *temp = fanon - fanoff;
>>
>> return 0;
>> }
>> @@ -445,6 +467,8 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
>> {
>> if (trip == 0)
>> *temp = fanon;
>> + else if (trip == 1)
>> + *temp = ACERHDF_TEMP_CRIT;
>>
>> return 0;
>> }
>> @@ -464,8 +488,10 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
>> .get_mode = acerhdf_get_mode,
>> .set_mode = acerhdf_set_mode,
>> .get_trip_type = acerhdf_get_trip_type,
>> + .get_trip_hyst = acerhdf_get_trip_hyst,
>> .get_trip_temp = acerhdf_get_trip_temp,
>> .get_crit_temp = acerhdf_get_crit_temp,
>> + .notify = NULL,
>
> Same as before, no need to initialize static to NULL.

Ok, thanks.

--
kind regards,
--peter;

2014-04-29 21:31:47

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] thermal: Added Bang-bang thermal governor

Hi Javi,

Peter Feuerer writes:

> Javi Merino writes:
[...]

>>> diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
>>> new file mode 100644
>>> index 0000000..328dde0
>>> --- /dev/null
>>> +++ b/drivers/thermal/gov_bang_bang.c
>>> @@ -0,0 +1,124 @@
>>> +/*
>>> + * gov_bang_bang.c - A simple thermal throttling governor using hysteresis
>>> + *
>>> + * Copyright (C) 2014 Peter Feuerer <[email protected]>
>>> + *
>>> + * Based on step_wise.c with following Copyrights:
>>> + * Copyright (C) 2012 Intel Corp
>>> + * Copyright (C) 2012 Durgadoss R <[email protected]>
>>> + *
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation, version 2.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
>>> + * the GNU General Public License for more details.
>>> + *
>>> + */
>>> +
>>> +#include <linux/thermal.h>
>>> +
>>> +#include "thermal_core.h"
>>> +
>>> +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
>>> +{
>>> + long trip_temp;
>>> + unsigned long trip_hyst;
>>> + struct thermal_instance *instance;
>>> +
>>> + tz->ops->get_trip_temp(tz, trip, &trip_temp);
>>> + tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
>>> +
>>> + dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
>>> + trip, trip_temp, tz->temperature,
>>> + trip_hyst);
>>> +
>>> + mutex_lock(&tz->lock);
>>> +
>>> + list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
>>> + if (instance->trip != trip)
>>> + continue;
>>> +
>>> + /* in case fan is neither on nor off set the fan to active */
>>> + if (instance->target != 0 && instance->target != 1)
>>> + instance->target = 1;
>>
>> I think you should add a pr_warn() here to warn the user that the
>> governor is being used with a cooling device that seems to support
>> more than one cooling state.
>
> Strange thing is, that the first time it is actually called with acerhdf
> attached, it comes in with instance→target = -1 … I did not yet find out,
> why.
>
> I'll further investigate on this and add some warning to it.

I found out, that the default init state of a cooling device is:

drivers/thermal/thermal_core.c:
960 dev->target = THERMAL_NO_TARGET;

While drivers/thermal/thermal_core.h:
30 /* Initial state of a cooling device during binding */
31 #define THERMAL_NO_TARGET -1UL


So I changed my patch to this:

+ /* in case fan is in initial state, switch the fan off */
+ if (instance->target == THERMAL_NO_TARGET)
+ instance->target = 0;
+
+ /* in case fan is neither on nor off set the fan to active */
+ if (instance->target != 0 && instance->target != 1) {
+ pr_warn("Thermal instance %s controlled by bang-bang has unexpected state: %ld\n",
+ instance->name, instance->target);
+ instance->target = 1;
+ }


--
kind regards,
--peter;

2014-04-30 09:01:22

by Javi Merino

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] thermal: Added Bang-bang thermal governor

Hi Peter,

On Tue, Apr 29, 2014 at 10:31:42PM +0100, Peter Feuerer wrote:
> Peter Feuerer writes:
>
> > Javi Merino writes:
> [...]
>
> >>> diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
> >>> new file mode 100644
> >>> index 0000000..328dde0
> >>> --- /dev/null
> >>> +++ b/drivers/thermal/gov_bang_bang.c
> >>> @@ -0,0 +1,124 @@
> >>> +/*
> >>> + * gov_bang_bang.c - A simple thermal throttling governor using hysteresis
> >>> + *
> >>> + * Copyright (C) 2014 Peter Feuerer <[email protected]>
> >>> + *
> >>> + * Based on step_wise.c with following Copyrights:
> >>> + * Copyright (C) 2012 Intel Corp
> >>> + * Copyright (C) 2012 Durgadoss R <[email protected]>
> >>> + *
> >>> + *
> >>> + * This program is free software; you can redistribute it and/or modify
> >>> + * it under the terms of the GNU General Public License as published by
> >>> + * the Free Software Foundation, version 2.
> >>> + *
> >>> + * This program is distributed in the hope that it will be useful,
> >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
> >>> + * the GNU General Public License for more details.
> >>> + *
> >>> + */
> >>> +
> >>> +#include <linux/thermal.h>
> >>> +
> >>> +#include "thermal_core.h"
> >>> +
> >>> +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
> >>> +{
> >>> + long trip_temp;
> >>> + unsigned long trip_hyst;
> >>> + struct thermal_instance *instance;
> >>> +
> >>> + tz->ops->get_trip_temp(tz, trip, &trip_temp);
> >>> + tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
> >>> +
> >>> + dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
> >>> + trip, trip_temp, tz->temperature,
> >>> + trip_hyst);
> >>> +
> >>> + mutex_lock(&tz->lock);
> >>> +
> >>> + list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
> >>> + if (instance->trip != trip)
> >>> + continue;
> >>> +
> >>> + /* in case fan is neither on nor off set the fan to active */
> >>> + if (instance->target != 0 && instance->target != 1)
> >>> + instance->target = 1;
> >>
> >> I think you should add a pr_warn() here to warn the user that the
> >> governor is being used with a cooling device that seems to support
> >> more than one cooling state.
> >
> > Strange thing is, that the first time it is actually called with acerhdf
> > attached, it comes in with instance→target = -1 … I did not yet find out,
> > why.
> >
> > I'll further investigate on this and add some warning to it.
>
> I found out, that the default init state of a cooling device is:
>
> drivers/thermal/thermal_core.c:
> 960 dev->target = THERMAL_NO_TARGET;
>
> While drivers/thermal/thermal_core.h:
> 30 /* Initial state of a cooling device during binding */
> 31 #define THERMAL_NO_TARGET -1UL
>
>
> So I changed my patch to this:
>
> + /* in case fan is in initial state, switch the fan off */
> + if (instance->target == THERMAL_NO_TARGET)
> + instance->target = 0;
> +
> + /* in case fan is neither on nor off set the fan to active */
> + if (instance->target != 0 && instance->target != 1) {
> + pr_warn("Thermal instance %s controlled by bang-bang has unexpected state: %ld\n",
> + instance->name, instance->target);
> + instance->target = 1;
> + }

That sounds like a better solution, thanks!
Javi

2014-07-20 00:51:35

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v4 0/6] acerhdf/thermal: adding new models, appropriate governor and minor clean up

Hi,

This patch series is intended to:

* Introduce "manual mode" support (Patch 1 & 2), which is needed to control
the fan of a few new models.

* Add an appropriate thermal governor (Patch 3 & 4). Manipulating and
fiddling around with the step-wise governor has been a very fragile thing
in the past and as it broke again, I used the opportunity to add a two
point thermal governor which implements the actual fan handling required by
acerhdf and puts from my point of view things straight.

* Do some minor clean up like:
- adding second trip point for critical temperature (Patch 5)
- removing _t suffix from struct which isn't typedef and replace unsigned
char by u8 (Patch 6)

Thanks and kind regards,
peter

Peter Feuerer (6):
acerhdf: Adding support for "manual mode"
acerhdf: Adding support for new models
thermal: Added Bang-bang thermal governor
acerhdf: Use bang-bang thermal governor
acerhdf: added critical trip point
acerhdf: minor clean up

drivers/platform/x86/Kconfig | 2 +-
drivers/platform/x86/acerhdf.c | 266 ++++++++++++++++++++++++++--------------
drivers/thermal/Kconfig | 10 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/gov_bang_bang.c | 131 ++++++++++++++++++++
drivers/thermal/thermal_core.c | 5 +
drivers/thermal/thermal_core.h | 8 ++
7 files changed, 327 insertions(+), 96 deletions(-)
create mode 100644 drivers/thermal/gov_bang_bang.c

--
2.0.2

2014-07-20 00:51:41

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v4 1/6] acerhdf: Adding support for "manual mode"

Some Acer models require an additional command to turn off the fan after
bios mode has been enabled. Adding new section in bios table to allow
support for those models, by writing an extra "manual mode" register.

Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 187 +++++++++++++++++++++++------------------
1 file changed, 103 insertions(+), 84 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f94467c..dd63e93 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.26"
+#define DRV_VER "0.5.29"

/*
* According to the Atom N270 datasheet,
@@ -119,6 +119,17 @@ struct fancmd {
u8 cmd_auto;
};

+struct manualcmd {
+ u8 mreg;
+ u8 moff;
+};
+
+/* default register and command to disable fan in manual mode */
+static const struct manualcmd mcmd = {
+ .mreg = 0x94,
+ .moff = 0xff,
+};
+
/* BIOS settings */
struct bios_settings_t {
const char *vendor;
@@ -127,105 +138,107 @@ struct bios_settings_t {
unsigned char fanreg;
unsigned char tempreg;
struct fancmd cmd;
+ int mcmd_enable;
};

+
/* Register addresses and values for different BIOS versions */
static const struct bios_settings_t bios_tbl[] = {
/* AOA110 */
- {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00}, 0},
/* AOA150 */
- {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00}, 0},
/* LT1005u */
- {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 1410 */
- {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer 1810xx */
- {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer 531 */
- {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 751 */
- {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, 0},
/* Acer 1825 */
- {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer TravelMate 7730 */
- {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00} },
+ {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, 0},
/* Gateway */
- {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
- {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} },
- {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
+ {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Packard Bell */
- {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
+ {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
/* pewpew-terminator */
- {"", "", "", 0, 0, {0, 0} }
+ {"", "", "", 0, 0, {0, 0}, 0}
};

static const struct bios_settings_t *bios_cfg __read_mostly;
@@ -275,6 +288,12 @@ static void acerhdf_change_fanstate(int state)
fanstate = state;

ec_write(bios_cfg->fanreg, cmd);
+
+ if (bios_cfg->mcmd_enable && state == ACERHDF_FAN_OFF) {
+ if (verbose)
+ pr_notice("turning off fan manually\n");
+ ec_write(mcmd.mreg, mcmd.moff);
+ }
}

static void acerhdf_check_param(struct thermal_zone_device *thermal)
--
2.0.2

2014-07-20 00:52:04

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v4 2/6] acerhdf: Adding support for new models

added following new models:
* Aspire 5755G
* AO521
* AO751h
* Aspire One 753
* Extensa 5420
* Aspire 5315
* Aspire 5739G
* TravelMate TM8573T

Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index dd63e93..176edbd 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.29"
+#define DRV_VER "0.5.30"

/*
* According to the Atom N270 datasheet,
@@ -200,17 +200,33 @@ static const struct bios_settings_t bios_tbl[] = {
{"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
+ /* Acer 5755G */
+ {"Acer", "Aspire 5755G", "V1.20", 0xab, 0xb4, {0x00, 0x08}, 0},
+ {"Acer", "Aspire 5755G", "V1.21", 0xab, 0xb3, {0x00, 0x08}, 0},
+ /* Acer 521 */
+ {"Acer", "AO521", "V1.11", 0x55, 0x58, {0x1f, 0x00}, 0},
/* Acer 531 */
{"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, 0},
{"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, 0},
{"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 751 */
+ {"Acer", "AO751h", "V0.3206", 0x55, 0x58, {0x21, 0x00}, 0},
{"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, 0},
+ /* Acer 753 */
+ {"Acer", "Aspire One 753", "V1.24", 0x93, 0xac, {0x14, 0x04}, 1},
/* Acer 1825 */
{"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
+ /* Acer Extensa 5420 */
+ {"Acer", "Extensa 5420", "V1.17", 0x93, 0xac, {0x14, 0x04}, 1},
+ /* Acer Aspire 5315 */
+ {"Acer", "Aspire 5315", "V1.19", 0x93, 0xac, {0x14, 0x04}, 1},
+ /* Acer Aspire 5739 */
+ {"Acer", "Aspire 5739G", "V1.3311", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer TravelMate 7730 */
{"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, 0},
+ /* Acer TravelMate TM8573T */
+ {"Acer", "TM8573T", "V1.13", 0x93, 0xa8, {0x14, 0x04}, 1},
/* Gateway */
{"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, 0},
{"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, 0},
@@ -742,9 +758,15 @@ MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO751h*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1410*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1810*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5755G:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1825PTZ:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAO521*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO531*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5739G:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*One*753:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5315:");
MODULE_ALIAS("dmi:*:*Acer*:TravelMate*7730G:");
+MODULE_ALIAS("dmi:*:*Acer*:TM8573T:");
MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnAOA*:");
@@ -753,6 +775,7 @@ MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMU*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnENBFT*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMA*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTVR46*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnExtensa 5420*:");

module_init(acerhdf_init);
module_exit(acerhdf_exit);
--
2.0.2

2014-07-20 00:51:53

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v4 5/6] acerhdf: added critical trip point

added critical trip point which represents the temperature limit.
Added return -EINVAL in case wrong trip point is provided.

Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Javi Merino <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index e8c3111..0d521ea 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -444,6 +444,10 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*type = THERMAL_TRIP_ACTIVE;
+ else if (trip == 1)
+ *type = THERMAL_TRIP_CRITICAL;
+ else
+ return -EINVAL;

return 0;
}
@@ -464,6 +468,10 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*temp = fanon;
+ else if (trip == 1)
+ *temp = ACERHDF_TEMP_CRIT;
+ else
+ return -EINVAL;

return 0;
}
@@ -714,7 +722,7 @@ static int acerhdf_register_thermal(void)
if (IS_ERR(cl_dev))
return -EINVAL;

- thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
+ thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL,
&acerhdf_dev_ops,
&acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
--
2.0.2

2014-07-20 00:51:51

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v4 4/6] acerhdf: Use bang-bang thermal governor

acerhdf has been doing an on-off fan control using hysteresis by
post-manipulating the outcome of thermal subsystem trip point handling.
This patch enables acerhdf to use the bang-bang governor, which is
intended for on-off controlled fans.

Cc: Andrew Morton <[email protected]>
CC: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Javi Merino <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/Kconfig | 2 +-
drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 172f26c..d89252a 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -38,7 +38,7 @@ config ACER_WMI

config ACERHDF
tristate "Acer Aspire One temperature and fan driver"
- depends on THERMAL && ACPI
+ depends on ACPI && THERMAL_GOV_BANG_BANG
---help---
This is a driver for Acer Aspire One netbooks. It allows to access
the temperature sensor and to control the fan.
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 176edbd..e8c3111 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.30"
+#define DRV_VER "0.7.0"

/*
* According to the Atom N270 datasheet,
@@ -259,6 +259,14 @@ static const struct bios_settings_t bios_tbl[] = {

static const struct bios_settings_t *bios_cfg __read_mostly;

+/*
+ * this struct is used to instruct thermal layer to use bang_bang instead of
+ * default governor for acerhdf
+ */
+static struct thermal_zone_params acerhdf_zone_params = {
+ .governor_name = "bang_bang",
+};
+
static int acerhdf_get_temp(int *temp)
{
u8 read_temp;
@@ -440,6 +448,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
return 0;
}

+static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
+ unsigned long *temp)
+{
+ if (trip != 0)
+ return -EINVAL;
+
+ *temp = fanon - fanoff;
+
+ return 0;
+}
+
static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
unsigned long *temp)
{
@@ -464,6 +483,7 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
.get_mode = acerhdf_get_mode,
.set_mode = acerhdf_set_mode,
.get_trip_type = acerhdf_get_trip_type,
+ .get_trip_hyst = acerhdf_get_trip_hyst,
.get_trip_temp = acerhdf_get_trip_temp,
.get_crit_temp = acerhdf_get_crit_temp,
};
@@ -516,9 +536,7 @@ static int acerhdf_set_cur_state(struct thermal_cooling_device *cdev,
}

if (state == 0) {
- /* turn fan off only if below fanoff temperature */
- if ((cur_state == ACERHDF_FAN_AUTO) &&
- (cur_temp < fanoff))
+ if (cur_state == ACERHDF_FAN_AUTO)
acerhdf_change_fanstate(ACERHDF_FAN_OFF);
} else {
if (cur_state == ACERHDF_FAN_OFF)
@@ -697,11 +715,19 @@ static int acerhdf_register_thermal(void)
return -EINVAL;

thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
- &acerhdf_dev_ops, NULL, 0,
+ &acerhdf_dev_ops,
+ &acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
if (IS_ERR(thz_dev))
return -EINVAL;

+ if (strcmp(thz_dev->governor->name,
+ acerhdf_zone_params.governor_name)) {
+ pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n",
+ acerhdf_zone_params.governor_name);
+ return -EINVAL;
+ }
+
return 0;
}

--
2.0.2

2014-07-20 00:52:47

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v4 6/6] acerhdf: minor clean up

* renamed bios_settings_t to bios_settings, as it is no typedef
* replaced "unsigned char" by u8 in bios_settings struct for better
readability.

Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 0d521ea..e608ef1 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -131,19 +131,19 @@ static const struct manualcmd mcmd = {
};

/* BIOS settings */
-struct bios_settings_t {
+struct bios_settings {
const char *vendor;
const char *product;
const char *version;
- unsigned char fanreg;
- unsigned char tempreg;
+ u8 fanreg;
+ u8 tempreg;
struct fancmd cmd;
int mcmd_enable;
};


/* Register addresses and values for different BIOS versions */
-static const struct bios_settings_t bios_tbl[] = {
+static const struct bios_settings bios_tbl[] = {
/* AOA110 */
{"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00}, 0},
{"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
@@ -257,7 +257,7 @@ static const struct bios_settings_t bios_tbl[] = {
{"", "", "", 0, 0, {0, 0}, 0}
};

-static const struct bios_settings_t *bios_cfg __read_mostly;
+static const struct bios_settings *bios_cfg __read_mostly;

/*
* this struct is used to instruct thermal layer to use bang_bang instead of
@@ -620,7 +620,7 @@ static int str_starts_with(const char *str, const char *start)
static int acerhdf_check_hardware(void)
{
char const *vendor, *version, *product;
- const struct bios_settings_t *bt = NULL;
+ const struct bios_settings *bt = NULL;

/* get BIOS data */
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
--
2.0.2

2014-07-20 00:53:00

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v4 3/6] thermal: Added Bang-bang thermal governor

The bang-bang thermal governor uses a hysteresis to switch abruptly on
or off a cooling device. It is intended to control fans, which can
not be throttled but just switched on or off.
Bang-bang cannot be set as default governor as it is intended for
special devices only. For those special devices the driver needs to
explicitely request it.

Cc: Andrew Morton <[email protected]>
Cc: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Javi Merino <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/thermal/Kconfig | 10 +++
drivers/thermal/Makefile | 1 +
drivers/thermal/gov_bang_bang.c | 131 ++++++++++++++++++++++++++++++++++++++++
drivers/thermal/thermal_core.c | 5 ++
drivers/thermal/thermal_core.h | 8 +++
5 files changed, 155 insertions(+)
create mode 100644 drivers/thermal/gov_bang_bang.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index f9a1386..cdddf09 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -84,6 +84,16 @@ config THERMAL_GOV_STEP_WISE
Enable this to manage platform thermals using a simple linear
governor.

+config THERMAL_GOV_BANG_BANG
+ bool "Bang Bang thermal governor"
+ default y
+ help
+ Enable this to manage platform thermals using bang bang governor.
+
+ Say 'Y' here if you want to use two point temperature regulation
+ used for fans without throttling. Some fan drivers depend on this
+ governor to be enabled (e.g. acerhdf).
+
config THERMAL_GOV_USER_SPACE
bool "User_space thermal governor"
help
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index de0636a..a675980 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -11,6 +11,7 @@ thermal_sys-$(CONFIG_THERMAL_OF) += of-thermal.o

# governors
thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += fair_share.o
+thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o
thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += step_wise.o
thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE) += user_space.o

diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
new file mode 100644
index 0000000..c5dd76b
--- /dev/null
+++ b/drivers/thermal/gov_bang_bang.c
@@ -0,0 +1,131 @@
+/*
+ * gov_bang_bang.c - A simple thermal throttling governor using hysteresis
+ *
+ * Copyright (C) 2014 Peter Feuerer <[email protected]>
+ *
+ * Based on step_wise.c with following Copyrights:
+ * Copyright (C) 2012 Intel Corp
+ * Copyright (C) 2012 Durgadoss R <[email protected]>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ */
+
+#include <linux/thermal.h>
+
+#include "thermal_core.h"
+
+static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
+{
+ long trip_temp;
+ unsigned long trip_hyst;
+ struct thermal_instance *instance;
+
+ tz->ops->get_trip_temp(tz, trip, &trip_temp);
+ tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
+
+ dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
+ trip, trip_temp, tz->temperature,
+ trip_hyst);
+
+ mutex_lock(&tz->lock);
+
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+ if (instance->trip != trip)
+ continue;
+
+ /* in case fan is in initial state, switch the fan off */
+ if (instance->target == THERMAL_NO_TARGET)
+ instance->target = 0;
+
+ /* in case fan is neither on nor off set the fan to active */
+ if (instance->target != 0 && instance->target != 1) {
+ pr_warn("Thermal instance %s controlled by bang-bang has unexpected state: %ld\n",
+ instance->name, instance->target);
+ instance->target = 1;
+ }
+
+ /*
+ * enable fan when temperature exceeds trip_temp and disable
+ * the fan in case it falls below trip_temp minus hysteresis
+ */
+ if (instance->target == 0 && tz->temperature >= trip_temp)
+ instance->target = 1;
+ else if (instance->target == 1 &&
+ tz->temperature < trip_temp - trip_hyst)
+ instance->target = 0;
+
+ dev_dbg(&instance->cdev->device, "target=%d\n",
+ (int)instance->target);
+
+ instance->cdev->updated = false; /* cdev needs update */
+ }
+
+ mutex_unlock(&tz->lock);
+}
+
+/**
+ * bang_bang_control - controls devices associated with the given zone
+ * @tz - thermal_zone_device
+ * @trip - the trip point
+ *
+ * Regulation Logic: a two point regulation, deliver cooling state depending
+ * on the previous state shown in this diagram:
+ *
+ * Fan: OFF ON
+ *
+ * |
+ * |
+ * trip_temp: +---->+
+ * | | ^
+ * | | |
+ * | | Temperature
+ * (trip_temp - hyst): +<----+
+ * |
+ * |
+ * |
+ *
+ * * If the fan is not running and temperature exceeds trip_temp, the fan
+ * gets turned on.
+ * * In case the fan is running, temperature must fall below
+ * (trip_temp - hyst) so that the fan gets turned off again.
+ *
+ */
+static int bang_bang_control(struct thermal_zone_device *tz, int trip)
+{
+ struct thermal_instance *instance;
+
+ thermal_zone_trip_update(tz, trip);
+
+ mutex_lock(&tz->lock);
+
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node)
+ thermal_cdev_update(instance->cdev);
+
+ mutex_unlock(&tz->lock);
+
+ return 0;
+}
+
+static struct thermal_governor thermal_gov_bang_bang = {
+ .name = "bang_bang",
+ .throttle = bang_bang_control,
+};
+
+int thermal_gov_bang_bang_register(void)
+{
+ return thermal_register_governor(&thermal_gov_bang_bang);
+}
+
+void thermal_gov_bang_bang_unregister(void)
+{
+ thermal_unregister_governor(&thermal_gov_bang_bang);
+}
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 71b0ec0..4c2726b 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1790,6 +1790,10 @@ static int __init thermal_register_governors(void)
if (result)
return result;

+ result = thermal_gov_bang_bang_register();
+ if (result)
+ return result;
+
return thermal_gov_user_space_register();
}

@@ -1797,6 +1801,7 @@ static void thermal_unregister_governors(void)
{
thermal_gov_step_wise_unregister();
thermal_gov_fair_share_unregister();
+ thermal_gov_bang_bang_unregister();
thermal_gov_user_space_unregister();
}

diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 3db339f..d15d243 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -69,6 +69,14 @@ 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_BANG_BANG
+int thermal_gov_bang_bang_register(void);
+void thermal_gov_bang_bang_unregister(void);
+#else
+static inline int thermal_gov_bang_bang_register(void) { return 0; }
+static inline void thermal_gov_bang_bang_unregister(void) {}
+#endif /* CONFIG_THERMAL_GOV_BANG_BANG */
+
#ifdef CONFIG_THERMAL_GOV_USER_SPACE
int thermal_gov_user_space_register(void);
void thermal_gov_user_space_unregister(void);
--
2.0.2

2014-07-20 08:04:28

by Andreas Mohr

[permalink] [raw]
Subject: Re: [PATCH v4 1/6] acerhdf: Adding support for "manual mode"

Hi,

On Sun, Jul 20, 2014 at 02:51:15AM +0200, Peter Feuerer wrote:
> @@ -127,105 +138,107 @@ struct bios_settings_t {
> unsigned char fanreg;
> unsigned char tempreg;
> struct fancmd cmd;
> + int mcmd_enable;
> };
>
> +
> /* Register addresses and values for different BIOS versions */
> static const struct bios_settings_t bios_tbl[] = {

Change-unrelated content here, might want to move away.

Suggestion (if ok from a commit revision/history POV):
git rebase -i s:/'acerhdf: Adding support for "manual mode"'~1
<"e"dit first commit>
git checkout -p s:/'acerhdf: Adding support for "manual mode"'
<grab hunk [split as needed]>
git commit -m "FIXUP"
git rebase --continue
git rebase -i s:/'acerhdf: Adding support for "manual mode"'~1
<move FIXUP line post [PATCH v4 6/6] acerhdf: minor clean up>
<do "f"ixup>


Sorry that I didn't find worse breakage during my review
than this si{mp|ng}le line ;)

Andreas

2014-07-20 10:42:59

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v4 1/6] acerhdf: Adding support for "manual mode"

Hi Andreas,

Andreas Mohr writes:

> Hi
>
> On Sun, Jul 20, 2014 at 02:51:15AM +0200, Peter Feuerer wrote:
>> @@ -127,105 +138,107 @@ struct bios_settings_t {
>> unsigned char fanreg;
>> unsigned char tempreg;
>> struct fancmd cmd;
>> + int mcmd_enable;
>> };
>>
>> +
>> /* Register addresses and values for different BIOS versions */
>> static const struct bios_settings_t bios_tbl[] = {
>
> Change-unrelated content here, might want to move away.

You mean this newline?


> Suggestion (if ok from a commit revision/history POV):
> git rebase -i s:/'acerhdf: Adding support for "manual mode"'~1
> <"e"dit first commit>
> git checkout -p s:/'acerhdf: Adding support for "manual mode"'
> <grab hunk [split as needed]>
> git commit -m "FIXUP"
> git rebase --continue
> git rebase -i s:/'acerhdf: Adding support for "manual mode"'~1
> <move FIXUP line post [PATCH v4 6/6] acerhdf: minor clean up>
> <do "f"ixup>

If I understand this correctly, you want me to move this new line
to patch 6, correct?


> Sorry that I didn't find worse breakage during my review
> than this si{mp|ng}le line ;)

No problem, as long as you give your Acked-by / Reviewed-by ;)

--peter;

2014-07-20 20:20:53

by Andreas Mohr

[permalink] [raw]
Subject: Re: [PATCH v4 1/6] acerhdf: Adding support for "manual mode"

Hi,

On Sun, Jul 20, 2014 at 12:42:53PM +0200, Peter Feuerer wrote:
> Hi Andreas,
>
> Andreas Mohr writes:
> >On Sun, Jul 20, 2014 at 02:51:15AM +0200, Peter Feuerer wrote:
> >>@@ -127,105 +138,107 @@ struct bios_settings_t {
> >> unsigned char fanreg;
> >> unsigned char tempreg;
> >> struct fancmd cmd;
> >>+ int mcmd_enable;
> >> };
> >>+
> >> /* Register addresses and values for different BIOS versions */
> >> static const struct bios_settings_t bios_tbl[] = {
> >
> >Change-unrelated content here, might want to move away.
>
> You mean this newline?

Yup.

> >Suggestion (if ok from a commit revision/history POV):
> >git rebase -i s:/'acerhdf: Adding support for "manual mode"'~1
> ><"e"dit first commit>
> >git checkout -p s:/'acerhdf: Adding support for "manual mode"'
> ><grab hunk [split as needed]>
> >git commit -m "FIXUP"
> >git rebase --continue
> >git rebase -i s:/'acerhdf: Adding support for "manual mode"'~1
> ><move FIXUP line post [PATCH v4 6/6] acerhdf: minor clean up>
> ><do "f"ixup>
>
> If I understand this correctly, you want me to move this new line
> to patch 6, correct?

Yup, to a suitable "other stuff" location, which patch 6 likely would be.

> >Sorry that I didn't find worse breakage during my review
> >than this si{mp|ng}le line ;)
>
> No problem, as long as you give your Acked-by / Reviewed-by ;)

Hmm, I'm unsure whether my involvement is sufficient for a full Reviewed-by
(think full replacement of core driver mechanisms as in bang-bang governor,
etc.).

But yeah, at least I can say I did review things
and I did not see any obvious issues.

Thanks,

Andreas

2014-07-21 09:29:57

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH v4 3/6] thermal: Added Bang-bang thermal governor

On Sun, Jul 20, 2014 at 02:51:17AM +0200, Peter Feuerer wrote:
> The bang-bang thermal governor uses a hysteresis to switch abruptly on
> or off a cooling device. It is intended to control fans, which can
> not be throttled but just switched on or off.
> Bang-bang cannot be set as default governor as it is intended for
> special devices only. For those special devices the driver needs to
> explicitely request it.
>
> Cc: Andrew Morton <[email protected]>
> Cc: Zhang Rui <[email protected]>
> Cc: Andreas Mohr <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: Javi Merino <[email protected]>
> Signed-off-by: Peter Feuerer <[email protected]>
> ---
> drivers/thermal/Kconfig | 10 +++
> drivers/thermal/Makefile | 1 +
> drivers/thermal/gov_bang_bang.c | 131 ++++++++++++++++++++++++++++++++++++++++
> drivers/thermal/thermal_core.c | 5 ++
> drivers/thermal/thermal_core.h | 8 +++
> 5 files changed, 155 insertions(+)
> create mode 100644 drivers/thermal/gov_bang_bang.c
>
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index f9a1386..cdddf09 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -84,6 +84,16 @@ config THERMAL_GOV_STEP_WISE
> Enable this to manage platform thermals using a simple linear
> governor.
>
> +config THERMAL_GOV_BANG_BANG
> + bool "Bang Bang thermal governor"
> + default y

Right, this is problematic.

When people are faced with the new selection after doing oldconfig, they
can say yes or no.

However, as acerhdf depends on it now, prompting the user to
unconditionally says yes is kinda redundant. Especially as this governor
is not supposed to be default anyway.

Actually you don't need the Kconfig prompt at all as this is a sort-of
"internal" governor and devices select it. IOW, it should be "default n"
and ACERHDF will do "select THERMAL_GOV_BANG_BANG". Something like that
at least.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2014-07-21 09:37:15

by Zhang, Rui

[permalink] [raw]
Subject: Re: [PATCH v4 3/6] thermal: Added Bang-bang thermal governor

On Mon, 2014-07-21 at 11:29 +0200, Borislav Petkov wrote:
> On Sun, Jul 20, 2014 at 02:51:17AM +0200, Peter Feuerer wrote:
> > The bang-bang thermal governor uses a hysteresis to switch abruptly on
> > or off a cooling device. It is intended to control fans, which can
> > not be throttled but just switched on or off.
> > Bang-bang cannot be set as default governor as it is intended for
> > special devices only. For those special devices the driver needs to
> > explicitely request it.
> >
> > Cc: Andrew Morton <[email protected]>
> > Cc: Zhang Rui <[email protected]>
> > Cc: Andreas Mohr <[email protected]>
> > Cc: Borislav Petkov <[email protected]>
> > Cc: Javi Merino <[email protected]>
> > Signed-off-by: Peter Feuerer <[email protected]>

For thermal related patches, please do cc linux-pm mailing list so that
I can see them in patchwork.

thanks,
rui
> > ---
> > drivers/thermal/Kconfig | 10 +++
> > drivers/thermal/Makefile | 1 +
> > drivers/thermal/gov_bang_bang.c | 131 ++++++++++++++++++++++++++++++++++++++++
> > drivers/thermal/thermal_core.c | 5 ++
> > drivers/thermal/thermal_core.h | 8 +++
> > 5 files changed, 155 insertions(+)
> > create mode 100644 drivers/thermal/gov_bang_bang.c
> >
> > diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> > index f9a1386..cdddf09 100644
> > --- a/drivers/thermal/Kconfig
> > +++ b/drivers/thermal/Kconfig
> > @@ -84,6 +84,16 @@ config THERMAL_GOV_STEP_WISE
> > Enable this to manage platform thermals using a simple linear
> > governor.
> >
> > +config THERMAL_GOV_BANG_BANG
> > + bool "Bang Bang thermal governor"
> > + default y
>
> Right, this is problematic.
>
> When people are faced with the new selection after doing oldconfig, they
> can say yes or no.
>
> However, as acerhdf depends on it now, prompting the user to
> unconditionally says yes is kinda redundant. Especially as this governor
> is not supposed to be default anyway.
>
> Actually you don't need the Kconfig prompt at all as this is a sort-of
> "internal" governor and devices select it. IOW, it should be "default n"
> and ACERHDF will do "select THERMAL_GOV_BANG_BANG". Something like that
> at least.
>

2014-07-21 09:40:55

by Zhang, Rui

[permalink] [raw]
Subject: Re: [PATCH v4 3/6] thermal: Added Bang-bang thermal governor

On Mon, 2014-07-21 at 11:29 +0200, Borislav Petkov wrote:
> On Sun, Jul 20, 2014 at 02:51:17AM +0200, Peter Feuerer wrote:
> > The bang-bang thermal governor uses a hysteresis to switch abruptly on
> > or off a cooling device. It is intended to control fans, which can
> > not be throttled but just switched on or off.
> > Bang-bang cannot be set as default governor as it is intended for
> > special devices only. For those special devices the driver needs to
> > explicitely request it.
> >
> > Cc: Andrew Morton <[email protected]>
> > Cc: Zhang Rui <[email protected]>
> > Cc: Andreas Mohr <[email protected]>
> > Cc: Borislav Petkov <[email protected]>
> > Cc: Javi Merino <[email protected]>
> > Signed-off-by: Peter Feuerer <[email protected]>
> > ---
> > drivers/thermal/Kconfig | 10 +++
> > drivers/thermal/Makefile | 1 +
> > drivers/thermal/gov_bang_bang.c | 131 ++++++++++++++++++++++++++++++++++++++++
> > drivers/thermal/thermal_core.c | 5 ++
> > drivers/thermal/thermal_core.h | 8 +++
> > 5 files changed, 155 insertions(+)
> > create mode 100644 drivers/thermal/gov_bang_bang.c
> >
> > diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> > index f9a1386..cdddf09 100644
> > --- a/drivers/thermal/Kconfig
> > +++ b/drivers/thermal/Kconfig
> > @@ -84,6 +84,16 @@ config THERMAL_GOV_STEP_WISE
> > Enable this to manage platform thermals using a simple linear
> > governor.
> >
> > +config THERMAL_GOV_BANG_BANG
> > + bool "Bang Bang thermal governor"
> > + default y
>
> Right, this is problematic.
>
> When people are faced with the new selection after doing oldconfig, they
> can say yes or no.
>
> However, as acerhdf depends on it now, prompting the user to
> unconditionally says yes is kinda redundant. Especially as this governor
> is not supposed to be default anyway.
>
> Actually you don't need the Kconfig prompt at all as this is a sort-of
> "internal" governor and devices select it. IOW, it should be "default n"
> and ACERHDF will do "select THERMAL_GOV_BANG_BANG". Something like that
> at least.
>
I agree with this approach.

thanks,
rui

2014-07-21 10:23:54

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH v4 4/6] acerhdf: Use bang-bang thermal governor

On Sun, Jul 20, 2014 at 02:51:18AM +0200, Peter Feuerer wrote:
> acerhdf has been doing an on-off fan control using hysteresis by
> post-manipulating the outcome of thermal subsystem trip point handling.
> This patch enables acerhdf to use the bang-bang governor, which is
> intended for on-off controlled fans.

Initial testing looks good.

It wasn't that easy to test though, judging by the current weather
temperatures - I had to go into the fridge with the laptop to cause it
to go under fanoff :-)

Acked-and-tested-by: Borislav Petkov <[email protected]>

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2014-07-22 15:04:25

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v4 3/6] thermal: Added Bang-bang thermal governor

Hi,

Zhang Rui writes:

> On Mon, 2014-07-21 at 11:29 +0200, Borislav Petkov wrote:
>> On Sun, Jul 20, 2014 at 02:51:17AM +0200, Peter Feuerer wrote:
>> > The bang-bang thermal governor uses a hysteresis to switch abruptly on
>> > or off a cooling device. It is intended to control fans, which can
>> > not be throttled but just switched on or off.
>> > Bang-bang cannot be set as default governor as it is intended for
>> > special devices only. For those special devices the driver needs to
>> > explicitely request it.
>> >
>> > Cc: Andrew Morton <[email protected]>
>> > Cc: Zhang Rui <[email protected]>
>> > Cc: Andreas Mohr <[email protected]>
>> > Cc: Borislav Petkov <[email protected]>
>> > Cc: Javi Merino <[email protected]>
>> > Signed-off-by: Peter Feuerer <[email protected]>
>> > ---
>> > drivers/thermal/Kconfig | 10 +++
>> > drivers/thermal/Makefile | 1 +
>> > drivers/thermal/gov_bang_bang.c | 131 ++++++++++++++++++++++++++++++++++++++++
>> > drivers/thermal/thermal_core.c | 5 ++
>> > drivers/thermal/thermal_core.h | 8 +++
>> > 5 files changed, 155 insertions(+)
>> > create mode 100644 drivers/thermal/gov_bang_bang.c
>> >
>> > diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
>> > index f9a1386..cdddf09 100644
>> > --- a/drivers/thermal/Kconfig
>> > +++ b/drivers/thermal/Kconfig
>> > @@ -84,6 +84,16 @@ config THERMAL_GOV_STEP_WISE
>> > Enable this to manage platform thermals using a simple linear
>> > governor.
>> >
>> > +config THERMAL_GOV_BANG_BANG
>> > + bool "Bang Bang thermal governor"
>> > + default y
>>
>> Right, this is problematic.
>>
>> When people are faced with the new selection after doing oldconfig, they
>> can say yes or no.
>>
>> However, as acerhdf depends on it now, prompting the user to
>> unconditionally says yes is kinda redundant. Especially as this governor
>> is not supposed to be default anyway.
>>
>> Actually you don't need the Kconfig prompt at all as this is a sort-of
>> "internal" governor and devices select it. IOW, it should be "default n"
>> and ACERHDF will do "select THERMAL_GOV_BANG_BANG". Something like that
>> at least.
>>
> I agree with this approach.

Yes, you are right, this looks better. Then the "depend on
THERMAL_GOV_BANG_BANG" could be removed from acerhdf Kbuild, as the "select"
will take care acerhdf is compiled with THERMAL_GOV_BANG_BANG enabled,
right?

--
--peter;

2014-07-22 15:37:23

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v5 0/6] acerhdf/thermal: adding new models, appropriate governor and minor clean up

Hi,

This patch series is intended to:

* Introduce "manual mode" support (Patch 1 & 2), which is needed to control
the fan of a few new models.

* Add an appropriate thermal governor (Patch 3 & 4). Manipulating and
fiddling around with the step-wise governor has been a very fragile thing
in the past and as it broke again, I used the opportunity to add a two
point thermal governor which implements the actual fan handling required by
acerhdf and puts from my point of view things straight.

* Do some minor clean up like:
- adding second trip point for critical temperature (Patch 5)
- removing _t suffix from struct which isn't typedef and replace unsigned
char by u8 (Patch 6)

Thanks and kind regards,
peter

Peter Feuerer (6):
acerhdf: Adding support for "manual mode"
acerhdf: Adding support for new models
thermal: Added Bang-bang thermal governor
acerhdf: Use bang-bang thermal governor
acerhdf: added critical trip point
acerhdf: minor clean up

drivers/platform/x86/Kconfig | 3 +-
drivers/platform/x86/acerhdf.c | 265 ++++++++++++++++++++++++++--------------
drivers/thermal/Kconfig | 10 ++
drivers/thermal/Makefile | 1 +
drivers/thermal/gov_bang_bang.c | 131 ++++++++++++++++++++
drivers/thermal/thermal_core.c | 5 +
drivers/thermal/thermal_core.h | 8 ++
7 files changed, 327 insertions(+), 96 deletions(-)
create mode 100644 drivers/thermal/gov_bang_bang.c

--
2.0.2

2014-07-22 15:37:40

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v5 1/6] acerhdf: Adding support for "manual mode"

Some Acer models require an additional command to turn off the fan after
bios mode has been enabled. Adding new section in bios table to allow
support for those models, by writing an extra "manual mode" register.

Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 186 ++++++++++++++++++++++-------------------
1 file changed, 102 insertions(+), 84 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f94467c..2c58f10 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.26"
+#define DRV_VER "0.5.29"

/*
* According to the Atom N270 datasheet,
@@ -119,6 +119,17 @@ struct fancmd {
u8 cmd_auto;
};

+struct manualcmd {
+ u8 mreg;
+ u8 moff;
+};
+
+/* default register and command to disable fan in manual mode */
+static const struct manualcmd mcmd = {
+ .mreg = 0x94,
+ .moff = 0xff,
+};
+
/* BIOS settings */
struct bios_settings_t {
const char *vendor;
@@ -127,105 +138,106 @@ struct bios_settings_t {
unsigned char fanreg;
unsigned char tempreg;
struct fancmd cmd;
+ int mcmd_enable;
};

/* Register addresses and values for different BIOS versions */
static const struct bios_settings_t bios_tbl[] = {
/* AOA110 */
- {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00}, 0},
/* AOA150 */
- {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00}, 0},
/* LT1005u */
- {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 1410 */
- {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer 1810xx */
- {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer 531 */
- {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 751 */
- {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, 0},
/* Acer 1825 */
- {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer TravelMate 7730 */
- {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00} },
+ {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, 0},
/* Gateway */
- {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
- {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} },
- {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
+ {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Packard Bell */
- {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
+ {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
/* pewpew-terminator */
- {"", "", "", 0, 0, {0, 0} }
+ {"", "", "", 0, 0, {0, 0}, 0}
};

static const struct bios_settings_t *bios_cfg __read_mostly;
@@ -275,6 +287,12 @@ static void acerhdf_change_fanstate(int state)
fanstate = state;

ec_write(bios_cfg->fanreg, cmd);
+
+ if (bios_cfg->mcmd_enable && state == ACERHDF_FAN_OFF) {
+ if (verbose)
+ pr_notice("turning off fan manually\n");
+ ec_write(mcmd.mreg, mcmd.moff);
+ }
}

static void acerhdf_check_param(struct thermal_zone_device *thermal)
--
2.0.2

2014-07-22 15:37:40

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v5 5/6] acerhdf: added critical trip point

added critical trip point which represents the temperature limit.
Added return -EINVAL in case wrong trip point is provided.

Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Javi Merino <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 7fe7dbf..91b16c8 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -443,6 +443,10 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*type = THERMAL_TRIP_ACTIVE;
+ else if (trip == 1)
+ *type = THERMAL_TRIP_CRITICAL;
+ else
+ return -EINVAL;

return 0;
}
@@ -463,6 +467,10 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*temp = fanon;
+ else if (trip == 1)
+ *temp = ACERHDF_TEMP_CRIT;
+ else
+ return -EINVAL;

return 0;
}
@@ -713,7 +721,7 @@ static int acerhdf_register_thermal(void)
if (IS_ERR(cl_dev))
return -EINVAL;

- thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
+ thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL,
&acerhdf_dev_ops,
&acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
--
2.0.2

2014-07-22 15:38:31

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v5 2/6] acerhdf: Adding support for new models

added following new models:
* Aspire 5755G
* AO521
* AO751h
* Aspire One 753
* Extensa 5420
* Aspire 5315
* Aspire 5739G
* TravelMate TM8573T

Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 2c58f10..f30767f 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.29"
+#define DRV_VER "0.5.30"

/*
* According to the Atom N270 datasheet,
@@ -199,17 +199,33 @@ static const struct bios_settings_t bios_tbl[] = {
{"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
+ /* Acer 5755G */
+ {"Acer", "Aspire 5755G", "V1.20", 0xab, 0xb4, {0x00, 0x08}, 0},
+ {"Acer", "Aspire 5755G", "V1.21", 0xab, 0xb3, {0x00, 0x08}, 0},
+ /* Acer 521 */
+ {"Acer", "AO521", "V1.11", 0x55, 0x58, {0x1f, 0x00}, 0},
/* Acer 531 */
{"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, 0},
{"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, 0},
{"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 751 */
+ {"Acer", "AO751h", "V0.3206", 0x55, 0x58, {0x21, 0x00}, 0},
{"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, 0},
+ /* Acer 753 */
+ {"Acer", "Aspire One 753", "V1.24", 0x93, 0xac, {0x14, 0x04}, 1},
/* Acer 1825 */
{"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
+ /* Acer Extensa 5420 */
+ {"Acer", "Extensa 5420", "V1.17", 0x93, 0xac, {0x14, 0x04}, 1},
+ /* Acer Aspire 5315 */
+ {"Acer", "Aspire 5315", "V1.19", 0x93, 0xac, {0x14, 0x04}, 1},
+ /* Acer Aspire 5739 */
+ {"Acer", "Aspire 5739G", "V1.3311", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer TravelMate 7730 */
{"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, 0},
+ /* Acer TravelMate TM8573T */
+ {"Acer", "TM8573T", "V1.13", 0x93, 0xa8, {0x14, 0x04}, 1},
/* Gateway */
{"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, 0},
{"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, 0},
@@ -741,9 +757,15 @@ MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO751h*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1410*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1810*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5755G:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1825PTZ:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAO521*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO531*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5739G:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*One*753:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5315:");
MODULE_ALIAS("dmi:*:*Acer*:TravelMate*7730G:");
+MODULE_ALIAS("dmi:*:*Acer*:TM8573T:");
MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnAOA*:");
@@ -752,6 +774,7 @@ MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMU*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnENBFT*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMA*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTVR46*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnExtensa 5420*:");

module_init(acerhdf_init);
module_exit(acerhdf_exit);
--
2.0.2

2014-07-22 15:38:33

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v5 4/6] acerhdf: Use bang-bang thermal governor

acerhdf has been doing an on-off fan control using hysteresis by
post-manipulating the outcome of thermal subsystem trip point handling.
This patch enables acerhdf to use the bang-bang governor, which is
intended for on-off controlled fans.

Cc: Andrew Morton <[email protected]>
CC: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Javi Merino <[email protected]>
Acked-and-tested-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/Kconfig | 3 ++-
drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 172f26c..b5e80dc 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -38,7 +38,8 @@ config ACER_WMI

config ACERHDF
tristate "Acer Aspire One temperature and fan driver"
- depends on THERMAL && ACPI
+ select THERMAL_GOV_BANG_BANG
+ depends on ACPI
---help---
This is a driver for Acer Aspire One netbooks. It allows to access
the temperature sensor and to control the fan.
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f30767f..7fe7dbf 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.30"
+#define DRV_VER "0.7.0"

/*
* According to the Atom N270 datasheet,
@@ -258,6 +258,14 @@ static const struct bios_settings_t bios_tbl[] = {

static const struct bios_settings_t *bios_cfg __read_mostly;

+/*
+ * this struct is used to instruct thermal layer to use bang_bang instead of
+ * default governor for acerhdf
+ */
+static struct thermal_zone_params acerhdf_zone_params = {
+ .governor_name = "bang_bang",
+};
+
static int acerhdf_get_temp(int *temp)
{
u8 read_temp;
@@ -439,6 +447,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
return 0;
}

+static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
+ unsigned long *temp)
+{
+ if (trip != 0)
+ return -EINVAL;
+
+ *temp = fanon - fanoff;
+
+ return 0;
+}
+
static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
unsigned long *temp)
{
@@ -463,6 +482,7 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
.get_mode = acerhdf_get_mode,
.set_mode = acerhdf_set_mode,
.get_trip_type = acerhdf_get_trip_type,
+ .get_trip_hyst = acerhdf_get_trip_hyst,
.get_trip_temp = acerhdf_get_trip_temp,
.get_crit_temp = acerhdf_get_crit_temp,
};
@@ -515,9 +535,7 @@ static int acerhdf_set_cur_state(struct thermal_cooling_device *cdev,
}

if (state == 0) {
- /* turn fan off only if below fanoff temperature */
- if ((cur_state == ACERHDF_FAN_AUTO) &&
- (cur_temp < fanoff))
+ if (cur_state == ACERHDF_FAN_AUTO)
acerhdf_change_fanstate(ACERHDF_FAN_OFF);
} else {
if (cur_state == ACERHDF_FAN_OFF)
@@ -696,11 +714,19 @@ static int acerhdf_register_thermal(void)
return -EINVAL;

thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
- &acerhdf_dev_ops, NULL, 0,
+ &acerhdf_dev_ops,
+ &acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
if (IS_ERR(thz_dev))
return -EINVAL;

+ if (strcmp(thz_dev->governor->name,
+ acerhdf_zone_params.governor_name)) {
+ pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n",
+ acerhdf_zone_params.governor_name);
+ return -EINVAL;
+ }
+
return 0;
}

--
2.0.2

2014-07-22 15:38:32

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v5 6/6] acerhdf: minor clean up

* renamed bios_settings_t to bios_settings, as it is no typedef
* replaced "unsigned char" by u8 in bios_settings struct for better
readability.

Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 91b16c8..c07623c 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -131,18 +131,18 @@ static const struct manualcmd mcmd = {
};

/* BIOS settings */
-struct bios_settings_t {
+struct bios_settings {
const char *vendor;
const char *product;
const char *version;
- unsigned char fanreg;
- unsigned char tempreg;
+ u8 fanreg;
+ u8 tempreg;
struct fancmd cmd;
int mcmd_enable;
};

/* Register addresses and values for different BIOS versions */
-static const struct bios_settings_t bios_tbl[] = {
+static const struct bios_settings bios_tbl[] = {
/* AOA110 */
{"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00}, 0},
{"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
@@ -256,7 +256,7 @@ static const struct bios_settings_t bios_tbl[] = {
{"", "", "", 0, 0, {0, 0}, 0}
};

-static const struct bios_settings_t *bios_cfg __read_mostly;
+static const struct bios_settings *bios_cfg __read_mostly;

/*
* this struct is used to instruct thermal layer to use bang_bang instead of
@@ -619,7 +619,7 @@ static int str_starts_with(const char *str, const char *start)
static int acerhdf_check_hardware(void)
{
char const *vendor, *version, *product;
- const struct bios_settings_t *bt = NULL;
+ const struct bios_settings *bt = NULL;

/* get BIOS data */
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
--
2.0.2

2014-07-22 15:38:30

by Peter Kästle

[permalink] [raw]
Subject: [PATCH v5 3/6] thermal: Added Bang-bang thermal governor

The bang-bang thermal governor uses a hysteresis to switch abruptly on
or off a cooling device. It is intended to control fans, which can
not be throttled but just switched on or off.
Bang-bang cannot be set as default governor as it is intended for
special devices only. For those special devices the driver needs to
explicitely request it.

Cc: Andrew Morton <[email protected]>
Cc: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Javi Merino <[email protected]>
Cc: [email protected]
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/thermal/Kconfig | 10 +++
drivers/thermal/Makefile | 1 +
drivers/thermal/gov_bang_bang.c | 131 ++++++++++++++++++++++++++++++++++++++++
drivers/thermal/thermal_core.c | 5 ++
drivers/thermal/thermal_core.h | 8 +++
5 files changed, 155 insertions(+)
create mode 100644 drivers/thermal/gov_bang_bang.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index f9a1386..fa14d56 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -84,6 +84,16 @@ config THERMAL_GOV_STEP_WISE
Enable this to manage platform thermals using a simple linear
governor.

+config THERMAL_GOV_BANG_BANG
+ bool "Bang Bang thermal governor"
+ default n
+ help
+ Enable this to manage platform thermals using bang bang governor.
+
+ Say 'Y' here if you want to use two point temperature regulation
+ used for fans without throttling. Some fan drivers depend on this
+ governor to be enabled (e.g. acerhdf).
+
config THERMAL_GOV_USER_SPACE
bool "User_space thermal governor"
help
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index de0636a..a675980 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -11,6 +11,7 @@ thermal_sys-$(CONFIG_THERMAL_OF) += of-thermal.o

# governors
thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += fair_share.o
+thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o
thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += step_wise.o
thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE) += user_space.o

diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
new file mode 100644
index 0000000..c5dd76b
--- /dev/null
+++ b/drivers/thermal/gov_bang_bang.c
@@ -0,0 +1,131 @@
+/*
+ * gov_bang_bang.c - A simple thermal throttling governor using hysteresis
+ *
+ * Copyright (C) 2014 Peter Feuerer <[email protected]>
+ *
+ * Based on step_wise.c with following Copyrights:
+ * Copyright (C) 2012 Intel Corp
+ * Copyright (C) 2012 Durgadoss R <[email protected]>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ */
+
+#include <linux/thermal.h>
+
+#include "thermal_core.h"
+
+static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
+{
+ long trip_temp;
+ unsigned long trip_hyst;
+ struct thermal_instance *instance;
+
+ tz->ops->get_trip_temp(tz, trip, &trip_temp);
+ tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
+
+ dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
+ trip, trip_temp, tz->temperature,
+ trip_hyst);
+
+ mutex_lock(&tz->lock);
+
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+ if (instance->trip != trip)
+ continue;
+
+ /* in case fan is in initial state, switch the fan off */
+ if (instance->target == THERMAL_NO_TARGET)
+ instance->target = 0;
+
+ /* in case fan is neither on nor off set the fan to active */
+ if (instance->target != 0 && instance->target != 1) {
+ pr_warn("Thermal instance %s controlled by bang-bang has unexpected state: %ld\n",
+ instance->name, instance->target);
+ instance->target = 1;
+ }
+
+ /*
+ * enable fan when temperature exceeds trip_temp and disable
+ * the fan in case it falls below trip_temp minus hysteresis
+ */
+ if (instance->target == 0 && tz->temperature >= trip_temp)
+ instance->target = 1;
+ else if (instance->target == 1 &&
+ tz->temperature < trip_temp - trip_hyst)
+ instance->target = 0;
+
+ dev_dbg(&instance->cdev->device, "target=%d\n",
+ (int)instance->target);
+
+ instance->cdev->updated = false; /* cdev needs update */
+ }
+
+ mutex_unlock(&tz->lock);
+}
+
+/**
+ * bang_bang_control - controls devices associated with the given zone
+ * @tz - thermal_zone_device
+ * @trip - the trip point
+ *
+ * Regulation Logic: a two point regulation, deliver cooling state depending
+ * on the previous state shown in this diagram:
+ *
+ * Fan: OFF ON
+ *
+ * |
+ * |
+ * trip_temp: +---->+
+ * | | ^
+ * | | |
+ * | | Temperature
+ * (trip_temp - hyst): +<----+
+ * |
+ * |
+ * |
+ *
+ * * If the fan is not running and temperature exceeds trip_temp, the fan
+ * gets turned on.
+ * * In case the fan is running, temperature must fall below
+ * (trip_temp - hyst) so that the fan gets turned off again.
+ *
+ */
+static int bang_bang_control(struct thermal_zone_device *tz, int trip)
+{
+ struct thermal_instance *instance;
+
+ thermal_zone_trip_update(tz, trip);
+
+ mutex_lock(&tz->lock);
+
+ list_for_each_entry(instance, &tz->thermal_instances, tz_node)
+ thermal_cdev_update(instance->cdev);
+
+ mutex_unlock(&tz->lock);
+
+ return 0;
+}
+
+static struct thermal_governor thermal_gov_bang_bang = {
+ .name = "bang_bang",
+ .throttle = bang_bang_control,
+};
+
+int thermal_gov_bang_bang_register(void)
+{
+ return thermal_register_governor(&thermal_gov_bang_bang);
+}
+
+void thermal_gov_bang_bang_unregister(void)
+{
+ thermal_unregister_governor(&thermal_gov_bang_bang);
+}
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 71b0ec0..4c2726b 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1790,6 +1790,10 @@ static int __init thermal_register_governors(void)
if (result)
return result;

+ result = thermal_gov_bang_bang_register();
+ if (result)
+ return result;
+
return thermal_gov_user_space_register();
}

@@ -1797,6 +1801,7 @@ static void thermal_unregister_governors(void)
{
thermal_gov_step_wise_unregister();
thermal_gov_fair_share_unregister();
+ thermal_gov_bang_bang_unregister();
thermal_gov_user_space_unregister();
}

diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 3db339f..d15d243 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -69,6 +69,14 @@ 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_BANG_BANG
+int thermal_gov_bang_bang_register(void);
+void thermal_gov_bang_bang_unregister(void);
+#else
+static inline int thermal_gov_bang_bang_register(void) { return 0; }
+static inline void thermal_gov_bang_bang_unregister(void) {}
+#endif /* CONFIG_THERMAL_GOV_BANG_BANG */
+
#ifdef CONFIG_THERMAL_GOV_USER_SPACE
int thermal_gov_user_space_register(void);
void thermal_gov_user_space_unregister(void);
--
2.0.2

2014-07-22 16:09:07

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH v4 3/6] thermal: Added Bang-bang thermal governor

On Tue, Jul 22, 2014 at 04:59:02PM +0200, Peter Feuerer wrote:
> Then the "depend on THERMAL_GOV_BANG_BANG" could be removed from
> acerhdf Kbuild, as the "select" will take care acerhdf is compiled
> with THERMAL_GOV_BANG_BANG enabled, right?

Yes, try it.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2014-07-26 14:14:53

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v5 3/6] thermal: Added Bang-bang thermal governor

Hi Rui,

Peter Feuerer writes:

> The bang-bang thermal governor uses a hysteresis to switch abruptly on
> or off a cooling device. It is intended to control fans, which can
> not be throttled but just switched on or off.
> Bang-bang cannot be set as default governor as it is intended for
> special devices only. For those special devices the driver needs to
> explicitely request it.
>
> Cc: Andrew Morton <[email protected]>
> Cc: Zhang Rui <[email protected]>

Anything that prevents you from giving your acked-by?

[...]

--
kind regards,
--peter;

2014-07-26 14:16:24

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v5 5/6] acerhdf: added critical trip point

Hi Boris,

Peter Feuerer writes:

> added critical trip point which represents the temperature limit.
> Added return -EINVAL in case wrong trip point is provided.
>
> Cc: Andrew Morton <[email protected]>
> Cc: Andreas Mohr <[email protected]>
> Cc: Borislav Petkov <[email protected]>

Any concerns regarding this patch?

--
--peter;

2014-07-28 02:26:37

by Zhang, Rui

[permalink] [raw]
Subject: Re: [PATCH v5 3/6] thermal: Added Bang-bang thermal governor

On Sat, 2014-07-26 at 16:14 +0200, Peter Feuerer wrote:
> Hi Rui,
>
> Peter Feuerer writes:
>
> > The bang-bang thermal governor uses a hysteresis to switch abruptly on
> > or off a cooling device. It is intended to control fans, which can
> > not be throttled but just switched on or off.
> > Bang-bang cannot be set as default governor as it is intended for
> > special devices only. For those special devices the driver needs to
> > explicitely request it.
> >
> > Cc: Andrew Morton <[email protected]>
> > Cc: Zhang Rui <[email protected]>
>
> Anything that prevents you from giving your acked-by?
>
NO.

I'll queue them for 3.18.

thanks,
rui

2014-10-21 10:38:31

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v5 3/6] thermal: Added Bang-bang thermal governor

Hi Rui,

Zhang Rui writes:

> On Sat, 2014-07-26 at 16:14 +0200, Peter Feuerer wrote:
>> Hi Rui,
>>
>> Peter Feuerer writes:
>>
>> > The bang-bang thermal governor uses a hysteresis to switch abruptly on
>> > or off a cooling device. It is intended to control fans, which can
>> > not be throttled but just switched on or off.
>> > Bang-bang cannot be set as default governor as it is intended for
>> > special devices only. For those special devices the driver needs to
>> > explicitely request it.
>> >
>> > Cc: Andrew Morton <[email protected]>
>> > Cc: Zhang Rui <[email protected]>
>>
>> Anything that prevents you from giving your acked-by?
>>
> NO.
>
> I'll queue them for 3.18.

Are all 6 patches in for 3.18 as you promissed?

kind regards,
--peter;

2014-10-28 19:33:46

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v5 3/6] thermal: Added Bang-bang thermal governor

Hi Rui,

I wonder whether you've had time to apply my set of patches already? Would
you please be so kind to just send me a short reply?

thanks and kind regards,
--peter;


Peter Feuerer writes:

> Hi Rui,
>
> Zhang Rui writes:
>
>> On Sat, 2014-07-26 at 16:14 +0200, Peter Feuerer wrote:
>>> Hi Rui,
>>>
>>> Peter Feuerer writes:
>>>
>>> > The bang-bang thermal governor uses a hysteresis to switch abruptly on
>>> > or off a cooling device. It is intended to control fans, which can
>>> > not be throttled but just switched on or off.
>>> > Bang-bang cannot be set as default governor as it is intended for
>>> > special devices only. For those special devices the driver needs to
>>> > explicitely request it.
>>> >
>>> > Cc: Andrew Morton <[email protected]>
>>> > Cc: Zhang Rui <[email protected]>
>>>
>>> Anything that prevents you from giving your acked-by?
>>>
>> NO.
>>
>> I'll queue them for 3.18.
>
> Are all 6 patches in for 3.18 as you promissed?
>
> kind regards,
> --peter;

2014-10-29 09:44:16

by Javi Merino

[permalink] [raw]
Subject: Re: [PATCH v5 3/6] thermal: Added Bang-bang thermal governor

On Tue, Oct 28, 2014 at 07:33:39PM +0000, Peter Feuerer wrote:
> Hi Rui,
>
> I wonder whether you've had time to apply my set of patches already? Would
> you please be so kind to just send me a short reply?

The bang-bang governor was merged and is part of v3.18-rc2:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8264fce6de03f3915e2301f52f181a982718a8cb

Cheers,
Javi

> Peter Feuerer writes:
>
> > Hi Rui,
> >
> > Zhang Rui writes:
> >
> >> On Sat, 2014-07-26 at 16:14 +0200, Peter Feuerer wrote:
> >>> Hi Rui,
> >>>
> >>> Peter Feuerer writes:
> >>>
> >>> > The bang-bang thermal governor uses a hysteresis to switch abruptly on
> >>> > or off a cooling device. It is intended to control fans, which can
> >>> > not be throttled but just switched on or off.
> >>> > Bang-bang cannot be set as default governor as it is intended for
> >>> > special devices only. For those special devices the driver needs to
> >>> > explicitely request it.
> >>> >
> >>> > Cc: Andrew Morton <[email protected]>
> >>> > Cc: Zhang Rui <[email protected]>
> >>>
> >>> Anything that prevents you from giving your acked-by?
> >>>
> >> NO.
> >>
> >> I'll queue them for 3.18.
> >
> > Are all 6 patches in for 3.18 as you promissed?
> >
> > kind regards,
> > --peter;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

2014-10-29 10:21:21

by Peter Kästle

[permalink] [raw]
Subject: Re: [PATCH v5 3/6] thermal: Added Bang-bang thermal governor

Hi Javi,

Javi Merino writes:

> On Tue, Oct 28, 2014 at 07:33:39PM +0000, Peter Feuerer wrote:
>> Hi Rui,
>>
>> I wonder whether you've had time to apply my set of patches already? Would
>> you please be so kind to just send me a short reply?
>
> The bang-bang governor was merged and is part of v3.18-rc2:
>
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8264fce6de03f3915e2301f52f181a982718a8cb

Thanks for your mail.

Seems like the other 5 patches of the series were not applied. So I
need to take care again, or?

kind regards,
--peter;


>
> Cheers,
> Javi
>
>> Peter Feuerer writes:
>>
>> > Hi Rui,
>> >
>> > Zhang Rui writes:
>> >
>> >> On Sat, 2014-07-26 at 16:14 +0200, Peter Feuerer wrote:
>> >>> Hi Rui,
>> >>>
>> >>> Peter Feuerer writes:
>> >>>
>> >>> > The bang-bang thermal governor uses a hysteresis to switch abruptly on
>> >>> > or off a cooling device. It is intended to control fans, which can
>> >>> > not be throttled but just switched on or off.
>> >>> > Bang-bang cannot be set as default governor as it is intended for
>> >>> > special devices only. For those special devices the driver needs to
>> >>> > explicitely request it.
>> >>> >
>> >>> > Cc: Andrew Morton <[email protected]>
>> >>> > Cc: Zhang Rui <[email protected]>
>> >>>
>> >>> Anything that prevents you from giving your acked-by?
>> >>>
>> >> NO.
>> >>
>> >> I'll queue them for 3.18.
>> >
>> > Are all 6 patches in for 3.18 as you promissed?
>> >
>> > kind regards,
>> > --peter;
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>>
>

2014-11-28 14:21:17

by Peter Kästle

[permalink] [raw]
Subject: [RESEND PATCH v5 5/5] acerhdf: minor clean up

* renamed bios_settings_t to bios_settings, as it is no typedef
* replaced "unsigned char" by u8 in bios_settings struct for better
readability.

Cc: [email protected]
Cc: Darren Hart <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 91b16c8..c07623c 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -131,18 +131,18 @@ static const struct manualcmd mcmd = {
};

/* BIOS settings */
-struct bios_settings_t {
+struct bios_settings {
const char *vendor;
const char *product;
const char *version;
- unsigned char fanreg;
- unsigned char tempreg;
+ u8 fanreg;
+ u8 tempreg;
struct fancmd cmd;
int mcmd_enable;
};

/* Register addresses and values for different BIOS versions */
-static const struct bios_settings_t bios_tbl[] = {
+static const struct bios_settings bios_tbl[] = {
/* AOA110 */
{"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00}, 0},
{"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
@@ -256,7 +256,7 @@ static const struct bios_settings_t bios_tbl[] = {
{"", "", "", 0, 0, {0, 0}, 0}
};

-static const struct bios_settings_t *bios_cfg __read_mostly;
+static const struct bios_settings *bios_cfg __read_mostly;

/*
* this struct is used to instruct thermal layer to use bang_bang instead of
@@ -619,7 +619,7 @@ static int str_starts_with(const char *str, const char *start)
static int acerhdf_check_hardware(void)
{
char const *vendor, *version, *product;
- const struct bios_settings_t *bt = NULL;
+ const struct bios_settings *bt = NULL;

/* get BIOS data */
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
--
2.1.3

2014-11-28 14:21:21

by Peter Kästle

[permalink] [raw]
Subject: [RESEND PATCH v5 2/5] acerhdf: Adding support for new models

added following new models:
* Aspire 5755G
* AO521
* AO751h
* Aspire One 753
* Extensa 5420
* Aspire 5315
* Aspire 5739G
* TravelMate TM8573T

Cc: [email protected]
Cc: Darren Hart <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 2c58f10..f30767f 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.29"
+#define DRV_VER "0.5.30"

/*
* According to the Atom N270 datasheet,
@@ -199,17 +199,33 @@ static const struct bios_settings_t bios_tbl[] = {
{"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
+ /* Acer 5755G */
+ {"Acer", "Aspire 5755G", "V1.20", 0xab, 0xb4, {0x00, 0x08}, 0},
+ {"Acer", "Aspire 5755G", "V1.21", 0xab, 0xb3, {0x00, 0x08}, 0},
+ /* Acer 521 */
+ {"Acer", "AO521", "V1.11", 0x55, 0x58, {0x1f, 0x00}, 0},
/* Acer 531 */
{"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, 0},
{"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, 0},
{"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 751 */
+ {"Acer", "AO751h", "V0.3206", 0x55, 0x58, {0x21, 0x00}, 0},
{"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, 0},
+ /* Acer 753 */
+ {"Acer", "Aspire One 753", "V1.24", 0x93, 0xac, {0x14, 0x04}, 1},
/* Acer 1825 */
{"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
{"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
+ /* Acer Extensa 5420 */
+ {"Acer", "Extensa 5420", "V1.17", 0x93, 0xac, {0x14, 0x04}, 1},
+ /* Acer Aspire 5315 */
+ {"Acer", "Aspire 5315", "V1.19", 0x93, 0xac, {0x14, 0x04}, 1},
+ /* Acer Aspire 5739 */
+ {"Acer", "Aspire 5739G", "V1.3311", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer TravelMate 7730 */
{"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, 0},
+ /* Acer TravelMate TM8573T */
+ {"Acer", "TM8573T", "V1.13", 0x93, 0xa8, {0x14, 0x04}, 1},
/* Gateway */
{"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, 0},
{"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, 0},
@@ -741,9 +757,15 @@ MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO751h*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1410*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1810*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5755G:");
MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1825PTZ:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAO521*:");
MODULE_ALIAS("dmi:*:*Acer*:pnAO531*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5739G:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*One*753:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*5315:");
MODULE_ALIAS("dmi:*:*Acer*:TravelMate*7730G:");
+MODULE_ALIAS("dmi:*:*Acer*:TM8573T:");
MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:");
MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnAOA*:");
@@ -752,6 +774,7 @@ MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMU*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnENBFT*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMA*:");
MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTVR46*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnExtensa 5420*:");

module_init(acerhdf_init);
module_exit(acerhdf_exit);
--
2.1.3

2014-11-28 14:21:16

by Peter Kästle

[permalink] [raw]
Subject: [RESEND PATCH v5 4/5] acerhdf: added critical trip point

added critical trip point which represents the temperature limit.
Added return -EINVAL in case wrong trip point is provided.

Cc: [email protected]
Cc: Darren Hart <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Javi Merino <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 7fe7dbf..91b16c8 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -443,6 +443,10 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*type = THERMAL_TRIP_ACTIVE;
+ else if (trip == 1)
+ *type = THERMAL_TRIP_CRITICAL;
+ else
+ return -EINVAL;

return 0;
}
@@ -463,6 +467,10 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
{
if (trip == 0)
*temp = fanon;
+ else if (trip == 1)
+ *temp = ACERHDF_TEMP_CRIT;
+ else
+ return -EINVAL;

return 0;
}
@@ -713,7 +721,7 @@ static int acerhdf_register_thermal(void)
if (IS_ERR(cl_dev))
return -EINVAL;

- thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
+ thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL,
&acerhdf_dev_ops,
&acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
--
2.1.3

2014-11-28 14:21:47

by Peter Kästle

[permalink] [raw]
Subject: [RESEND PATCH v5 0/5] acerhdf: adding new models, appropriate governor and minor clean up

Hi Darren,

please apply this series of patches.

It is intended to:

* Introduce "manual mode" support (Patch 1 & 2), which is needed to control
the fan of a few new models.

* Add an appropriate thermal governor (Patch 3). Manipulating and
fiddling around with the step-wise governor has been a very fragile thing
in the past and as it broke again, I used the opportunity to add a two
point thermal governor which implements the actual fan handling required by
acerhdf and puts from my point of view things straight.

* Do some minor clean up like:
- adding second trip point for critical temperature (Patch 4)
- removing _t suffix from struct which isn't typedef and replace unsigned
char by u8 (Patch 5)

Thanks and kind regards,
peter

Peter Feuerer (5):
acerhdf: Adding support for "manual mode"
acerhdf: Adding support for new models
acerhdf: Use bang-bang thermal governor
acerhdf: added critical trip point
acerhdf: minor clean up

drivers/platform/x86/Kconfig | 3 +-
drivers/platform/x86/acerhdf.c | 265 ++++++++++++++++++++++++++---------------
2 files changed, 172 insertions(+), 96 deletions(-)

--
2.1.3

2014-11-28 14:22:08

by Peter Kästle

[permalink] [raw]
Subject: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

acerhdf has been doing an on-off fan control using hysteresis by
post-manipulating the outcome of thermal subsystem trip point handling.
This patch enables acerhdf to use the bang-bang governor, which is
intended for on-off controlled fans.

Cc: [email protected]
Cc: Darren Hart <[email protected]>
Cc: Andrew Morton <[email protected]>
CC: Zhang Rui <[email protected]>
Cc: Andreas Mohr <[email protected]>
Cc: Javi Merino <[email protected]>
Acked-and-tested-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/Kconfig | 3 ++-
drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index a2eabe6..c173266 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -38,7 +38,8 @@ config ACER_WMI

config ACERHDF
tristate "Acer Aspire One temperature and fan driver"
- depends on THERMAL && ACPI
+ select THERMAL_GOV_BANG_BANG
+ depends on ACPI
---help---
This is a driver for Acer Aspire One netbooks. It allows to access
the temperature sensor and to control the fan.
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f30767f..7fe7dbf 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.30"
+#define DRV_VER "0.7.0"

/*
* According to the Atom N270 datasheet,
@@ -258,6 +258,14 @@ static const struct bios_settings_t bios_tbl[] = {

static const struct bios_settings_t *bios_cfg __read_mostly;

+/*
+ * this struct is used to instruct thermal layer to use bang_bang instead of
+ * default governor for acerhdf
+ */
+static struct thermal_zone_params acerhdf_zone_params = {
+ .governor_name = "bang_bang",
+};
+
static int acerhdf_get_temp(int *temp)
{
u8 read_temp;
@@ -439,6 +447,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
return 0;
}

+static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
+ unsigned long *temp)
+{
+ if (trip != 0)
+ return -EINVAL;
+
+ *temp = fanon - fanoff;
+
+ return 0;
+}
+
static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
unsigned long *temp)
{
@@ -463,6 +482,7 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
.get_mode = acerhdf_get_mode,
.set_mode = acerhdf_set_mode,
.get_trip_type = acerhdf_get_trip_type,
+ .get_trip_hyst = acerhdf_get_trip_hyst,
.get_trip_temp = acerhdf_get_trip_temp,
.get_crit_temp = acerhdf_get_crit_temp,
};
@@ -515,9 +535,7 @@ static int acerhdf_set_cur_state(struct thermal_cooling_device *cdev,
}

if (state == 0) {
- /* turn fan off only if below fanoff temperature */
- if ((cur_state == ACERHDF_FAN_AUTO) &&
- (cur_temp < fanoff))
+ if (cur_state == ACERHDF_FAN_AUTO)
acerhdf_change_fanstate(ACERHDF_FAN_OFF);
} else {
if (cur_state == ACERHDF_FAN_OFF)
@@ -696,11 +714,19 @@ static int acerhdf_register_thermal(void)
return -EINVAL;

thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
- &acerhdf_dev_ops, NULL, 0,
+ &acerhdf_dev_ops,
+ &acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0);
if (IS_ERR(thz_dev))
return -EINVAL;

+ if (strcmp(thz_dev->governor->name,
+ acerhdf_zone_params.governor_name)) {
+ pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n",
+ acerhdf_zone_params.governor_name);
+ return -EINVAL;
+ }
+
return 0;
}

--
2.1.3

2014-11-28 14:27:35

by Peter Kästle

[permalink] [raw]
Subject: [RESEND PATCH v5 1/5] acerhdf: Adding support for "manual mode"

Some Acer models require an additional command to turn off the fan after
bios mode has been enabled. Adding new section in bios table to allow
support for those models, by writing an extra "manual mode" register.

Cc: [email protected]
Cc: Darren Hart <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andreas Mohr <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Signed-off-by: Peter Feuerer <[email protected]>
---
drivers/platform/x86/acerhdf.c | 186 ++++++++++++++++++++++-------------------
1 file changed, 102 insertions(+), 84 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f94467c..2c58f10 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -50,7 +50,7 @@
*/
#undef START_IN_KERNEL_MODE

-#define DRV_VER "0.5.26"
+#define DRV_VER "0.5.29"

/*
* According to the Atom N270 datasheet,
@@ -119,6 +119,17 @@ struct fancmd {
u8 cmd_auto;
};

+struct manualcmd {
+ u8 mreg;
+ u8 moff;
+};
+
+/* default register and command to disable fan in manual mode */
+static const struct manualcmd mcmd = {
+ .mreg = 0x94,
+ .moff = 0xff,
+};
+
/* BIOS settings */
struct bios_settings_t {
const char *vendor;
@@ -127,105 +138,106 @@ struct bios_settings_t {
unsigned char fanreg;
unsigned char tempreg;
struct fancmd cmd;
+ int mcmd_enable;
};

/* Register addresses and values for different BIOS versions */
static const struct bios_settings_t bios_tbl[] = {
/* AOA110 */
- {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00} },
- {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00} },
- {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00}, 0},
/* AOA150 */
- {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
- {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x1f, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00}, 0},
/* LT1005u */
- {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 1410 */
- {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer 1810xx */
- {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3310", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1810T", "v1.3314", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer 531 */
- {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00} },
- {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
+ {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00}, 0},
/* Acer 751 */
- {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00} },
+ {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00}, 0},
/* Acer 1825 */
- {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
+ {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Acer TravelMate 7730 */
- {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00} },
+ {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00}, 0},
/* Gateway */
- {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
- {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} },
- {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
+ {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Gateway", "LT31", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
/* Packard Bell */
- {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
- {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
- {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
+ {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00}, 0},
+ {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00}, 0},
+ {"Packard Bell", "ENBFT", "V1.3118", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "ENBFT", "V1.3127", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3108", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3113", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3115", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3117", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v0.3119", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMU", "v1.3204", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3201", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3302", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
+ {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0},
/* pewpew-terminator */
- {"", "", "", 0, 0, {0, 0} }
+ {"", "", "", 0, 0, {0, 0}, 0}
};

static const struct bios_settings_t *bios_cfg __read_mostly;
@@ -275,6 +287,12 @@ static void acerhdf_change_fanstate(int state)
fanstate = state;

ec_write(bios_cfg->fanreg, cmd);
+
+ if (bios_cfg->mcmd_enable && state == ACERHDF_FAN_OFF) {
+ if (verbose)
+ pr_notice("turning off fan manually\n");
+ ec_write(mcmd.mreg, mcmd.moff);
+ }
}

static void acerhdf_check_param(struct thermal_zone_device *thermal)
--
2.1.3

2014-12-03 21:46:18

by Peter Kästle

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 0/5] acerhdf: adding new models, appropriate governor and minor clean up

Hi Darren / platform-driver-x86 list,

Peter Feuerer writes:
> please apply this series of patches.

did you find time for my patchseries already?
Is there any problem with it?

--
kind regards,
--peter;

2014-12-04 05:56:00

by Darren Hart

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:
> acerhdf has been doing an on-off fan control using hysteresis by
> post-manipulating the outcome of thermal subsystem trip point handling.
> This patch enables acerhdf to use the bang-bang governor, which is
> intended for on-off controlled fans.
>
> Cc: [email protected]
> Cc: Darren Hart <[email protected]>
> Cc: Andrew Morton <[email protected]>
> CC: Zhang Rui <[email protected]>
> Cc: Andreas Mohr <[email protected]>
> Cc: Javi Merino <[email protected]>
> Acked-and-tested-by: Borislav Petkov <[email protected]>
> Signed-off-by: Peter Feuerer <[email protected]>
> ---
> drivers/platform/x86/Kconfig | 3 ++-
> drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
> 2 files changed, 33 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index a2eabe6..c173266 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -38,7 +38,8 @@ config ACER_WMI
>
> config ACERHDF
> tristate "Acer Aspire One temperature and fan driver"
> - depends on THERMAL && ACPI
> + select THERMAL_GOV_BANG_BANG

So we use select sparingly as it does implicit things.

I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
already depends on it (which it doesn't appear to). Any particular reason to add
select here instead of adding it as a depends.

Why did you drop THERMAL?

> + depends on ACPI
> ---help---
> This is a driver for Acer Aspire One netbooks. It allows to access
> the temperature sensor and to control the fan.
> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
> index f30767f..7fe7dbf 100644
> --- a/drivers/platform/x86/acerhdf.c
> +++ b/drivers/platform/x86/acerhdf.c
> @@ -50,7 +50,7 @@
> */
> #undef START_IN_KERNEL_MODE
>
> -#define DRV_VER "0.5.30"
> +#define DRV_VER "0.7.0"
>
> /*
> * According to the Atom N270 datasheet,
> @@ -258,6 +258,14 @@ static const struct bios_settings_t bios_tbl[] = {
>
> static const struct bios_settings_t *bios_cfg __read_mostly;
>
> +/*
> + * this struct is used to instruct thermal layer to use bang_bang instead of
> + * default governor for acerhdf

Please use sentence punctuation, particularly for block comments.

/*
* This struct...
* default ... for acerhdf.
*/

> + */
> +static struct thermal_zone_params acerhdf_zone_params = {
> + .governor_name = "bang_bang",
> +};
> +
> static int acerhdf_get_temp(int *temp)
> {
> u8 read_temp;
> @@ -439,6 +447,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
> return 0;
> }
>
> +static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
> + unsigned long *temp)
> +{
> + if (trip != 0)
> + return -EINVAL;
> +
> + *temp = fanon - fanoff;
> +
> + return 0;
> +}
> +
> static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
> unsigned long *temp)
> {
> @@ -463,6 +482,7 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
> .get_mode = acerhdf_get_mode,
> .set_mode = acerhdf_set_mode,
> .get_trip_type = acerhdf_get_trip_type,
> + .get_trip_hyst = acerhdf_get_trip_hyst,
> .get_trip_temp = acerhdf_get_trip_temp,
> .get_crit_temp = acerhdf_get_crit_temp,
> };
> @@ -515,9 +535,7 @@ static int acerhdf_set_cur_state(struct thermal_cooling_device *cdev,
> }
>
> if (state == 0) {
> - /* turn fan off only if below fanoff temperature */
> - if ((cur_state == ACERHDF_FAN_AUTO) &&
> - (cur_temp < fanoff))
> + if (cur_state == ACERHDF_FAN_AUTO)
> acerhdf_change_fanstate(ACERHDF_FAN_OFF);
> } else {
> if (cur_state == ACERHDF_FAN_OFF)
> @@ -696,11 +714,19 @@ static int acerhdf_register_thermal(void)
> return -EINVAL;
>
> thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
> - &acerhdf_dev_ops, NULL, 0,
> + &acerhdf_dev_ops,
> + &acerhdf_zone_params, 0,
> (kernelmode) ? interval*1000 : 0);
> if (IS_ERR(thz_dev))
> return -EINVAL;
>
> + if (strcmp(thz_dev->governor->name,
> + acerhdf_zone_params.governor_name)) {
> + pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n",
> + acerhdf_zone_params.governor_name);

We've ensured it has to be compiled in, so that really can't be it. Right?

> + return -EINVAL;
> + }
> +
> return 0;
> }
>
> --
> 2.1.3
>
>

--
Darren Hart
Intel Open Source Technology Center

2014-12-04 06:00:06

by Darren Hart

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 4/5] acerhdf: added critical trip point

On Fri, Nov 28, 2014 at 03:20:51PM +0100, Peter Feuerer wrote:
> added critical trip point which represents the temperature limit.

Nitpic, Add ^

> Added return -EINVAL in case wrong trip point is provided.

Add (we are going to add it with this patch, it wasn't added previously). It's a
nitpic. But this is more consistent with typical commit message language.

I might normally just fix that upon commit, but since I had a few questions on
the last one, if that results in a V2, please correct this as well.

>
> Cc: [email protected]
> Cc: Darren Hart <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Andreas Mohr <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: Javi Merino <[email protected]>
> Signed-off-by: Peter Feuerer <[email protected]>
> ---
> drivers/platform/x86/acerhdf.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
> index 7fe7dbf..91b16c8 100644
> --- a/drivers/platform/x86/acerhdf.c
> +++ b/drivers/platform/x86/acerhdf.c
> @@ -443,6 +443,10 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
> {
> if (trip == 0)
> *type = THERMAL_TRIP_ACTIVE;
> + else if (trip == 1)
> + *type = THERMAL_TRIP_CRITICAL;
> + else
> + return -EINVAL;
>
> return 0;
> }
> @@ -463,6 +467,10 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
> {
> if (trip == 0)
> *temp = fanon;
> + else if (trip == 1)
> + *temp = ACERHDF_TEMP_CRIT;
> + else
> + return -EINVAL;
>
> return 0;
> }
> @@ -713,7 +721,7 @@ static int acerhdf_register_thermal(void)
> if (IS_ERR(cl_dev))
> return -EINVAL;
>
> - thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
> + thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL,
> &acerhdf_dev_ops,
> &acerhdf_zone_params, 0,
> (kernelmode) ? interval*1000 : 0);
> --
> 2.1.3
>
>

--
Darren Hart
Intel Open Source Technology Center

2014-12-04 07:11:44

by Peter Kästle

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

Hi Darren,

thank you very much for your reply.


Darren Hart writes:

> On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:
>> acerhdf has been doing an on-off fan control using hysteresis by
>> post-manipulating the outcome of thermal subsystem trip point handling.
>> This patch enables acerhdf to use the bang-bang governor, which is
>> intended for on-off controlled fans.
>>
>> Cc: [email protected]
>> Cc: Darren Hart <[email protected]>
>> Cc: Andrew Morton <[email protected]>
>> CC: Zhang Rui <[email protected]>
>> Cc: Andreas Mohr <[email protected]>
>> Cc: Javi Merino <[email protected]>
>> Acked-and-tested-by: Borislav Petkov <[email protected]>
>> Signed-off-by: Peter Feuerer <[email protected]>
>> ---
>> drivers/platform/x86/Kconfig | 3 ++-
>> drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
>> 2 files changed, 33 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
>> index a2eabe6..c173266 100644
>> --- a/drivers/platform/x86/Kconfig
>> +++ b/drivers/platform/x86/Kconfig
>> @@ -38,7 +38,8 @@ config ACER_WMI
>>
>> config ACERHDF
>> tristate "Acer Aspire One temperature and fan driver"
>> - depends on THERMAL && ACPI
>> + select THERMAL_GOV_BANG_BANG
>
> So we use select sparingly as it does implicit things.
>
> I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
> already depends on it (which it doesn't appear to). Any particular reason to add
> select here instead of adding it as a depends.
>
> Why did you drop THERMAL?

I had it like this in my first version of patches:
+ depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG

But after some discussion with lkml community we ended up with the select line and dropped THERMAL dependency, as it is implied by THEMAL_GOV_BANG_BANG. I'm not so experienced with Kconfig, so I must rely on the statements of the community in this case.


>> + depends on ACPI
>> ---help---
>> This is a driver for Acer Aspire One netbooks. It allows to access
>> the temperature sensor and to control the fan.
>> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
>> index f30767f..7fe7dbf 100644
>> --- a/drivers/platform/x86/acerhdf.c
>> +++ b/drivers/platform/x86/acerhdf.c
>> @@ -50,7 +50,7 @@
>> */
>> #undef START_IN_KERNEL_MODE
>>
>> -#define DRV_VER "0.5.30"
>> +#define DRV_VER "0.7.0"
>>
>> /*
>> * According to the Atom N270 datasheet,
>> @@ -258,6 +258,14 @@ static const struct bios_settings_t bios_tbl[] = {
>>
>> static const struct bios_settings_t *bios_cfg __read_mostly;
>>
>> +/*
>> + * this struct is used to instruct thermal layer to use bang_bang instead of
>> + * default governor for acerhdf
>
> Please use sentence punctuation, particularly for block comments.

ok.



> /*
> * This struct...
> * default ... for acerhdf.
> */
>
>> + */
>> +static struct thermal_zone_params acerhdf_zone_params = {
>> + .governor_name = "bang_bang",
>> +};
>> +
>> static int acerhdf_get_temp(int *temp)
>> {
>> u8 read_temp;
>> @@ -439,6 +447,17 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
>> return 0;
>> }
>>
>> +static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
>> + unsigned long *temp)
>> +{
>> + if (trip != 0)
>> + return -EINVAL;
>> +
>> + *temp = fanon - fanoff;
>> +
>> + return 0;
>> +}
>> +
>> static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
>> unsigned long *temp)
>> {
>> @@ -463,6 +482,7 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
>> .get_mode = acerhdf_get_mode,
>> .set_mode = acerhdf_set_mode,
>> .get_trip_type = acerhdf_get_trip_type,
>> + .get_trip_hyst = acerhdf_get_trip_hyst,
>> .get_trip_temp = acerhdf_get_trip_temp,
>> .get_crit_temp = acerhdf_get_crit_temp,
>> };
>> @@ -515,9 +535,7 @@ static int acerhdf_set_cur_state(struct thermal_cooling_device *cdev,
>> }
>>
>> if (state == 0) {
>> - /* turn fan off only if below fanoff temperature */
>> - if ((cur_state == ACERHDF_FAN_AUTO) &&
>> - (cur_temp < fanoff))
>> + if (cur_state == ACERHDF_FAN_AUTO)
>> acerhdf_change_fanstate(ACERHDF_FAN_OFF);
>> } else {
>> if (cur_state == ACERHDF_FAN_OFF)
>> @@ -696,11 +714,19 @@ static int acerhdf_register_thermal(void)
>> return -EINVAL;
>>
>> thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL,
>> - &acerhdf_dev_ops, NULL, 0,
>> + &acerhdf_dev_ops,
>> + &acerhdf_zone_params, 0,
>> (kernelmode) ? interval*1000 : 0);
>> if (IS_ERR(thz_dev))
>> return -EINVAL;
>>
>> + if (strcmp(thz_dev->governor->name,
>> + acerhdf_zone_params.governor_name)) {
>> + pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n",
>> + acerhdf_zone_params.governor_name);
>
> We've ensured it has to be compiled in, so that really can't be it. Right?

Yes, you are right, but if it is no real blocker for you, I'd like to keep this code in as I'm providing the acerhdf.c code in a separate package for debugging / testing too and people could use the code without the Kconfig.

--
kind regards,
--peter;

2014-12-04 07:22:26

by Peter Kästle

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

Hi again,

Peter Feuerer writes:

> Hi Darren,
>
> thank you very much for your reply.
>
>
> Darren Hart writes:
>
>> On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:
>>> acerhdf has been doing an on-off fan control using hysteresis by
>>> post-manipulating the outcome of thermal subsystem trip point handling.
>>> This patch enables acerhdf to use the bang-bang governor, which is
>>> intended for on-off controlled fans.
>>>
>>> Cc: [email protected]
>>> Cc: Darren Hart <[email protected]>
>>> Cc: Andrew Morton <[email protected]>
>>> CC: Zhang Rui <[email protected]>
>>> Cc: Andreas Mohr <[email protected]>
>>> Cc: Javi Merino <[email protected]>
>>> Acked-and-tested-by: Borislav Petkov <[email protected]>
>>> Signed-off-by: Peter Feuerer <[email protected]>
>>> ---
>>> drivers/platform/x86/Kconfig | 3 ++-
>>> drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
>>> 2 files changed, 33 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
>>> index a2eabe6..c173266 100644
>>> --- a/drivers/platform/x86/Kconfig
>>> +++ b/drivers/platform/x86/Kconfig
>>> @@ -38,7 +38,8 @@ config ACER_WMI
>>>
>>> config ACERHDF
>>> tristate "Acer Aspire One temperature and fan driver"
>>> - depends on THERMAL && ACPI
>>> + select THERMAL_GOV_BANG_BANG
>>
>> So we use select sparingly as it does implicit things.
>>
>> I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
>> already depends on it (which it doesn't appear to). Any particular reason to add
>> select here instead of adding it as a depends.
>>
>> Why did you drop THERMAL?
>
> I had it like this in my first version of patches:
> + depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG
>
> But after some discussion with lkml community we ended up with the select
> line and dropped THERMAL dependency, as it is implied by
> THEMAL_GOV_BANG_BANG. I'm not so experienced with Kconfig, so I must rely
> on the statements of the community in this case.

Just found the link about this discussion I had with Rui and Boris:
http://linux-kernel.2935.n7.nabble.com/PATCH-0-4-acerhdf-thermal-adding-new-models-and-appropriate-governor-tp848572p908256.html

[...]

--
kind regards,
--peter;

2014-12-08 07:47:20

by Peter Kästle

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

Hi Darren,

I know you are busy and I don't want to stress you, but have you had time to
look to this? I'd be really happy to solve all issues in time and have
those patches finally applied.

kind regards,
--peter;


Peter Feuerer writes:

> Hi again,
>
> Peter Feuerer writes:
>
>> Hi Darren,
>>
>> thank you very much for your reply.
>>
>>
>> Darren Hart writes:
>>
>>> On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:
>>>> acerhdf has been doing an on-off fan control using hysteresis by
>>>> post-manipulating the outcome of thermal subsystem trip point handling.
>>>> This patch enables acerhdf to use the bang-bang governor, which is
>>>> intended for on-off controlled fans.
>>>>
>>>> Cc: [email protected]
>>>> Cc: Darren Hart <[email protected]>
>>>> Cc: Andrew Morton <[email protected]>
>>>> CC: Zhang Rui <[email protected]>
>>>> Cc: Andreas Mohr <[email protected]>
>>>> Cc: Javi Merino <[email protected]>
>>>> Acked-and-tested-by: Borislav Petkov <[email protected]>
>>>> Signed-off-by: Peter Feuerer <[email protected]>
>>>> ---
>>>> drivers/platform/x86/Kconfig | 3 ++-
>>>> drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
>>>> 2 files changed, 33 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
>>>> index a2eabe6..c173266 100644
>>>> --- a/drivers/platform/x86/Kconfig
>>>> +++ b/drivers/platform/x86/Kconfig
>>>> @@ -38,7 +38,8 @@ config ACER_WMI
>>>>
>>>> config ACERHDF
>>>> tristate "Acer Aspire One temperature and fan driver"
>>>> - depends on THERMAL && ACPI
>>>> + select THERMAL_GOV_BANG_BANG
>>>
>>> So we use select sparingly as it does implicit things.
>>>
>>> I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
>>> already depends on it (which it doesn't appear to). Any particular reason to add
>>> select here instead of adding it as a depends.
>>>
>>> Why did you drop THERMAL?
>>
>> I had it like this in my first version of patches:
>> + depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG
>>
>> But after some discussion with lkml community we ended up with the select
>> line and dropped THERMAL dependency, as it is implied by
>> THEMAL_GOV_BANG_BANG. I'm not so experienced with Kconfig, so I must rely
>> on the statements of the community in this case.
>
> Just found the link about this discussion I had with Rui and Boris:
> http://linux-kernel.2935.n7.nabble.com/PATCH-0-4-acerhdf-thermal-adding-new-models-and-appropriate-governor-tp848572p908256.html
>
> [...]
>
> --
> kind regards,
> --peter;

2014-12-09 22:07:18

by Darren Hart

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

On Mon, Dec 08, 2014 at 08:45:58AM +0100, Peter Feuerer wrote:
> Hi Darren,
>
> I know you are busy and I don't want to stress you, but have you had time to
> look to this? I'd be really happy to solve all issues in time and have
> those patches finally applied.

Not yet. I've been traveling to Mexico and wrapping up the current for-next
patches. FYI, also dealing with a very sick kid these last couple of days, so
I've been rather tied up. I hope to get to these in the next few days.

You've provided the link to the discussion which is what I needed, thanks.

Thanks,

Darren

>
> kind regards,
> --peter;
>
>
> Peter Feuerer writes:
>
> >Hi again,
> >
> >Peter Feuerer writes:
> >
> >>Hi Darren,
> >>
> >>thank you very much for your reply.
> >>
> >>
> >>Darren Hart writes:
> >>
> >>>On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:
> >>>>acerhdf has been doing an on-off fan control using hysteresis by
> >>>>post-manipulating the outcome of thermal subsystem trip point handling.
> >>>>This patch enables acerhdf to use the bang-bang governor, which is
> >>>>intended for on-off controlled fans.
> >>>>
> >>>>Cc: [email protected]
> >>>>Cc: Darren Hart <[email protected]>
> >>>>Cc: Andrew Morton <[email protected]>
> >>>>CC: Zhang Rui <[email protected]>
> >>>>Cc: Andreas Mohr <[email protected]>
> >>>>Cc: Javi Merino <[email protected]>
> >>>>Acked-and-tested-by: Borislav Petkov <[email protected]>
> >>>>Signed-off-by: Peter Feuerer <[email protected]>
> >>>>---
> >>>> drivers/platform/x86/Kconfig | 3 ++-
> >>>> drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
> >>>> 2 files changed, 33 insertions(+), 6 deletions(-)
> >>>>
> >>>>diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> >>>>index a2eabe6..c173266 100644
> >>>>--- a/drivers/platform/x86/Kconfig
> >>>>+++ b/drivers/platform/x86/Kconfig
> >>>>@@ -38,7 +38,8 @@ config ACER_WMI
> >>>> config ACERHDF
> >>>> tristate "Acer Aspire One temperature and fan driver"
> >>>>- depends on THERMAL && ACPI
> >>>>+ select THERMAL_GOV_BANG_BANG
> >>>
> >>>So we use select sparingly as it does implicit things.
> >>>
> >>>I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
> >>>already depends on it (which it doesn't appear to). Any particular reason to add
> >>>select here instead of adding it as a depends.
> >>>
> >>>Why did you drop THERMAL?
> >>
> >>I had it like this in my first version of patches:
> >>+ depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG
> >>
> >>But after some discussion with lkml community we ended up with the
> >>select line and dropped THERMAL dependency, as it is implied by
> >>THEMAL_GOV_BANG_BANG. I'm not so experienced with Kconfig, so I must
> >>rely on the statements of the community in this case.
> >
> >Just found the link about this discussion I had with Rui and Boris:
> >http://linux-kernel.2935.n7.nabble.com/PATCH-0-4-acerhdf-thermal-adding-new-models-and-appropriate-governor-tp848572p908256.html
> >
> >[...]
> >
> >--
> >kind regards,
> >--peter;
>

--
Darren Hart
Intel Open Source Technology Center

2014-12-09 22:29:46

by Darren Hart

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 3/5] acerhdf: Use bang-bang thermal governor

On Thu, Dec 04, 2014 at 08:21:06AM +0100, Peter Feuerer wrote:
> Hi again,
>
> Peter Feuerer writes:
>
> >Hi Darren,
> >
> >thank you very much for your reply.
> >
> >
> >Darren Hart writes:
> >
> >>On Fri, Nov 28, 2014 at 03:20:50PM +0100, Peter Feuerer wrote:
> >>>acerhdf has been doing an on-off fan control using hysteresis by
> >>>post-manipulating the outcome of thermal subsystem trip point handling.
> >>>This patch enables acerhdf to use the bang-bang governor, which is
> >>>intended for on-off controlled fans.
> >>>
> >>>Cc: [email protected]
> >>>Cc: Darren Hart <[email protected]>
> >>>Cc: Andrew Morton <[email protected]>
> >>>CC: Zhang Rui <[email protected]>
> >>>Cc: Andreas Mohr <[email protected]>
> >>>Cc: Javi Merino <[email protected]>
> >>>Acked-and-tested-by: Borislav Petkov <[email protected]>
> >>>Signed-off-by: Peter Feuerer <[email protected]>
> >>>---
> >>> drivers/platform/x86/Kconfig | 3 ++-
> >>> drivers/platform/x86/acerhdf.c | 36 +++++++++++++++++++++++++++++++-----
> >>> 2 files changed, 33 insertions(+), 6 deletions(-)
> >>>
> >>>diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> >>>index a2eabe6..c173266 100644
> >>>--- a/drivers/platform/x86/Kconfig
> >>>+++ b/drivers/platform/x86/Kconfig
> >>>@@ -38,7 +38,8 @@ config ACER_WMI
> >>> config ACERHDF
> >>> tristate "Acer Aspire One temperature and fan driver"
> >>>- depends on THERMAL && ACPI
> >>>+ select THERMAL_GOV_BANG_BANG
> >>
> >>So we use select sparingly as it does implicit things.
> >>
> >>I checked the THERMAL_GOV_BANG_BANG Kconfig entry, and the help says acerhdf
> >>already depends on it (which it doesn't appear to). Any particular reason to add
> >>select here instead of adding it as a depends.
> >>
> >>Why did you drop THERMAL?
> >
> >I had it like this in my first version of patches:
> >+ depends on THERMAL && ACPI && THERMAL_GOV_BANG_BANG
> >
> >But after some discussion with lkml community we ended up with the select
> >line and dropped THERMAL dependency, as it is implied by
> >THEMAL_GOV_BANG_BANG. I'm not so experienced with Kconfig, so I must rely
> >on the statements of the community in this case.
>
> Just found the link about this discussion I had with Rui and Boris:
> http://linux-kernel.2935.n7.nabble.com/PATCH-0-4-acerhdf-thermal-adding-new-models-and-appropriate-governor-tp848572p908256.html
>

Rui,

I see you said you agree with the approach to "select THERMAL_GOV_BANG_BANG",
and I'm OK with that. But that doesn't ensure, as far as I can see, a
sufficient set of Kconfig dependencies for ACERHDF as THERMAL_GOV_BANG_BANG
doesn't in turn select THERMAL.

While it's unlikely to get ACERHDF available without THERMAL enabled, it does
look possible. Should this driver also select or depends on THERMAL?

Maybe:

depends on ACPI
depends on THERMAL
select THERMAL_GOV_BANG_BANG

?

> [...]
>
> --
> kind regards,
> --peter;
>

--
Darren Hart
Intel Open Source Technology Center

2014-12-11 04:28:04

by Darren Hart

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 0/5] acerhdf: adding new models, appropriate governor and minor clean up

On Fri, Nov 28, 2014 at 03:20:47PM +0100, Peter Feuerer wrote:
> Hi Darren,
>
> please apply this series of patches.

Applied to testing, and given the level of review and testing already received,
I will include in for-next for a late merge-window submission.

Thanks,

--
Darren Hart
Intel Open Source Technology Center

2014-12-11 04:59:30

by Darren Hart

[permalink] [raw]
Subject: Re: [RESEND PATCH v5 0/5] acerhdf: adding new models, appropriate governor and minor clean up

On Fri, Nov 28, 2014 at 03:20:47PM +0100, Peter Feuerer wrote:
> Hi Darren,
>
> please apply this series of patches.
>
> It is intended to:
>
> * Introduce "manual mode" support (Patch 1 & 2), which is needed to control
> the fan of a few new models.
>
> * Add an appropriate thermal governor (Patch 3). Manipulating and
> fiddling around with the step-wise governor has been a very fragile thing
> in the past and as it broke again, I used the opportunity to add a two
> point thermal governor which implements the actual fan handling required by
> acerhdf and puts from my point of view things straight.
>
> * Do some minor clean up like:
> - adding second trip point for critical temperature (Patch 4)
> - removing _t suffix from struct which isn't typedef and replace unsigned
> char by u8 (Patch 5)
>
> Thanks and kind regards,
> peter
>
> Peter Feuerer (5):
> acerhdf: Adding support for "manual mode"
> acerhdf: Adding support for new models
> acerhdf: Use bang-bang thermal governor
> acerhdf: added critical trip point
> acerhdf: minor clean up

Queued to for-next. Thanks!

--
Darren Hart
Intel Open Source Technology Center