Bug 195751

Summary: Dell inspiron 7720 fan control is freeze system by 500ms
Product: Drivers Reporter: vova7890 (zvova7890)
Component: Hardware MonitoringAssignee: Pali Rohár (pali)
Status: RESOLVED CODE_FIX    
Severity: normal CC: andy.shevchenko, inbox-kernelorg, jdelvare, linux, oleksandr
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 4.11 Subsystem:
Regression: No Bisected commit-id:
Attachments: [PATCH 1/2] hwmon: (dell-smm) Enable broken functionality via "force" module param
[PATCH 2/2] hwmon: (dell-smm) Disable fan support for Dell Inspiron 7720
Replace DMI_EXACT_MATCH with DMI_MATCH in i8k_blacklist_fan_support_dmi_table
Replace DMI_EXACT_MATCH with DMI_MATCH in i8k_blacklist_fan_type_dmi_table
Add Dell Vostro 3360 to i8k_blacklist_fan_support_dmi_table
[PATCH] hwmon: (dell-smm) Disable fan support for Dell Vostro 3360
[PATCH] hwmon: (dell-smm) Disable fan support for Dell Vostro 3360
[PATCH] hwmon: (dell-smm) Disable fan support for Dell Vostro 3360
[PATCH] hwmon: (dell-smm) Disable fan support for Dell XPS13 9333

Description vova7890 2017-05-13 19:08:27 UTC
Every access to the fan RPM(read/write) is provide an a freezes by the around 500ms

Model:
DMI: Dell Inc.          Inspiron 7720/      , BIOS A17 05/19/2015

That I'm trying understand from where freezes hapend. This is read RPM value:
[15567.022496] dell_smm_hwmon: i8k_hwmon_show_fan
[15567.022499] dell_smm_hwmon: i8k_get_fan_speed 0
[15567.523122] dell_smm_hwmon: smm(0x02a3 0x0000) = 0x0a52  (took  488908 usecs)

And write fan speed:
[14494.740165] dell_smm_hwmon: smm(0x01a3 0x0200) = 0x0000  (took  489212 usecs)


Fan control is work just fine at all, but the lags with SMP lock with 500ms isn't good.

[root@dell-i7 ~]# sensors
coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +41.0°C  (high = +87.0°C, crit = +105.0°C)
Core 0:        +41.0°C  (high = +87.0°C, crit = +105.0°C)
Core 1:        +41.0°C  (high = +87.0°C, crit = +105.0°C)
Core 2:        +41.0°C  (high = +87.0°C, crit = +105.0°C)
Core 3:        +34.0°C  (high = +87.0°C, crit = +105.0°C)

acpitz-virtual-0
Adapter: Virtual device
temp1:        +39.0°C  (crit = +106.0°C)
temp2:        +39.0°C  (crit = +106.0°C)

dell_smm-virtual-0
Adapter: Virtual device
Processor Fan: 3247 RPM
CPU:            +42.0°C  
Ambient:        +32.0°C  
GPU:            +31.0°C  
Other:          +64.0°C 

Other values(such as temp) read isn't provied the lags, because the operation is took < 1000us
Comment 1 Pali Rohár 2017-05-18 21:54:24 UTC
This looks like as another problem in Dell BIOS/firmware. Freeze is caused by SMM call implemented by Dell BIOS/firmware which is not under control of kernel. And therefore kernel cannot fix that call.

If Dell does not fix it (which I doubt due to old machine) then the only way is to disable accessing processor fan on your machine based on DMI data.

Please provide DMI data from these files, including whitespaces and special characters...

/sys/class/dmi/id/sys_vendor
/sys/class/dmi/id/product_name
Comment 2 Guenter Roeck 2017-05-18 22:06:31 UTC
I have seen this problem myself on older Dell machines. So far I just accepted it as a fact of life, but I agree - if people complain, the "fix" is really to take the functionality away.

