Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set fan mode/Dell XPS 7390/dell_smm/pwm1_enable #229

Open
piyueh opened this issue May 19, 2023 · 5 comments
Open

Unable to set fan mode/Dell XPS 7390/dell_smm/pwm1_enable #229

piyueh opened this issue May 19, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@piyueh
Copy link

piyueh commented May 19, 2023

Describe the bug

fan2go fan init -i <fan> and fan2go gave errors complaining being unable to set fan mode through pwm*_enable.

To Reproduce

  1. $ fan2go detect (I'm only posting relevant sections here):

    Click me to expand
    > dell_smm-isa-0000
      Fans     Index  Channel  Label        RPM  PWM  Auto 
      -----------------------------------------------------
               1      1        hwmon4/fan1  0    0    false
               2      2        hwmon4/fan2  0    0    false
      Sensors  Index  Label                       Value
      -------------------------------------------------
               1      hwmon4/temp1 (temp1_input)  44000
               2      hwmon4/temp2 (temp2_input)  37000
               3      hwmon4/temp3 (temp3_input)  38000
               4      hwmon4/temp4 (temp4_input)  32000
               5      hwmon4/temp5 (temp5_input)  38000
               6      hwmon4/temp6 (temp6_input)  38000
               7      hwmon4/temp7 (temp7_input)  37000
    
    > coretemp-isa-0000
      Sensors  Index  Label                       Value
      -------------------------------------------------
               1      Package id 0 (temp1_input)  53000
               2      Core 0 (temp2_input)        51000
               3      Core 1 (temp3_input)        51000
               4      Core 2 (temp4_input)        52000
               5      Core 3 (temp5_input)        50000
               6      Core 4 (temp6_input)        52000
               7      Core 5 (temp7_input)        48000
  2. $ cat /etc/fan2go/fan2go.yaml:

    Click me to expand
    fans:
      - id: fan-1
        hwmon:
          platform: dell_smm-isa-0000
          rpmChannel: 1
          pwmChannel: 1
          index: 0
        neverStop: true
        curve: fan-curve-1
    sensors:
      - id: cpu-package
        hwmon:
          platform: coretemp-isa-0000
          index: 1
    curves:
      - id: fan-curve-1
        linear:
          sensor: cpu-package
          min: 50
          max: 90
  3. # fan2go fan init -i fan-1, I got

    Click me to expand
    INFO  Using configuration file at: /etc/fan2go/fan2go.yaml
    INFO  Using persistence at: /etc/fan2go/fan2go.db
    INFO  Deleting existing data for fan 'fan-1'...
    INFO  Computing pwm map...
    ERROR   Unable to set Fan Mode of 'fan-1' to "1": PWM mode stuck to -1
    ERROR   Unable to set Fan Mode of 'fan-1' to "0": write
        /sys/devices/platform/dell_smm_hwmon/hwmon/hwmon5/pwm1_enable:
        invalid argument
    INFO  Measuring RPM curve...
    ERROR   Unable to set Fan Mode of 'fan-1' to "1": PWM mode stuck to -1
    ERROR   Unable to set Fan Mode of 'fan-1' to "0": write
        /sys/devices/platform/dell_smm_hwmon/hwmon/hwmon5/pwm1_enable:
        invalid argument
    WARNING  Could not enable manual fan mode on fan-1, trying to
        continue anyway...
    SUCCESS  Done!
    INFO  Using configuration file at: /etc/fan2go/fan2go.yaml
    fan-1
    ------------
    Min PWM    0
    Start PWM  0
    Max PWM    0

Expected behavior

No error messages.

Desktop (please complete the following information):

  • Laptop model: Dell XPS 7390
  • Distro: Arch Linux
  • uname -a: 6.3.2-arch1-1
  • sensors -v: sensors version 3.6.0+git with libsensors version 3.6.0+git
  • fan2go version: commit c20619e

Additional context

According to hwmon's documentation, for dell_smm, the file pwm1_enable does not accept 0. A value of 1 to pwm1_enable means disabling the automatic BIOS fan control, while 2 means enabling such automatic control. See here.

@piyueh piyueh added the bug Something isn't working label May 19, 2023
@markusressel
Copy link
Owner

fan2go tries to set 1 first and only falls back to 0.
Since both seem to fail and the returned value seems to be -1 this might be a permission problem.

@piyueh
Copy link
Author

piyueh commented May 19, 2023

You are right. I think simply using sudo does not give enough permission to write to pwm*_enable. On my machine, I have to actually be the root to write to the file.

@piyueh
Copy link
Author

piyueh commented Jun 24, 2023

I'm re-opening this issue because maybe some other people may help. I'm unsure if this is simply a permission issue or something else. I found that writing 1 to the file pwm1_enable did not give any permission error. The permission error appeared when fan2go tried to read the value from pwm1_enable for confirmation. On my machine (Dell XPS13 7390 and Arch Linux), pwm1_enable is not readable even as a root (cat, tail, head, or even opening/reading it with Python/C code did not work). I haven't figured out why.

So I think the permission error message originated from line 163 when trying to read the value:

func (fan *HwMonFan) SetPwmEnabled(value ControlMode) (err error) {
err = util.WriteIntToFile(int(value), fan.Config.HwMon.PwmEnablePath)
if err == nil {
currentValue, err := util.ReadIntFromFile(fan.Config.HwMon.PwmEnablePath)
if err != nil || ControlMode(currentValue) != value {
return fmt.Errorf("PWM mode stuck to %d", currentValue)
}
}
return err
}

@piyueh piyueh reopened this Jun 24, 2023
@piyueh
Copy link
Author

piyueh commented Oct 2, 2023

@markusressel Just to give an update. If my understanding is correct, for Dell fans that rely on the dell_smm_hwmon kernel module, pwm1_enable is write-only. Therefore reading the value from pwm1_enable always fails. And so the code snippet referenced in my previous comment always returns an error.

See: https://docs.kernel.org/hwmon/dell-smm-hwmon.html. In the table of available sysfs interfaces, pwm1_enable is shown to be write-only.
image

@markusressel
Copy link
Owner

Hmm interesting 🤔 I am not sure if we can test for this somehow in code and ignore the validation logic in case the pwm_enable is write-only. However, even if not, we could add a config property to disable it manually.

As I am not able to test this with real hardware myself, we would need to test it on yours. I will let you know when I have something ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants