From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: rafael@kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@collabora.com
Subject: Re: [RFC PATCH 01/26] thermal: Introduce thermal_zone_device_register() and params structure
Date: Tue, 16 Jan 2024 10:58:04 +0100 [thread overview]
Message-ID: <33c7d36d-c2f5-477f-946a-6ad926a277d7@collabora.com> (raw)
In-Reply-To: <7417c498-2439-485d-9f78-fbb22f9ce393@linaro.org>
Il 15/01/24 13:39, Daniel Lezcano ha scritto:
> On 21/12/2023 13:48, AngeloGioacchino Del Regno wrote:
>> In preparation for extending the thermal zone devices to actually have
>> a name and disambiguation of thermal zone types/names, introduce a new
>> thermal_zone_device_params structure which holds all of the parameters
>> that are necessary to register a thermal zone device, then add a new
>> function thermal_zone_device_register().
>>
>> The latter takes as parameter the newly introduced structure and is
>> made to eventually replace all usages of the now deprecated function
>> thermal_zone_device_register_with_trips() and of
>> thermal_tripless_zone_device_register().
>>
>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>> ---
>> drivers/thermal/thermal_core.c | 27 +++++++++++++++++++++++++++
>> include/linux/thermal.h | 33 +++++++++++++++++++++++++++++++++
>> 2 files changed, 60 insertions(+)
>>
>> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
>> index e5434cdbf23b..6be508eb2d72 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -1235,6 +1235,8 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
>> * whether trip points have been crossed (0 for interrupt
>> * driven systems)
>> *
>> + * This function is deprecated. See thermal_zone_device_register().
>> + *
>> * This interface function adds a new thermal zone device (sensor) to
>> * /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the
>> * thermal cooling devices registered at the same time.
>> @@ -1409,6 +1411,7 @@ thermal_zone_device_register_with_trips(const char *type,
>> struct thermal_trip *t
>> }
>> EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips);
>> +/* This function is deprecated. See thermal_zone_device_register(). */
>> struct thermal_zone_device *thermal_tripless_zone_device_register(
>> const char *type,
>> void *devdata,
>> @@ -1420,6 +1423,30 @@ struct thermal_zone_device
>> *thermal_tripless_zone_device_register(
>> }
>> EXPORT_SYMBOL_GPL(thermal_tripless_zone_device_register);
>> +/**
>> + * thermal_zone_device_register() - register a new thermal zone device
>> + * @tzdp: Parameters of the new thermal zone device
>> + * See struct thermal_zone_device_register.
>> + *
>> + * This interface function adds a new thermal zone device (sensor) to
>> + * /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the
>> + * thermal cooling devices registered at the same time.
>> + * thermal_zone_device_unregister() must be called when the device is no
>> + * longer needed. The passive cooling depends on the .get_trend() return value.
>> + *
>> + * Return: a pointer to the created struct thermal_zone_device or an
>> + * in case of error, an ERR_PTR. Caller must check return value with
>> + * IS_ERR*() helpers.
>> + */
>> +struct thermal_zone_device *thermal_zone_device_register(struct
>> thermal_zone_device_params *tzdp)
>> +{
>> + return thermal_zone_device_register_with_trips(tzdp->type, tzdp->trips,
>> tzdp->num_trips,
>> + tzdp->mask, tzdp->devdata, tzdp->ops,
>> + &tzdp->tzp, tzdp->passive_delay,
>> + tzdp->polling_delay);
>> +}
>> +EXPORT_SYMBOL_GPL(thermal_zone_device_register);
>> +
>> void *thermal_zone_device_priv(struct thermal_zone_device *tzd)
>> {
>> return tzd->devdata;
>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>> index 98957bae08ff..c6ed33a7e468 100644
>> --- a/include/linux/thermal.h
>> +++ b/include/linux/thermal.h
>> @@ -258,6 +258,33 @@ struct thermal_zone_params {
>> int offset;
>> };
>> +/**
>> + * struct thermal_zone_device_params - parameters for a thermal zone device
>> + * @type: the thermal zone device type
>> + * @tzp: thermal zone platform parameters
>> + * @ops: standard thermal zone device callbacks
>> + * @devdata: private device data
>> + * @trips: a pointer to an array of thermal trips, if any
>> + * @num_trips: the number of trip points the thermal zone support
>> + * @mask: a bit string indicating the writeablility of trip points
>> + * @passive_delay: number of milliseconds to wait between polls when
>> + * performing passive cooling
>> + * @polling_delay: number of milliseconds to wait between polls when checking
>> + * whether trip points have been crossed (0 for interrupt
>> + * driven systems)
>> + */
>> +struct thermal_zone_device_params {
>> + const char *type;
>> + struct thermal_zone_params tzp;
>> + struct thermal_zone_device_ops *ops;
>> + void *devdata;
>> + struct thermal_trip *trips;
>> + int num_trips;
>> + int mask;
>> + int passive_delay;
>> + int polling_delay;
>> +};
>
> From my POV, this "struct thermal_zone_params" has been always a inadequate and
> catch-all structure. It will confuse with thermal_zone_device_params
>
> I suggest to cleanup a bit that by sorting the parameters in the right structures
> where the result could be something like:
>
> eg.
>
> struct thermal_zone_params {
>
> const char *type;
> struct thermal_zone_device_ops *ops;
> struct thermal_trip *trips;
> int num_trips;
>
> int passive_delay;
> int polling_delay;
>
> void *devdata;
> bool no_hwmon;
> };
>
> struct thermal_governor_ipa_params {
> u32 sustainable_power;
> s32 k_po;
> s32 k_pu;
> s32 k_i;
> s32 k_d;
> s32 integral_cutoff;
> int slope;
> int offset;
> };
>
> struct thermal_governor_params {
> char governor_name[THERMAL_NAME_LENGTH];
> union {
> struct thermal_governor_ipa_params ipa_params;
> };
> };
>
> struct thermal_zone_device_params {
> struct thermal_zone_params *tzp;
> struct thermal_governor_params *tgp;
> }
>
> No functional changes just code reorg, being a series to be submitted before the
> rest on these RFC changes (2->26)
>
Could work. It's true that thermal_zone_params is a catch-all structure, and it's
not really the best... but I also haven't checked how complex and/or how much time
would your proposed change take.
Shouldn't take much as far as I can foresee, but I really have to check a bit.
If I'm right as in it's not something huge, the next series will directly have
this stuff sorted - if not, I'll reach to you.
Cheers,
Angelo
>> /* Function declarations */
>> #ifdef CONFIG_THERMAL_OF
>> struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev,
>> int id, void *data,
>> @@ -310,6 +337,8 @@ struct thermal_zone_device
>> *thermal_tripless_zone_device_register(
>> struct thermal_zone_device_ops *ops,
>> const struct thermal_zone_params *tzp);
>> +struct thermal_zone_device *thermal_zone_device_register(struct
>> thermal_zone_device_params *tzdp);
>> +
>> void thermal_zone_device_unregister(struct thermal_zone_device *tz);
>> void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
>> @@ -372,6 +401,10 @@ static inline struct thermal_zone_device
>> *thermal_tripless_zone_device_register(
>> const struct thermal_zone_params *tzp)
>> { return ERR_PTR(-ENODEV); }
>> +static inline struct thermal_zone_device *thermal_zone_device_register(
>> + struct thermal_zone_device_params *tzdp)
>> +{ return ERR_PTR(-ENODEV); }
>> +
>> static inline void thermal_zone_device_unregister(struct thermal_zone_device *tz)
>> { }
>
next prev parent reply other threads:[~2024-01-16 9:58 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 12:47 [RFC PATCH 00/26] Add thermal zones names and new registration func AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 01/26] thermal: Introduce thermal_zone_device_register() and params structure AngeloGioacchino Del Regno
2024-01-15 12:39 ` Daniel Lezcano
2024-01-16 9:58 ` AngeloGioacchino Del Regno [this message]
2024-01-18 9:39 ` AngeloGioacchino Del Regno
2024-01-18 9:46 ` AngeloGioacchino Del Regno
2024-01-22 19:19 ` Daniel Lezcano
2024-01-23 10:58 ` AngeloGioacchino Del Regno
2024-01-22 19:19 ` Daniel Lezcano
2023-12-21 12:48 ` [RFC PATCH 02/26] thermal/of: Migrate to thermal_zone_device_register() AngeloGioacchino Del Regno
2024-01-15 17:17 ` Daniel Lezcano
2024-01-16 9:50 ` AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 03/26] platform/x86: acerhdf: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 04/26] ACPI: thermal: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 05/26] thermal/drivers/da9062: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 06/26] thermal/drivers/imx: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 07/26] thermal/drivers/rcar: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 08/26] thermal/drivers/st: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 09/26] thermal: intel: pch_thermal: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 10/26] thermal: intel: quark_dts: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 11/26] thermal: intel: soc_dts_iosf: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 12/26] thermal: intel: int340x: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 13/26] thermal: int340x: processor: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 14/26] thermal: intel: x86_pkg_temp: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 15/26] power: supply: core: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 16/26] thermal/drivers/armada: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 17/26] thermal/drivers/dove: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 18/26] thermal/drivers/kirkwood: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 19/26] thermal/drivers/spear: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 20/26] thermal/drivers/int340x: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 21/26] wifi: iwlwifi: mvm: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 22/26] cxgb4: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 23/26] mlxsw: core_thermal: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 24/26] fixup! power: supply: core: " AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 25/26] thermal: Remove tripless_zone_register and register_with_trips functions AngeloGioacchino Del Regno
2023-12-21 12:48 ` [RFC PATCH 26/26] thermal: Introduce thermal zones names AngeloGioacchino Del Regno
2024-01-16 9:14 ` Daniel Lezcano
2024-01-16 9:45 ` AngeloGioacchino Del Regno
2024-01-16 11:30 ` Daniel Lezcano
2024-01-16 11:37 ` AngeloGioacchino Del Regno
2023-12-21 13:38 ` [RFC PATCH 00/26] Add thermal zones names and new registration func Rafael J. Wysocki
2023-12-21 13:54 ` AngeloGioacchino Del Regno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=33c7d36d-c2f5-477f-946a-6ad926a277d7@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=daniel.lezcano@linaro.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox