Skip to contentSkip to conversation

hwmon: (pwm-fan) add option to leave fan on shutdown

PATCH In review Akinobu Mita 5 participants 12 messages Sep 23, 2021 – Oct 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 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."

Cc Rob Herring <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Billy Tsai <[email protected]>
---
 drivers/hwmon/pwm-fan.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/hwmon/pwm-fan.c +8 -1
index 17518b4cab1b..1ea0d0562c28 100644
@@ -38,6 +38,7 @@ struct pwm_fan_ctx {
 	struct pwm_fan_tach *tachs;
 	ktime_t sample_start;
 	struct timer_list rpm_timer;
+	bool retain_state_shutdown;
 
 	unsigned int pwm_value;
 	unsigned int pwm_fan_state;
@@ -312,6 +313,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
 
 	mutex_init(&ctx->lock);
 
+	ctx->retain_state_shutdown =
+		of_property_read_bool(dev->of_node, "retain-state-shutdown");
+
 	ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
 	if (IS_ERR(ctx->pwm))
 		return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n");
@@ -492,7 +496,10 @@ static int pwm_fan_disable(struct device *dev)
 
 static void pwm_fan_shutdown(struct platform_device *pdev)
 {
-	pwm_fan_disable(&pdev->dev);
+	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
+
+	if (!ctx->retain_state_shutdown)
+		pwm_fan_disable(&pdev->dev);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 dt-bindings: hwmon: (pwm-fan) add retain-state-shutdown property

Document new retain-state-shutdown property.

Cc Rob Herring <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Billy Tsai <[email protected]>
---
 Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/hwmon/pwm-fan.txt +2 -0
index 4509e688623a..c1b2c3ff7ba8 100644
@@ -19,6 +19,8 @@ Optional properties:
 			  interrupts per revolution). The value must be
 			  greater than zero.
 
+- retain-state-shutdown: Retain the state of the PWM on shutdown.
+
 Example:
 	fan0: pwm-fan {
 		compatible = "pwm-fan";
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/2
#4 lore raw
In reply to Akinobu Mita
Quoted 9 lines · Akinobu Mita

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 5 lines
Cc Rob Herring <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Billy Tsai <[email protected]>

For my reference (waiting for DT property approval):

Guenter

Quoted 38 lines
---
 drivers/hwmon/pwm-fan.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/hwmon/pwm-fan.c +8 -1
index 17518b4cab1b..1ea0d0562c28 100644
@@ -38,6 +38,7 @@ struct pwm_fan_ctx {
 	struct pwm_fan_tach *tachs;
 	ktime_t sample_start;
 	struct timer_list rpm_timer;
+	bool retain_state_shutdown;
 
 	unsigned int pwm_value;
 	unsigned int pwm_fan_state;
@@ -312,6 +313,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
 
 	mutex_init(&ctx->lock);
 
+	ctx->retain_state_shutdown =
+		of_property_read_bool(dev->of_node, "retain-state-shutdown");
+
 	ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
 	if (IS_ERR(ctx->pwm))
 		return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n");
@@ -492,7 +496,10 @@ static int pwm_fan_disable(struct device *dev)
 
 static void pwm_fan_shutdown(struct platform_device *pdev)
 {
-	pwm_fan_disable(&pdev->dev);
+	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
+
+	if (!ctx->retain_state_shutdown)
+		pwm_fan_disable(&pdev->dev);
 }
 
 #ifdef CONFIG_PM_SLEEP
Reviewed-by
#5 lore raw

On 2021/10/11, 10:34 PM, "Guenter Roeck" <[email protected] on behalf of [email protected]> wrote:

On Thu, Sep 23, 2021 at 11:34:47AM +0900, Akinobu Mita wrote:
> > 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."
> >
> > Cc: Rob Herring <[email protected]>
> > Cc: Bartlomiej Zolnierkiewicz <[email protected]>
> > Cc: Guenter Roeck <[email protected]>
> > Cc: Billy Tsai <[email protected]>
> > Signed-off-by: Akinobu Mita <[email protected]>

> For my reference (waiting for DT property approval):

> Reviewed-by: Guenter Roeck <[email protected]>

> Guenter

Billy

Quoted 38 lines
Quoted 38 lines
---
 drivers/hwmon/pwm-fan.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/hwmon/pwm-fan.c +8 -1
index 17518b4cab1b..1ea0d0562c28 100644
@@ -38,6 +38,7 @@ struct pwm_fan_ctx {
 	struct pwm_fan_tach *tachs;
 	ktime_t sample_start;
 	struct timer_list rpm_timer;
+	bool retain_state_shutdown;
 
 	unsigned int pwm_value;
 	unsigned int pwm_fan_state;
@@ -312,6 +313,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
 
 	mutex_init(&ctx->lock);
 
+	ctx->retain_state_shutdown =
+		of_property_read_bool(dev->of_node, "retain-state-shutdown");
+
 	ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
 	if (IS_ERR(ctx->pwm))
 		return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n");
@@ -492,7 +496,10 @@ static int pwm_fan_disable(struct device *dev)
 
 static void pwm_fan_shutdown(struct platform_device *pdev)
 {
-	pwm_fan_disable(&pdev->dev);
+	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
+
+	if (!ctx->retain_state_shutdown)
+		pwm_fan_disable(&pdev->dev);
 }
 
 #ifdef CONFIG_PM_SLEEP
#6 lore raw

Hi All,

I found that these patches have been rejected.
Is there any other reason why it can't be merged into the mainline?

Thanks

#7 lore raw
Quoted 4 lines · Billy Tsai

Hi All,

I found that these patches have been rejected.

Where did that happen?

Quoted 1 line

Is there any other reason why it can't be merged into the mainline?

I don't see any replies on the binding. Perhaps that's because it wasn't sent to the DT list and it doesn't get reviewed if not. In any case, lots has changed in 3 years such as we have a fan binding now.

Rob

maintainer
#8 lore raw
Quoted 8 lines · Rob Herring
Quoted 4 lines · Billy Tsai

Hi All,

I found that these patches have been rejected.

Where did that happen?

https://patchwork.kernel.org/project/linux-hwmon/patch/[email protected]/

It has been a long time, but from the available history I guess I marked it as rejected because the DT patch was never approved. That is just a guess, though; I really don't remember.

Guenter

Quoted 7 lines
Quoted 1 line

Is there any other reason why it can't be merged into the mainline?

I don't see any replies on the binding. Perhaps that's because it wasn't sent to the DT list and it doesn't get reviewed if not. In any case, lots has changed in 3 years such as we have a fan binding now.

Rob

#2 lore raw

Re: [PATCH 2/2] dt-bindings: hwmon: (pwm-fan) add retain-state-shutdown property

In reply to Akinobu Mita
Quoted 7 lines · Akinobu Mita

Document new retain-state-shutdown property.

Cc Rob Herring <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Billy Tsai <[email protected]>

You develop on some very old kernel, please don't and rather use mainline.

<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.

Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline) or work on fork of kernel (don't, instead use mainline). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.

You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time.

Please kindly resend and include all necessary To/Cc entries. </form letter>

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 2/2] dt-bindings: hwmon: (pwm-fan) add retain-state-shutdown property

Quoted 10 lines · Krzysztof Kozlowski
Quoted 7 lines · Akinobu Mita

Document new retain-state-shutdown property.

Cc Rob Herring <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Billy Tsai <[email protected]>

You develop on some very old kernel, please don't and rather use mainline.

And I need to start checking dates of messages which lei brings to me.

Sorry for the noise, although missing cc to DT is still valid argument.

Best regards,
Krzysztof

#9 lore raw
In reply to Billy Tsai

Hi Billy,

I have updated and resubmitted these patches. I don't have the hardware to test at the moment, so is it possible for you to test it?

maintainer
#10 lore raw
Quoted 4 lines · Akinobu Mita

Hi Billy,

I have updated and resubmitted these patches. I don't have the hardware to test at the moment, so is it possible for you to test it?

You did not provide a change log. I do not review patch resubmissions without change log.

Guenter

#11 lore raw
In reply to Akinobu Mita
Quoted 2 lines

I have updated and resubmitted these patches. I don't have the hardware to test at the moment, so is it possible for you to test it?

Okay, I will try the v2 patch and add the Tested-by.

Thanks