2022-08-21 15:35:53

by Armin Wolf

[permalink] [raw]
Subject: [PATCH 1/3] hwmon: (dell-smm) Fail probing when cooling device registration fails

Previously, it was thought that failing to register a cooling device
would not be critical, so the probing was not aborted in such a case.
This however would lead to userspace being unable to rely on those
cooling devices, since they might not represent all fans being present.
Fix that by failing probing when cooling device registration fails.

Tested on a Dell Inspiron 3505.

Fixes: e0d3f7cb2606 ("hwmon: (dell-smm) Add cooling device support")
Signed-off-by: Armin Wolf <[email protected]>
---
drivers/hwmon/dell-smm-hwmon.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 7f8d95dd2717..1dab7591576a 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -1013,12 +1013,10 @@ static int __init dell_smm_init_hwmon(struct device *dev)

data->fan[i] = true;

- /* the cooling device is not critical, ignore failures */
if (IS_REACHABLE(CONFIG_THERMAL)) {
err = dell_smm_init_cdev(dev, i);
if (err < 0)
- dev_warn(dev, "Failed to register cooling device for fan %u\n",
- i + 1);
+ return err;
}

data->fan_nominal_speed[i] = devm_kmalloc_array(dev, data->i8k_fan_max + 1,
--
2.30.2


2022-08-21 15:56:18

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 1/3] hwmon: (dell-smm) Fail probing when cooling device registration fails

On Sunday 21 August 2022 17:17:11 Armin Wolf wrote:
> Previously, it was thought that failing to register a cooling device
> would not be critical, so the probing was not aborted in such a case.
> This however would lead to userspace being unable to rely on those
> cooling devices, since they might not represent all fans being present.
> Fix that by failing probing when cooling device registration fails.

This patch does not fix address this issue fully. CONFIG_THERMAL can be
disabled during compile time and then cooling device would not be
registered too.

> Tested on a Dell Inspiron 3505.
>
> Fixes: e0d3f7cb2606 ("hwmon: (dell-smm) Add cooling device support")
> Signed-off-by: Armin Wolf <[email protected]>
> ---
> drivers/hwmon/dell-smm-hwmon.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index 7f8d95dd2717..1dab7591576a 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -1013,12 +1013,10 @@ static int __init dell_smm_init_hwmon(struct device *dev)
>
> data->fan[i] = true;
>
> - /* the cooling device is not critical, ignore failures */
> if (IS_REACHABLE(CONFIG_THERMAL)) {
> err = dell_smm_init_cdev(dev, i);
> if (err < 0)
> - dev_warn(dev, "Failed to register cooling device for fan %u\n",
> - i + 1);
> + return err;
> }
>
> data->fan_nominal_speed[i] = devm_kmalloc_array(dev, data->i8k_fan_max + 1,
> --
> 2.30.2
>

2022-08-21 19:13:41

by Armin Wolf

[permalink] [raw]
Subject: Re: [PATCH 1/3] hwmon: (dell-smm) Fail probing when cooling device registration fails

Am 21.08.22 um 17:41 schrieb Pali Rohár:

> On Sunday 21 August 2022 17:17:11 Armin Wolf wrote:
>> Previously, it was thought that failing to register a cooling device
>> would not be critical, so the probing was not aborted in such a case.
>> This however would lead to userspace being unable to rely on those
>> cooling devices, since they might not represent all fans being present.
>> Fix that by failing probing when cooling device registration fails.
> This patch does not fix address this issue fully. CONFIG_THERMAL can be
> disabled during compile time and then cooling device would not be
> registered too.

I though of the cooling device feature as being optional "as a whole".
So when CONFIG_THERMAL is disabled during compile time, the driver does
not create any cooling devices. If however CONFIG_THERMAL was enabled
during compile time, the driver should fail probing if it cannot register
all cooling devices.

Armin Wolf

>> Tested on a Dell Inspiron 3505.
>>
>> Fixes: e0d3f7cb2606 ("hwmon: (dell-smm) Add cooling device support")
>> Signed-off-by: Armin Wolf <[email protected]>
>> ---
>> drivers/hwmon/dell-smm-hwmon.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
>> index 7f8d95dd2717..1dab7591576a 100644
>> --- a/drivers/hwmon/dell-smm-hwmon.c
>> +++ b/drivers/hwmon/dell-smm-hwmon.c
>> @@ -1013,12 +1013,10 @@ static int __init dell_smm_init_hwmon(struct device *dev)
>>
>> data->fan[i] = true;
>>
>> - /* the cooling device is not critical, ignore failures */
>> if (IS_REACHABLE(CONFIG_THERMAL)) {
>> err = dell_smm_init_cdev(dev, i);
>> if (err < 0)
>> - dev_warn(dev, "Failed to register cooling device for fan %u\n",
>> - i + 1);
>> + return err;
>> }
>>
>> data->fan_nominal_speed[i] = devm_kmalloc_array(dev, data->i8k_fan_max + 1,
>> --
>> 2.30.2
>>

2022-08-22 16:45:24

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 1/3] hwmon: (dell-smm) Fail probing when cooling device registration fails

On Sun, Aug 21, 2022 at 09:11:24PM +0200, Armin Wolf wrote:
> Am 21.08.22 um 17:41 schrieb Pali Roh?r:
>
> > On Sunday 21 August 2022 17:17:11 Armin Wolf wrote:
> > > Previously, it was thought that failing to register a cooling device
> > > would not be critical, so the probing was not aborted in such a case.
> > > This however would lead to userspace being unable to rely on those
> > > cooling devices, since they might not represent all fans being present.
> > > Fix that by failing probing when cooling device registration fails.
> > This patch does not fix address this issue fully. CONFIG_THERMAL can be
> > disabled during compile time and then cooling device would not be
> > registered too.
>
> I though of the cooling device feature as being optional "as a whole".
> So when CONFIG_THERMAL is disabled during compile time, the driver does
> not create any cooling devices. If however CONFIG_THERMAL was enabled
> during compile time, the driver should fail probing if it cannot register
> all cooling devices.
>

I disagree. The primary objective of this driver is to report environmental
data. Support for the thermal subsystem is an add-on. If instantiating
the thermal device fails, the driver should at least report temperatures
and fan speeds, as it did before thermal support was added.

Thanks,
Guenter

> Armin Wolf
>
> > > Tested on a Dell Inspiron 3505.
> > >
> > > Fixes: e0d3f7cb2606 ("hwmon: (dell-smm) Add cooling device support")
> > > Signed-off-by: Armin Wolf <[email protected]>
> > > ---
> > > drivers/hwmon/dell-smm-hwmon.c | 4 +---
> > > 1 file changed, 1 insertion(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> > > index 7f8d95dd2717..1dab7591576a 100644
> > > --- a/drivers/hwmon/dell-smm-hwmon.c
> > > +++ b/drivers/hwmon/dell-smm-hwmon.c
> > > @@ -1013,12 +1013,10 @@ static int __init dell_smm_init_hwmon(struct device *dev)
> > >
> > > data->fan[i] = true;
> > >
> > > - /* the cooling device is not critical, ignore failures */
> > > if (IS_REACHABLE(CONFIG_THERMAL)) {
> > > err = dell_smm_init_cdev(dev, i);
> > > if (err < 0)
> > > - dev_warn(dev, "Failed to register cooling device for fan %u\n",
> > > - i + 1);
> > > + return err;
> > > }
> > >
> > > data->fan_nominal_speed[i] = devm_kmalloc_array(dev, data->i8k_fan_max + 1,
> > > --
> > > 2.30.2
> > >