hwmon: (pwm-fan) add option to leave fan on shutdown
Subsystems (2)
v2 cover hwmon: (pwm-fan) add option to leave fan on shutdown
I sent these patches a long time ago, but I didn't cc them to the DT list, so the DT bindings changes weren't reviewed.
There have been a lot of changes to pwm-fan since then, and I've updated the patch, so please review again.
Akinobu Mita (2):
hwmon: (pwm-fan) add option to leave fan on shutdown
dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 4 ++++ drivers/hwmon/pwm-fan.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 hwmon: (pwm-fan) add option to leave fan on shutdown
This adds an optional property "retain-state-shutdown" as requested by Billy Tsai.
Billy said:
"Our platform is BMC that will use a PWM-FAN driver to control the fan on the managed host. In our case, we do not want to stop the fan when the BMC is reboot, which may cause the temperature of the managed host not to be lowered."
--- drivers/hwmon/pwm-fan.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwmon/pwm-fan.c +5 -1
@@ -51,6 +51,7 @@ struct pwm_fan_ctx {u32 *pulses_per_revolution;ktime_t sample_start;struct timer_list rpm_timer; +bool retain_state_shutdown;unsigned int pwm_value;unsigned int pwm_fan_state;
@@ -490,6 +491,8 @@ static int pwm_fan_probe(struct platform_device *pdev)mutex_init (&ctx->lock); + ctx->retain_state_shutdown =device_property_read_bool (dev,"retain-state-shutdown" ); + ctx->dev = &pdev->dev; ctx->pwm =devm_pwm_get (dev,NULL );if (IS_ERR (ctx->pwm))
@@ -655,7 +658,8 @@ static void pwm_fan_shutdown(struct platform_device *pdev) {struct pwm_fan_ctx *ctx =platform_get_drvdata (pdev); -pwm_fan_cleanup (ctx); +if (!ctx->retain_state_shutdown) +pwm_fan_cleanup (ctx); }static int pwm_fan_suspend (struct device *dev)
Signature · 1 line
2.34.1
Quoted 8 lines
This adds an optional property "retain-state-shutdown" as requested by Billy Tsai.
Billy said:
"Our platform is BMC that will use a PWM-FAN driver to control the fan on the managed host. In our case, we do not want to stop the fan when the BMC is reboot, which may cause the temperature of the managed host not to be lowered."
I confirmed that it works properly.
Thanks
2024年10月29日(火) 11:35 Billy Tsai <[email protected]>:
Quoted 10 lines
Quoted 9 lines
This adds an optional property "retain-state-shutdown" as requested by Billy Tsai.
Billy said:
"Our platform is BMC that will use a PWM-FAN driver to control the fan on the managed host. In our case, we do not want to stop the fan when the BMC is reboot, which may cause the temperature of the managed host not to be lowered."
Quoted 4 lines
I confirmed that it works properly.
Reviewed-by Billy Tsai <[email protected]>Tested-by Billy Tsai <[email protected]>
Thank you very much for testing.
However, I plan to change this option to device attribute (/sys/class/hwmon/hwmonX/retain-state-shutdown) instead of the device tree.
Guenter Roeck
maintainerQuoted 11 lines · Akinobu Mita
2024年10月29日(火) 11:35 Billy Tsai <[email protected]>:
Quoted 10 lines
Quoted 9 lines
This adds an optional property "retain-state-shutdown" as requested by Billy Tsai.
Billy said:
"Our platform is BMC that will use a PWM-FAN driver to control the fan on the managed host. In our case, we do not want to stop the fan when the BMC is reboot, which may cause the temperature of the managed host not to be lowered."
Quoted 8 lines
Quoted 4 lines
I confirmed that it works properly.
Reviewed-by Billy Tsai <[email protected]>Tested-by Billy Tsai <[email protected]>Thank you very much for testing.
However, I plan to change this option to device attribute (/sys/class/hwmon/hwmonX/retain-state-shutdown) instead of the device tree.
No, I won't acccept that.
Guenter
2024年10月31日(木) 0:02 Guenter Roeck <[email protected]>:
Quoted 18 lines · Akinobu Mita
Quoted 16 lines
2024年10月29日(火) 11:35 Billy Tsai <[email protected]>:
Quoted 14 lines
Quoted 9 lines
This adds an optional property "retain-state-shutdown" as requested by Billy Tsai.
Billy said:
"Our platform is BMC that will use a PWM-FAN driver to control the fan on the managed host. In our case, we do not want to stop the fan when the BMC is reboot, which may cause the temperature of the managed host not to be lowered."I confirmed that it works properly.
Reviewed-by Billy Tsai <[email protected]>Tested-by Billy Tsai <[email protected]>
Quoted 6 lines
Quoted 3 lines
Thank you very much for testing.
However, I plan to change this option to device attribute (/sys/class/hwmon/hwmonX/retain-state-shutdown) instead of the device tree.No, I won't acccept that.
Oops, I mean /sys/device/platform/pwm-fan.X/retain-state-shutdown not /sys/class/hwmon/hwmonX/retain-state-shutdown.
Guenter Roeck
maintainerQuoted 24 lines · Akinobu Mita
2024年10月31日(木) 0:02 Guenter Roeck <[email protected]>:
Quoted 23 lines · Akinobu Mita
Quoted 19 lines
2024年10月29日(火) 11:35 Billy Tsai <[email protected]>:
Quoted 10 lines
Quoted 9 lines
This adds an optional property "retain-state-shutdown" as requested by Billy Tsai.
Billy said:
"Our platform is BMC that will use a PWM-FAN driver to control the fan on the managed host. In our case, we do not want to stop the fan when the BMC is reboot, which may cause the temperature of the managed host not to be lowered."Quoted 4 lines
I confirmed that it works properly.
Reviewed-by Billy Tsai <[email protected]>Tested-by Billy Tsai <[email protected]>Thank you very much for testing.
However, I plan to change this option to device attribute (/sys/class/hwmon/hwmonX/retain-state-shutdown) instead of the device tree.
Quoted 4 lines
Quoted 1 line
No, I won't acccept that.
Oops, I mean
/sys/device/platform/pwm-fan.X/retain-state-shutdownnot/sys/class/hwmon/hwmonX/retain-state-shutdown.
That does not make a difference. It still very much looks like a system property to me, and making it a device property to be set by userspace just looks like a workaround to address refusal by dt maintainers to accept the system property.
You'll have to make the case for why this is _not_ a system property for me to accept it.
Guenter
PATCH v2 2/2 dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
In reply to Akinobu MitaDocument new retain-state-shutdown property.
--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +4 -0
@@ -40,6 +40,10 @@ properties: maximum: 4 default: 2 + retain-state-shutdown: + description: Retain the state of the PWM on shutdown. + $ref: /schemas/types.yaml#/definitions/flag + pwms: description: The PWM that is used to control the fan. maxItems: 1
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
Quoted 18 lines · Akinobu Mita
Document new retain-state-shutdown property.
Cc Jean Delvare <[email protected]>Cc Guenter Roeck <[email protected]>Cc Rob Herring <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Conor Dooley <[email protected]>Cc Billy Tsai <[email protected]>Signed-off-by Akinobu Mita <[email protected]>--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +0
-0
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml properties: · line 44
Quoted 5 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +2
-0@@ -40,6 +40,10 @@ properties: maximum: 4 default: 2 + retain-state-shutdown: + description: Retain the state of the PWM on shutdown.
You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Best regards,
Krzysztof
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
2024年10月28日(月) 5:38 Krzysztof Kozlowski <[email protected]>:
Quoted 23 lines · Akinobu Mita
Quoted 21 lines
Document new retain-state-shutdown property.
Cc Jean Delvare <[email protected]>Cc Guenter Roeck <[email protected]>Cc Rob Herring <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Conor Dooley <[email protected]>Cc Billy Tsai <[email protected]>Signed-off-by Akinobu Mita <[email protected]>--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +0
-0@@ -40,6 +40,10 @@ properties: maximum: 4 default: 2
Quoted 7 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml properties: · line 44
Quoted 2 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +2
-0+ retain-state-shutdown: + description: Retain the state of the PWM on shutdown.You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Is this description okay?
(Reused the description of retain-state-shutdown in leds-gpio.yaml)
description:
Retain the state of the PWM on shutdown. Useful in BMC systems, for example, when the BMC is rebooted while the host remains up, the fan will not stop.
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
Quoted 32 lines · Akinobu Mita
2024年10月28日(月) 5:38 Krzysztof Kozlowski <[email protected]>:
Quoted 23 lines · Akinobu Mita
Quoted 21 lines
Document new retain-state-shutdown property.
Cc Jean Delvare <[email protected]>Cc Guenter Roeck <[email protected]>Cc Rob Herring <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Conor Dooley <[email protected]>Cc Billy Tsai <[email protected]>Signed-off-by Akinobu Mita <[email protected]>--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +0
-0@@ -40,6 +40,10 @@ properties: maximum: 4 default: 2Quoted 7 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml properties: · line 44
Quoted 2 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +2
-0+ retain-state-shutdown: + description: Retain the state of the PWM on shutdown.You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Quoted 7 lines
Is this description okay?
(Reused the description of retain-state-shutdown inleds-gpio.yaml)description:
Retain the state of the PWM on shutdown. Useful in BMC systems, for example, when the BMC is rebooted while the host remains up, the fan will not stop.
Nothing improved in the property. You still say what the system should do. This is user-space choice, not DT.
Best regards,
Krzysztof
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
2024年10月28日(月) 23:22 Krzysztof Kozlowski <[email protected]>:
Quoted 37 lines · Akinobu Mita
Quoted 35 lines
2024年10月28日(月) 5:38 Krzysztof Kozlowski <[email protected]>:
Quoted 23 lines · Akinobu Mita
Quoted 21 lines
Document new retain-state-shutdown property.
Cc Jean Delvare <[email protected]>Cc Guenter Roeck <[email protected]>Cc Rob Herring <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Conor Dooley <[email protected]>Cc Billy Tsai <[email protected]>Signed-off-by Akinobu Mita <[email protected]>--- Documentation/devicetree/bindings/hwmon/pwm-fan.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +0
-0@@ -40,6 +40,10 @@ properties: maximum: 4 default: 2Quoted 7 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml properties: · line 44
Quoted 2 lines
Documentation/devicetree/bindings/hwmon/pwm-fan.yaml +2
-0+ retain-state-shutdown: + description: Retain the state of the PWM on shutdown.You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Is this description okay?
(Reused the description of retain-state-shutdown inleds-gpio.yaml)
Quoted 7 lines
Quoted 4 lines
description:
Retain the state of the PWM on shutdown. Useful in BMC systems, for example, when the BMC is rebooted while the host remains up, the fan will not stop.Nothing improved in the property. You still say what the system should do. This is user-space choice, not DT.
It seems better to implement it as a device attribute.
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
Quoted 14 lines · Akinobu Mita
Quoted 14 lines
Quoted 13 lines
Quoted 5 lines
You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Is this description okay?
(Reused the description of retain-state-shutdown inleds-gpio.yaml)description:
Retain the state of the PWM on shutdown. Useful in BMC systems, for example, when the BMC is rebooted while the host remains up, the fan will not stop.
Quoted 4 lines
Quoted 2 lines
Nothing improved in the property. You still say what the system should do. This is user-space choice, not DT.
It seems better to implement it as a device attribute.
I don't know about that. To repeat: if you say what system is supposed to be doing, it is a policy. Describe the hardware and its configuration and maybe this would be suitable for DT.
Best regards,
Krzysztof
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
2024年10月31日(木) 0:18 Krzysztof Kozlowski <[email protected]>:
Quoted 16 lines · Akinobu Mita
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 5 lines
You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Is this description okay?
(Reused the description of retain-state-shutdown inleds-gpio.yaml)description:
Retain the state of the PWM on shutdown. Useful in BMC systems, for example, when the BMC is rebooted while the host remains up, the fan will not stop.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Nothing improved in the property. You still say what the system should do. This is user-space choice, not DT.
It seems better to implement it as a device attribute.
I don't know about that. To repeat: if you say what system is supposed to be doing, it is a policy. Describe the hardware and its configuration and maybe this would be suitable for DT.
Billy, could you please write a proper description for this property? I'm not the right person for this.
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
Quoted 19 lines
Quoted 19 lines · Akinobu Mita
Quoted 17 lines
Quoted 16 lines
Quoted 6 lines
Quoted 5 lines
You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Quoted 7 lines
Is this description okay?
(Reused the description of retain-state-shutdown inleds-gpio.yaml)description:
Retain the state of the PWM on shutdown. Useful in BMC systems, for example, when the BMC is rebooted while the host remains up, the fan will not stop.Nothing improved in the property. You still say what the system should do. This is user-space choice, not DT.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It seems better to implement it as a device attribute.
I don't know about that. To repeat: if you say what system is supposed to be doing, it is a policy. Describe the hardware and its configuration and maybe this would be suitable for DT.
Billy, could you please write a proper description for this property? I'm not the right person for this.
In our hardware, if the system reboots and power remains on the PWM controller will retain its original settings. However, the pwm-fan.c driver currently disables the PWM controller during a system reboot. I need this property to prevent pwm-fan.c from disabling the PWM when the system reboots.
In my point of view, the description can be:
Retain the state of the PWM on shutdown. Some platforms (e.g., BMC) will maintain the PWM status after the system reboot. Add this property to prevent the PWM from being disabled during the system reboot.
Thanks
Billy Tsai
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
Quoted 25 lines · Billy Tsai
Quoted 24 lines
Quoted 24 lines · Akinobu Mita
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 5 lines
You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Is this description okay?
(Reused the description of retain-state-shutdown inleds-gpio.yaml)description:
Retain the state of the PWM on shutdown. Useful in BMC systems, for example, when the BMC is rebooted while the host remains up, the fan will not stop.Quoted 4 lines
Quoted 2 lines
Nothing improved in the property. You still say what the system should do. This is user-space choice, not DT.
It seems better to implement it as a device attribute.
I don't know about that. To repeat: if you say what system is supposed to be doing, it is a policy. Describe the hardware and its configuration and maybe this would be suitable for DT.
Quoted 6 lines
Quoted 2 lines
Billy, could you please write a proper description for this property? I'm not the right person for this.
In our hardware, if the system reboots and power remains on the PWM controller will retain its original settings. However, the
pwm-fan.cdriver currently disables the PWM controller during a system reboot. I need this property to preventpwm-fan.c
If we change the PWM core not to disable it, then we have to change bindings?
How is this binding applicable on system (e.g. on *BSD) which does not disable PWM on reboot?
Quoted 5 lines
from disabling the PWM when the system reboots.
In my point of view, the description can be:
Retain the state of the PWM on shutdown. Some platforms (e.g., BMC) will maintain the PWM status after the system reboot. Add this property to prevent the PWM from being disabled during the system reboot.
You again describe what OS should do. First and last sentences are the same.
Probably what you want to say is that fan is some critical component which should not be turned off or left unattended. Or that this hardware keeps last state of register on reset, so some boards might want to use it? If the first, then probably different property name. If the second, current seems fine, just choose some description describing actual hardware.
Best regards,
Krzysztof
Re: [PATCH v2 2/2] dt-bindings: hwmon: pwm-fan: add retain-state-shutdown property
Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 16 lines · Akinobu Mita
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 5 lines
You described the desired Linux feature or behavior, not the actual hardware. The bindings are about the latter, so instead you need to rephrase the property and its description to match actual hardware capabilities/features/configuration etc.
Is this description okay?
(Reused the description of retain-state-shutdown inleds-gpio.yaml)description:
Retain the state of the PWM on shutdown. Useful in BMC systems, for example, when the BMC is rebooted while the host remains up, the fan will not stop.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Nothing improved in the property. You still say what the system should do. This is user-space choice, not DT.
It seems better to implement it as a device attribute.
I don't know about that. To repeat: if you say what system is supposed to be doing, it is a policy. Describe the hardware and its configuration and maybe this would be suitable for DT.
Billy, could you please write a proper description for this property? I'm not the right person for this.
Quoted 6 lines
Quoted 3 lines
In our hardware, if the system reboots and power remains on the PWM controller will retain its original settings. However, the
pwm-fan.cdriver currently disables the PWM controller during a system reboot. I need this property to preventpwm-fan.cIf we change the PWM core not to disable it, then we have to change bindings?
If the pwm-fan.c driver doesn't disable the PWM controller, we don't need to add this property.
Quoted 2 lines
How is this binding applicable on system (e.g. on *BSD) which does not disable PWM on reboot?
That's why we need this property?
Quoted 6 lines
Quoted 5 lines
from disabling the PWM when the system reboots.
In my point of view, the description can be:
Retain the state of the PWM on shutdown. Some platforms (e.g., BMC) will maintain the PWM status after the system reboot. Add this property to prevent the PWM from being disabled during the system reboot.
Quoted 7 lines
You again describe what OS should do. First and last sentences are the same.
Probably what you want to say is that fan is some critical component which should not be turned off or left unattended. Or that this hardware keeps last state of register on reset, so some boards might want to use it? If the first, then probably different property name. If the second, current seems fine, just choose some description describing actual hardware.
I think it will be the second one. Is it okay to change the description to the following? Retain the state of the PWM on shutdown. Some platforms (e.g., BMC) require the PWM to maintain its last register status on system reboot. Add this property to prevent the PWM from being disabled during system reboot.
Thanks
Billy Tsai
Guenter Roeck
maintainerQuoted 6 lines · Akinobu Mita
I sent these patches a long time ago, but I didn't cc them to the DT list, so the DT bindings changes weren't reviewed.
There have been a lot of changes to pwm-fan since then, and I've updated the patch, so please review again.
What changed ? Where is the change log ?
Guenter
Quoted 8 lines
Akinobu Mita (2):
hwmon: (pwm-fan) add option to leave fan on shutdown
dt-bindings: hwmon: pwm-fan: add retain-state-shutdown propertyDocumentation/devicetree/bindings/hwmon/pwm-fan.yaml | 4 ++++ drivers/hwmon/pwm-fan.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-)
2024年10月27日(日) 1:19 Guenter Roeck <[email protected]>:
Quoted 10 lines · Akinobu Mita
Quoted 6 lines
I sent these patches a long time ago, but I didn't cc them to the DT list, so the DT bindings changes weren't reviewed.
There have been a lot of changes to pwm-fan since then, and I've updated the patch, so please review again.
What changed ? Where is the change log ?
Sorry, I forgot to write the changelog.
Changes in v2
Patch 1:
- use device_property_read_bool() instead of of_property_read_bool()
- skip calling pwn_fan_cleanup() when newly introduced property is set (Since pwm_fan_disable() call in the shutdown() method has been changed to pwm_fan_cleanup() call since commit b99152d4f04b ("hwmon: (pwm-fan) Switch regulator dynamically"), pwm_fan_disable() no longer exists.)
Patch 2:
- document the new property according to yaml format conversion