One option might be to take it away but add a module parameter to override the default. That might be useful anyway so people can disable fan speed reporting without having to recompile the kernel.
Comment 3 vova7890 2017-05-19 19:16:23 UTC
Yes, one way is blacklist that operation. Guenter Roeck says right, override is may useful for some people. 

Here is:
[root@dell-i7 ~]# cat /sys/class/dmi/id/product_name | xxd
00000000: 496e 7370 6972 6f6e 2037 3732 300a       Inspiron 7720.
[root@dell-i7 ~]# cat /sys/class/dmi/id/sys_vendor | xxd
00000000: 4465 6c6c 2049 6e63 2e20 2020 2020 2020  Dell Inc.       
00000010: 2020 0a
Comment 4 Pali Rohár 2017-05-20 07:20:59 UTC
Created attachment 256637 [details]
[PATCH 1/2] hwmon: (dell-smm) Enable broken functionality via "force" module param
Comment 5 Pali Rohár 2017-05-20 07:21:56 UTC
Created attachment 256639 [details]
[PATCH 2/2] hwmon: (dell-smm) Disable fan support for Dell Inspiron 7720
Comment 6 Pali Rohár 2017-05-20 07:22:15 UTC
Try these two patches.
Comment 7 Oleksandr Natalenko 2017-11-24 11:12:15 UTC
Created attachment 260809 [details]
Replace DMI_EXACT_MATCH with DMI_MATCH in i8k_blacklist_fan_support_dmi_table
Comment 8 Oleksandr Natalenko 2017-11-24 11:12:42 UTC
Created attachment 260811 [details]
Replace DMI_EXACT_MATCH with DMI_MATCH in i8k_blacklist_fan_type_dmi_table
Comment 9 Oleksandr Natalenko 2017-11-24 11:13:24 UTC
Created attachment 260813 [details]
Add Dell Vostro 3360 to i8k_blacklist_fan_support_dmi_table
Comment 10 Oleksandr Natalenko 2017-11-24 11:15:13 UTC
Confirming the same issue with Dell Vostro 3360.

Also, confirming that disabling fan support eliminates freezes. I had to replace DMI_EXACT_MATCH with DMI_MATCH to make quirks work for me, otherwise DMI is not matched.

Also, attaching a patch that adds Dell Vostro 3360 to i8k_blacklist_fan_support_dmi_table.
Comment 11 Pali Rohár 2017-11-24 11:17:55 UTC
On Friday 24 November 2017 11:15:13 bugzilla-daemon@bugzilla.kernel.org wrote:
> I had to replace DMI_EXACT_MATCH with DMI_MATCH to make quirks work
> for me, otherwise DMI is not matched.

Hi! Please use exact match, we do not want to match random machines with
substrings in blacklist.

If exact match did not worked, it means that you specified just
substring of DMI string.
Comment 12 Oleksandr Natalenko 2017-11-24 11:20:10 UTC
I believe, exact match didn't work because DMI vendor contains extra spaces:

[~]$ cat /sys/class/dmi/id/sys_vendor | xxd                         
00000000: 4465 6c6c 2049 6e63 2e20 2020 2020 2020  Dell Inc.       
00000010: 2020 0a                                    .

[~]$ i=`cat /sys/class/dmi/id/sys_vendor`; echo "'"$i"'"
'Dell Inc.         '
Comment 13 Pali Rohár 2017-11-24 11:23:46 UTC
On Friday 24 November 2017 11:20:10 bugzilla-daemon@bugzilla.kernel.org wrote:
> --- Comment #12 from Oleksandr Natalenko (oleksandr@natalenko.name) ---
> I believe, exact match didn't work because DMI vendor contains extra spaces:

That is not truth, it would work.

> [~]$ cat /sys/class/dmi/id/sys_vendor | xxd                         
> 00000000: 4465 6c6c 2049 6e63 2e20 2020 2020 2020  Dell Inc.       
> 00000010: 2020 0a                                    .
> 
> [~]$ i=`cat /sys/class/dmi/id/sys_vendor`; echo "'"$i"'"
> 'Dell Inc.         '

