mirror of https://gitee.com/openkylin/linux.git
Improve fan type detection for dell-smm to prevent kernel hang
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJXbZZfAAoJEMsfJm/On5mB26MQAKewiG5wtzVQFJcR/dINWMOS 5R+z765nOSLE/NMRb1AQkYIpCuiXGkk95f902uHDAMuwXw53mhoIflHWAfvUCmvG 8pqVeBua+lM1wLAMnynx/4dLO8F8Tzk4Dk1yWNM1ynFUYV5fpXjK9GG7OFT98PF4 uP8icECOtIehJKXs4X9hqfSaWScF/wAlzkGTpbf8DDibKQ2cRWq4dOVcsE4lc90f N78KMj1kevsiDieML9CW0uIkJfOaphSWhGSKKizgHSF1G7QLPIg9E+Sjp5hNH7kT LsLpc0f8qzowh4hzmy5sjXD6IsQb8o2cJZE3UEfXN6Tx3mJZDqtBTwrWsh5w/FWX mPStanqj43WqORjHM+AfOUW9z4X4u/H7EdoyW5KnqPpbfncDomMdz+YVpxKwfDAX IInYPDz/TLkBLr4rh7WYnVijSGXj5+BBVJjP+Lg60REmfGsV59flF7uxG6fqzUWj Q0BKz0OtOzDkK3r/xo/7YHGS8HBGtarYQdrbR/FMg0v5olFsvgNm16cPkHEoO71a /xecjP1OKxaUygO/f0wri1f2AWCktNlS/T1a8Dob2oiO8PKdI0hQlXKr9ObA+O4b Z+3yuoymKyCLzkvEoENuA7PGRikL8J1w/luLpUR4pN/2OWDJkR3AHL9D86s232Sw niK+c4sGDd7NpYwqBUUz =rsC8 -----END PGP SIGNATURE----- Merge tag 'hwmon-for-linus-v4.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon fix from Guenter Roeck: "Improve fan type detection for dell-smm to prevent kernel hang" * tag 'hwmon-for-linus-v4.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (dell-smm) Cache fan_type() calls and change fan detection
This commit is contained in:
commit
260eaba4ea
|
@ -238,7 +238,7 @@ static int i8k_get_fan_speed(int fan)
|
|||
/*
|
||||
* Read the fan type.
|
||||
*/
|
||||
static int i8k_get_fan_type(int fan)
|
||||
static int _i8k_get_fan_type(int fan)
|
||||
{
|
||||
struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, };
|
||||
|
||||
|
@ -249,6 +249,17 @@ static int i8k_get_fan_type(int fan)
|
|||
return i8k_smm(®s) ? : regs.eax & 0xff;
|
||||
}
|
||||
|
||||
static int i8k_get_fan_type(int fan)
|
||||
{
|
||||
/* I8K_SMM_GET_FAN_TYPE SMM call is expensive, so cache values */
|
||||
static int types[2] = { INT_MIN, INT_MIN };
|
||||
|
||||
if (types[fan] == INT_MIN)
|
||||
types[fan] = _i8k_get_fan_type(fan);
|
||||
|
||||
return types[fan];
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the fan nominal rpm for specific fan speed.
|
||||
*/
|
||||
|
@ -782,13 +793,17 @@ static int __init i8k_init_hwmon(void)
|
|||
if (err >= 0)
|
||||
i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4;
|
||||
|
||||
/* First fan attributes, if fan type is OK */
|
||||
err = i8k_get_fan_type(0);
|
||||
/* First fan attributes, if fan status or type is OK */
|
||||
err = i8k_get_fan_status(0);
|
||||
if (err < 0)
|
||||
err = i8k_get_fan_type(0);
|
||||
if (err >= 0)
|
||||
i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1;
|
||||
|
||||
/* Second fan attributes, if fan type is OK */
|
||||
err = i8k_get_fan_type(1);
|
||||
/* Second fan attributes, if fan status or type is OK */
|
||||
err = i8k_get_fan_status(1);
|
||||
if (err < 0)
|
||||
err = i8k_get_fan_type(1);
|
||||
if (err >= 0)
|
||||
i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2;
|
||||
|
||||
|
|
Loading…
Reference in New Issue