2022-06-29 23:19:17

by William McVicker

[permalink] [raw]
Subject: [PATCH 4.19 v1 0/2] Fixes for thermal hwmon registration

Hi All,

These two patches fix issues with thermal hwmon registration on 4.19.
The upstream commit ddaefa209c4a ("hwmon: Make chip parameter for
with_info API mandatory") forces the chip parameter to be mandatory
which breaks thermal subsystem devices from probing. These fixes were
pulled into 5.4, but missed from 4.19. I have verified them on Pixel
5 with the 4.19 kernel.

Thanks,
Will

Guenter Roeck (2):
hwmon: Introduce hwmon_device_register_for_thermal
thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal()

drivers/hwmon/hwmon.c | 25 +++++++++++++++++++++++++
drivers/thermal/thermal_hwmon.c | 4 ++--
include/linux/hwmon.h | 3 +++
3 files changed, 30 insertions(+), 2 deletions(-)

--
2.37.0.rc0.161.g10f37bed90-goog


2022-06-29 23:21:34

by William McVicker

[permalink] [raw]
Subject: [PATCH 4.19 v1 2/2] thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal()

From: Guenter Roeck <[email protected]>

[ upstream commit 87743bcf08072b3e1952a0bf5524b2833e667b4c ]

The thermal subsystem registers a hwmon device without providing chip
information or sysfs attribute groups. While undesirable, it would be
difficult to change. On the other side, it abuses the
hwmon_device_register_with_info API by not providing that information.
Use new API specifically created for the thermal subsystem instead to
let us enforce the 'chip' parameter for other callers of
hwmon_device_register_with_info().

Acked-by: Rafael J . Wysocki <[email protected]>
Signed-off-by: Guenter Roeck <[email protected]>
---
drivers/thermal/thermal_hwmon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index dd5d8ee37928..b3b229421936 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -147,8 +147,8 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
INIT_LIST_HEAD(&hwmon->tz_list);
strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
strreplace(hwmon->type, '-', '_');
- hwmon->device = hwmon_device_register_with_info(&tz->device, hwmon->type,
- hwmon, NULL, NULL);
+ hwmon->device = hwmon_device_register_for_thermal(&tz->device,
+ hwmon->type, hwmon);
if (IS_ERR(hwmon->device)) {
result = PTR_ERR(hwmon->device);
goto free_mem;
--
2.37.0.rc0.161.g10f37bed90-goog

2022-06-29 23:22:18

by William McVicker

[permalink] [raw]
Subject: [PATCH 4.19 v1 1/2] hwmon: Introduce hwmon_device_register_for_thermal

From: Guenter Roeck <[email protected]>

[ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]

The thermal subsystem registers a hwmon driver without providing
chip or sysfs group information. This is for legacy reasons and
would be difficult to change. At the same time, we want to enforce
that chip information is provided when registering a hwmon device
using hwmon_device_register_with_info(). To enable this, introduce
a special API for use only by the thermal subsystem.

Acked-by: Rafael J . Wysocki <[email protected]>
Signed-off-by: Guenter Roeck <[email protected]>
---
drivers/hwmon/hwmon.c | 25 +++++++++++++++++++++++++
include/linux/hwmon.h | 3 +++
2 files changed, 28 insertions(+)

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index c4051a3e63c2..412a5e39fc14 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -725,6 +725,31 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
}
EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);