You just need to include whole string as is with all spaces and special
characters.
Comment 14 Oleksandr Natalenko 2017-11-24 12:07:56 UTC
Created attachment 260815 [details]
[PATCH] hwmon: (dell-smm) Disable fan support for Dell Vostro 3360

I had to specify vendor with all extra spaces to make DMI_EXACT_MATCH work.
Comment 15 Andy Shevchenko 2017-11-24 21:03:00 UTC
(In reply to Oleksandr Natalenko from comment #14)
> Created attachment 260815 [details]
> [PATCH] hwmon: (dell-smm) Disable fan support for Dell Vostro 3360

First of all, why not to use DMI_MATCH() instead?

Next, is about tags in the patch.

Tested-by: is implied by author of the patch (otherwise the question how it was tested at all?!).

Reported-by: makes not much sense if SoB (author) is the same person.
Comment 16 Oleksandr Natalenko 2017-11-24 21:16:11 UTC
(In reply to Andy Shevchenko from comment #15)
> First of all, why not to use DMI_MATCH() instead?

Erm, citing Pali:

 | Please use exact match, we do not want to match
 | random machines with substrings in blacklist.

This makes sense to me.

> Next, is about tags in the patch.
> 
> Tested-by: is implied by author of the patch (otherwise the question how it
> was tested at all?!).
> 
> Reported-by: makes not much sense if SoB (author) is the same person.

Okay.
Comment 17 Guenter Roeck 2017-11-24 22:07:00 UTC
#16: I buy that for the machine name, but not for the manufacturer. It is just a little unlikely that there is a second Dell Inc. (with fewer spaces) around.
Comment 18 Oleksandr Natalenko 2017-11-25 09:57:28 UTC
Created attachment 260831 [details]
[PATCH] hwmon: (dell-smm) Disable fan support for Dell Vostro 3360

Taking into account comments posted above.
Comment 19 Oleksandr Natalenko 2017-12-18 09:55:07 UTC
Created attachment 261239 [details]
[PATCH] hwmon: (dell-smm) Disable fan support for Dell Vostro 3360

Added Reviewed-by as per ML discussion.
Comment 20 Pali Rohár 2018-01-27 13:54:59 UTC
@Guenter Roeck will you process patches from this bugzilla ticket? Feel free to change DMI_EXACT_MATCH to DMI_MATCH. But because this problem was reported in 2017-05-13, it would be nice to have it fixed as patches already exist.
Comment 21 Guenter Roeck 2018-01-27 16:03:50 UTC
@Pali: You know how to submit patches for the upstream kernel, even more so since you are the maintainer of the affected driver. Maybe your expectation is that upstream maintainers pick patches from where-ever the submitter happens to send them to, but that is not how kernel development works, and you should know that. Please send any patches you want to see upstream to the hwmon mailing list and Cc: me, and I'll be happy to process them.
Comment 22 vova7890 2018-04-20 21:03:27 UTC
Fixed in 4.16 by blacklist
Comment 23 Helge Eichelberg 2018-06-02 10:27:27 UTC
I might have the same issue with a Dell XPS13 9333.

Reading "/sys/devices/virtual/hwmon/hwmon2/fan1_input" takes about 500ms and causes a short but noticeable lag/freeze. I've noticed it since some time ago when running "sensors" but I installed "tlp" recently and now I notice the lag more often at (seemingly) random times.

Unfortunately, I'm not well-versed and do not know how to test if disabling fan support fixes the problem. I'm also cautious about what "taking functionality away" might mean.



user@hostname:~$ strace -Ty -e read cat /sys/devices/virtual/hwmon/hwmon2/fan1_input
read(3</lib/x86_64-linux-gnu/libc-2.26.so>, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\22\2\0\0\0\0\0"..., 832) = 832 <0.000017>
read(3</sys/devices/virtual/hwmon/hwmon2/fan1_input>, "3692\n", 131072) = 5 <0.501844>
3692
read(3</sys/devices/virtual/hwmon/hwmon2/fan1_input>, "", 131072) = 0 <0.000013>
+++ exited with 0 +++

user@hostname:~$ strace -Ty -e read sensors 2>&1 | grep fan1_input
read(3</sys/devices/virtual/hwmon/hwmon2/fan1_input>, "3642\n", 4096) = 5 <0.501666>

user@hostname:~$ sudo strace -Ty -e read tlp-stat 2>&1 | grep fan1_input
read(0</sys/devices/virtual/hwmon/hwmon2/fan1_input>, "3", 1) = 1 <0.502211>
read(0</sys/devices/virtual/hwmon/hwmon2/fan1_input>, "0", 1) = 1 <0.003049>
read(0</sys/devices/virtual/hwmon/hwmon2/fan1_input>, "6", 1) = 1 <0.000996>
read(0</sys/devices/virtual/hwmon/hwmon2/fan1_input>, "2", 1) = 1 <0.002996>
read(0</sys/devices/virtual/hwmon/hwmon2/fan1_input>, "\n", 1) = 1 <0.000077>

user@hostname:~$ cat /proc/version
Linux version 4.13.0-43-generic (buildd@lgw01-amd64-026) (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)) #48-Ubuntu SMP Wed May 16 12:18:48 UTC 2018

user@hostname:~$ sudo dmidecode -t 1,0 -q
System Information
	Manufacturer: Dell Inc.
	Product Name: XPS13 9333
	[...]

BIOS Information
	Vendor: Dell Inc.
	Version: A08
	Release Date: 08/31/2015

user@hostname:~$ cat /sys/class/dmi/id/sys_vendor
Dell Inc.

user@hostname:~$ cat /sys/class/dmi/id/product_name
XPS13 9333
Comment 24 Oleksandr Natalenko 2018-06-02 10:49:45 UTC
(In reply to inbox-kernelorg from comment #23)
> I might have the same issue with a Dell XPS13 9333.
> 
> Reading "/sys/devices/virtual/hwmon/hwmon2/fan1_input" takes about 500ms and
> causes a short but noticeable lag/freeze. I've noticed it since some time
> ago when running "sensors" but I installed "tlp" recently and now I notice
> the lag more often at (seemingly) random times.
> 
> Unfortunately, I'm not well-versed and do not know how to test if disabling
> fan support fixes the problem. I'm also cautious about what "taking
> functionality away" might mean.

Shall you be able to compile the kernel and test things if the blacklisting patch is provided?
Comment 25 Helge Eichelberg 2018-06-02 18:16:42 UTC
Created attachment 276303 [details]
[PATCH] hwmon: (dell-smm) Disable fan support for Dell XPS13 9333

I hope I'm doing this right.

After compiling the kernel with the attached changes, installing and rebooting, the file "/sys/devices/virtual/hwmon/hwmon2/fan1_input" doesn't exist anymore. No more freezes when running "sensors" and "tlp-stats". "sensors" doesn't report fan speed anymore, though. I guess that was the whole point. Otherwise, everything seems to be working as usual but I'll continue testing.
Comment 26 Oleksandr Natalenko 2018-06-02 18:20:07 UTC
(In reply to Helge Eichelberg from comment #25)
> Created attachment 276303 [details]
> [PATCH] hwmon: (dell-smm) Disable fan support for Dell XPS13 9333
> 
> I hope I'm doing this right.
> 
> After compiling the kernel with the attached changes, installing and
> rebooting, the file "/sys/devices/virtual/hwmon/hwmon2/fan1_input" doesn't
> exist anymore. No more freezes when running "sensors" and "tlp-stats".
> "sensors" doesn't report fan speed anymore, though. I guess that was the
> whole point. Otherwise, everything seems to be working as usual but I'll
> continue testing.

Yup, precisely. I was going to post exactly the same patch for you.

Feel free to push it into the upstream, BTW.
Comment 27 Guenter Roeck 2018-06-02 19:02:01 UTC
#26: Yes, please post the patch upstream. Please don't forget to sign it.