+/**
+ * hwmon_device_register_for_thermal - register hwmon device for thermal subsystem
+ * @dev: the parent device
+ * @name: hwmon name attribute
+ * @drvdata: driver data to attach to created device
+ *
+ * The use of this function is restricted. It is provided for legacy reasons
+ * and must only be called from the thermal subsystem.
+ *
+ * hwmon_device_unregister() must be called when the device is no
+ * longer needed.
+ *
+ * Returns the pointer to the new device.
+ */
+struct device *
+hwmon_device_register_for_thermal(struct device *dev, const char *name,
+ void *drvdata)
+{
+ if (!name || !dev)
+ return ERR_PTR(-EINVAL);
+
+ return __hwmon_device_register(dev, name, drvdata, NULL, NULL);
+}
+EXPORT_SYMBOL_GPL(hwmon_device_register_for_thermal);
+
/**
* hwmon_device_register - register w/ hwmon
* @dev: the device to register
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index 8fde789f2eff..5ff3db6eb9f1 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -390,6 +390,9 @@ hwmon_device_register_with_info(struct device *dev,
const struct hwmon_chip_info *info,
const struct attribute_group **extra_groups);
struct device *
+hwmon_device_register_for_thermal(struct device *dev, const char *name,
+ void *drvdata);
+struct device *
devm_hwmon_device_register_with_info(struct device *dev,
const char *name, void *drvdata,
const struct hwmon_chip_info *info,
--
2.37.0.rc0.161.g10f37bed90-goog

2022-06-29 23:52:37

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 4.19 v1 2/2] thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal()

On 6/29/22 15:58, Will McVicker wrote:
> From: Guenter Roeck <[email protected]>
>
> [ upstream commit 87743bcf08072b3e1952a0bf5524b2833e667b4c ]
>
> The thermal subsystem registers a hwmon device without providing chip
> information or sysfs attribute groups. While undesirable, it would be
> difficult to change. On the other side, it abuses the
> hwmon_device_register_with_info API by not providing that information.
> Use new API specifically created for the thermal subsystem instead to
> let us enforce the 'chip' parameter for other callers of
> hwmon_device_register_with_info().
>
> Acked-by: Rafael J . Wysocki <[email protected]>
> Signed-off-by: Guenter Roeck <[email protected]>

NACK. Same reason as 1/2.

Guenter

> ---
> drivers/thermal/thermal_hwmon.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
> index dd5d8ee37928..b3b229421936 100644
> --- a/drivers/thermal/thermal_hwmon.c
> +++ b/drivers/thermal/thermal_hwmon.c
> @@ -147,8 +147,8 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
> INIT_LIST_HEAD(&hwmon->tz_list);
> strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
> strreplace(hwmon->type, '-', '_');
> - hwmon->device = hwmon_device_register_with_info(&tz->device, hwmon->type,
> - hwmon, NULL, NULL);
> + hwmon->device = hwmon_device_register_for_thermal(&tz->device,
> + hwmon->type, hwmon);
> if (IS_ERR(hwmon->device)) {
> result = PTR_ERR(hwmon->device);
> goto free_mem;

2022-06-30 00:05:45

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 4.19 v1 1/2] hwmon: Introduce hwmon_device_register_for_thermal

On 6/29/22 15:58, Will McVicker wrote:
> From: Guenter Roeck <[email protected]>
>
> [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
>
> The thermal subsystem registers a hwmon driver without providing
> chip or sysfs group information. This is for legacy reasons and
> would be difficult to change. At the same time, we want to enforce
> that chip information is provided when registering a hwmon device
> using hwmon_device_register_with_info(). To enable this, introduce
> a special API for use only by the thermal subsystem.
>
> Acked-by: Rafael J . Wysocki <[email protected]>
> Signed-off-by: Guenter Roeck <[email protected]>

NACK. The patch introducing the problem needs to be reverted.

Guenter

> ---
> drivers/hwmon/hwmon.c | 25 +++++++++++++++++++++++++
> include/linux/hwmon.h | 3 +++
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index c4051a3e63c2..412a5e39fc14 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -725,6 +725,31 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
> }
> EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);
>
> +/**
> + * hwmon_device_register_for_thermal - register hwmon device for thermal subsystem
> + * @dev: the parent device
> + * @name: hwmon name attribute
> + * @drvdata: driver data to attach to created device
> + *
> + * The use of this function is restricted. It is provided for legacy reasons
> + * and must only be called from the thermal subsystem.
> + *
> + * hwmon_device_unregister() must be called when the device is no
> + * longer needed.
> + *
> + * Returns the pointer to the new device.
> + */
> +struct device *
> +hwmon_device_register_for_thermal(struct device *dev, const char *name,
> + void *drvdata)
> +{
> + if (!name || !dev)
> + return ERR_PTR(-EINVAL);
> +
> + return __hwmon_device_register(dev, name, drvdata, NULL, NULL);
> +}
> +EXPORT_SYMBOL_GPL(hwmon_device_register_for_thermal);
> +
> /**
> * hwmon_device_register - register w/ hwmon
> * @dev: the device to register
> diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
> index 8fde789f2eff..5ff3db6eb9f1 100644
> --- a/include/linux/hwmon.h
> +++ b/include/linux/hwmon.h
> @@ -390,6 +390,9 @@ hwmon_device_register_with_info(struct device *dev,
> const struct hwmon_chip_info *info,
> const struct attribute_group **extra_groups);
> struct device *
> +hwmon_device_register_for_thermal(struct device *dev, const char *name,
> + void *drvdata);
> +struct device *
> devm_hwmon_device_register_with_info(struct device *dev,
> const char *name, void *drvdata,
> const struct hwmon_chip_info *info,

2022-06-30 00:25:48

by William McVicker

[permalink] [raw]
Subject: Re: [PATCH 4.19 v1 1/2] hwmon: Introduce hwmon_device_register_for_thermal

On 06/29/2022, Guenter Roeck wrote:
> On 6/29/22 15:58, Will McVicker wrote:
> > From: Guenter Roeck <[email protected]>
> >
> > [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
> >
> > The thermal subsystem registers a hwmon driver without providing
> > chip or sysfs group information. This is for legacy reasons and
> > would be difficult to change. At the same time, we want to enforce
> > that chip information is provided when registering a hwmon device
> > using hwmon_device_register_with_info(). To enable this, introduce
> > a special API for use only by the thermal subsystem.
> >
> > Acked-by: Rafael J . Wysocki <[email protected]>
> > Signed-off-by: Guenter Roeck <[email protected]>
>
> NACK. The patch introducing the problem needs to be reverted.

I'm fine with that as well. I've already verified that fixes the issue. I'll go
ahead and send the revert.

Thanks,
Will

>
> Guenter
>
> > ---
> > drivers/hwmon/hwmon.c | 25 +++++++++++++++++++++++++
> > include/linux/hwmon.h | 3 +++
> > 2 files changed, 28 insertions(+)
> >
> > diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> > index c4051a3e63c2..412a5e39fc14 100644
> > --- a/drivers/hwmon/hwmon.c
> > +++ b/drivers/hwmon/hwmon.c
> > @@ -725,6 +725,31 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
> > }
> > EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);
> > +/**
> > + * hwmon_device_register_for_thermal - register hwmon device for thermal subsystem
> > + * @dev: the parent device
> > + * @name: hwmon name attribute
> > + * @drvdata: driver data to attach to created device
> > + *
> > + * The use of this function is restricted. It is provided for legacy reasons
> > + * and must only be called from the thermal subsystem.
> > + *
> > + * hwmon_device_unregister() must be called when the device is no
> > + * longer needed.
> > + *
> > + * Returns the pointer to the new device.
> > + */
> > +struct device *
> > +hwmon_device_register_for_thermal(struct device *dev, const char *name,
> > + void *drvdata)
> > +{
> > + if (!name || !dev)
> > + return ERR_PTR(-EINVAL);
> > +
> > + return __hwmon_device_register(dev, name, drvdata, NULL, NULL);
> > +}
> > +EXPORT_SYMBOL_GPL(hwmon_device_register_for_thermal);
> > +
> > /**
> > * hwmon_device_register - register w/ hwmon
> > * @dev: the device to register
> > diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
> > index 8fde789f2eff..5ff3db6eb9f1 100644
> > --- a/include/linux/hwmon.h
> > +++ b/include/linux/hwmon.h
> > @@ -390,6 +390,9 @@ hwmon_device_register_with_info(struct device *dev,
> > const struct hwmon_chip_info *info,
> > const struct attribute_group **extra_groups);
> > struct device *
> > +hwmon_device_register_for_thermal(struct device *dev, const char *name,
> > + void *drvdata);
> > +struct device *
> > devm_hwmon_device_register_with_info(struct device *dev,
> > const char *name, void *drvdata,
> > const struct hwmon_chip_info *info,
>

2022-06-30 03:04:39

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 4.19 v1 1/2] hwmon: Introduce hwmon_device_register_for_thermal

On 6/29/22 16:18, William McVicker wrote:
> On 06/29/2022, Guenter Roeck wrote:
>> On 6/29/22 15:58, Will McVicker wrote:
>>> From: Guenter Roeck <[email protected]>
>>>
>>> [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
>>>
>>> The thermal subsystem registers a hwmon driver without providing
>>> chip or sysfs group information. This is for legacy reasons and
>>> would be difficult to change. At the same time, we want to enforce
>>> that chip information is provided when registering a hwmon device
>>> using hwmon_device_register_with_info(). To enable this, introduce
>>> a special API for use only by the thermal subsystem.
>>>
>>> Acked-by: Rafael J . Wysocki <[email protected]>
>>> Signed-off-by: Guenter Roeck <[email protected]>
>>
>> NACK. The patch introducing the problem needs to be reverted.
>
> I'm fine with that as well. I've already verified that fixes the issue. I'll go
> ahead and send the revert.
>

My understanding is that it is already queued up.

Guenter

2022-06-30 06:58:26

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 4.19 v1 1/2] hwmon: Introduce hwmon_device_register_for_thermal

On Wed, Jun 29, 2022 at 07:31:10PM -0700, Guenter Roeck wrote:
> On 6/29/22 16:18, William McVicker wrote:
> > On 06/29/2022, Guenter Roeck wrote:
> > > On 6/29/22 15:58, Will McVicker wrote:
> > > > From: Guenter Roeck <[email protected]>
> > > >
> > > > [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
> > > >
> > > > The thermal subsystem registers a hwmon driver without providing
> > > > chip or sysfs group information. This is for legacy reasons and
> > > > would be difficult to change. At the same time, we want to enforce
> > > > that chip information is provided when registering a hwmon device
> > > > using hwmon_device_register_with_info(). To enable this, introduce
> > > > a special API for use only by the thermal subsystem.
> > > >
> > > > Acked-by: Rafael J . Wysocki <[email protected]>
> > > > Signed-off-by: Guenter Roeck <[email protected]>
> > >
> > > NACK. The patch introducing the problem needs to be reverted.
> >
> > I'm fine with that as well. I've already verified that fixes the issue. I'll go
> > ahead and send the revert.
> >
>
> My understanding is that it is already queued up.

Yes it is, sorry for the delay, will try to push out -rc releases later
today...

greg k-h