linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v4 02/11] thermal: Store thermal mode in a dedicated enum
@ 2020-05-29 15:05 Guenter Roeck
  2020-05-29 15:08 ` Andrzej Pietrasiewicz
  0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2020-05-29 15:05 UTC (permalink / raw)
  To: Andrzej Pietrasiewicz
  Cc: linux-pm, linux-acpi, netdev, linux-wireless,
	platform-driver-x86, linux-arm-kernel, linux-renesas-soc,
	linux-rockchip, Emmanuel Grumbach, Heiko Stuebner,
	Rafael J . Wysocki, Vishal Kulkarni, Luca Coelho, Miquel Raynal,
	kernel, Fabio Estevam, Amit Kucheria, Chunyan Zhang,
	Daniel Lezcano, Allison Randal, NXP Linux Team, Darren Hart,
	Zhang Rui, Gayatri Kammela, Len Brown, Johannes Berg,
	Intel Linux Wireless, Sascha Hauer, Ido Schimmel, Baolin Wang,
	Jiri Pirko, Orson Zhai, Thomas Gleixner, Kalle Valo,
	Support Opensource, Enrico Weigelt, Peter Kaestle,
	Sebastian Reichel, Bartlomiej Zolnierkiewicz,
	Pengutronix Kernel Team, Niklas Söderlund, Shawn Guo,
	David S . Miller, Andy Shevchenko

On Thu, May 28, 2020 at 09:20:42PM +0200, Andrzej Pietrasiewicz wrote:
> Prepare for storing mode in struct thermal_zone_device.
> 
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>

What is the baseline for this series ? I can't get this patch to apply
on top of current mainline, nor on v5.6, nor on top of linux-next.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <Message-ID: <4493c0e4-51aa-3907-810c-74949ff27ca4@samsung.com>]
* Re: [RFC v3 1/2] thermal: core: Let thermal zone device's mode be stored in its struct
@ 2020-05-27 13:30 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2020-05-27 13:30 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Andrzej Pietrasiewicz, linux-pm, Zhang Rui, Rafael J . Wysocki,
	Len Brown, Jiri Pirko, Ido Schimmel, David S . Miller,
	Peter Kaestle, Darren Hart, Andy Shevchenko, Support Opensource,
	Amit Kucheria, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Allison Randal, Enrico Weigelt,
	Gayatri Kammela, Thomas Gleixner, linux-acpi, netdev,
	platform-driver-x86, linux-arm-kernel, kernel


Hi Daniel,

On 5/23/20 11:24 PM, Daniel Lezcano wrote:
> Hi Andrzej,
> 
> On 17/04/2020 18:20, Andrzej Pietrasiewicz wrote:
>> Thermal zone devices' mode is stored in individual drivers. This patch
>> changes it so that mode is stored in struct thermal_zone_device instead.
>>
>> As a result all driver-specific variables storing the mode are not needed
>> and are removed. Consequently, the get_mode() implementations have nothing
>> to operate on and need to be removed, too.
>>
>> Some thermal framework specific functions are introduced:
>>
>> thermal_zone_device_get_mode()
>> thermal_zone_device_set_mode()
>> thermal_zone_device_enable()
>> thermal_zone_device_disable()
>>
>> thermal_zone_device_get_mode() and its "set" counterpart take tzd's lock
>> and the "set" calls driver's set_mode() if provided, so the latter must
>> not take this lock again. At the end of the "set"
>> thermal_zone_device_update() is called so drivers don't need to repeat this
>> invocation in their specific set_mode() implementations.
>>
>> The scope of the above 4 functions is purposedly limited to the thermal
>> framework and drivers are not supposed to call them. This encapsulation
>> does not fully work at the moment for some drivers, though:
>>
>> - platform/x86/acerhdf.c
>> - drivers/thermal/imx_thermal.c
>> - drivers/thermal/intel/intel_quark_dts_thermal.c
>> - drivers/thermal/of-thermal.c
>>
>> and they manipulate struct thermal_zone_device's members directly.
>>
>> struct thermal_zone_params gains a new member called initial_mode, which
>> is used to set tzd's mode at registration time.
>>
>> The sysfs "mode" attribute is always exposed from now on, because all
>> thermal zone devices now have their get_mode() implemented at the generic
>> level and it is always available. Exposing "mode" doesn't hurt the drivers
>> which don't provide their own set_mode(), because writing to "mode" will
>> result in -EPERM, as expected.
> 
> The result is great, that is a nice cleanup of the thermal framework.
> 
> After review it appears there are still problems IMO, especially with
> the suspend / resume path. The patch is big, it is a bit complex to
> comment. I suggest to re-org the changes as following:

There are still issues with the related existing thermal code but this
patch seems to be a step in the right direction.

For the latest version posted ("v3" one, your mail was replied to the
older "RFC v3" one):

https://lore.kernel.org/linux-pm/20200423165705.13585-2-andrzej.p@collabora.com/

I couldn't find the problems with the patch itself (no new issues
being introduced, all changes seem to be improvements over the current
situation).

Also the patch is not small but it also not that big and it mostly
removes the code:

17 files changed, 105 insertions(+), 244 deletions(-)

I worry that since the original code is intertwined in the interesting
ways the cost of work on splitting the patch on smaller changes may be
higher than its benefits.

>  - patch 1 : Add the four functions:
> 
>  * thermal_zone_device_set_mode()
>  * thermal_zone_device_enable()
>  * thermal_zone_device_disable()
>  * thermal_zone_device_is_enabled()
> 
> *but* do not export thermal_zone_device_set_mode(), it must stay private
> to the thermal framework ATM.
> 
>  - patch 2 : Add the mode THERMAL_DEVICE_SUSPENDED
> 
> In the thermal_pm_notify() in the:
> 
>  - PM_SUSPEND_PREPARE case, set the mode to THERMAL_DEVICE_SUSPENDED if
> the mode is THERMAL_DEVICE_ENABLED
> 
>  - PM_POST_SUSPEND case, set the mode to THERMAL_DEVICE_ENABLED, if the
> mode is THERMAL_DEVICE_SUSPENDED
> 
>  - patch 3 : Change the monitor function
> 
> Change monitor_thermal_zone() function to set the polling to zero if the
> mode is THERMAL_DEVICE_DISABLED
> 
>  - patch 4 : Do the changes to remove get_mode() ops
> 
> Make sure there is no access to tz->mode from the drivers anymore but
> use of the functions of patch 1. IMO, this is the tricky part because a
> part of the drivers are not calling the update after setting the mode
> while the function thermal_zone_device_enable()/disable() call update
> via the thermal_zone_device_set_mode(), so we must be sure to not break
> anything.
> 
>  - patch 5 : Do the changes to remove set_mode() ops users
> 
> As the patch 3 sets the polling to zero, the routine in the driver
> setting the polling to zero is no longer needed (eg. in the mellanox
> driver). I expect int300 to be the last user of this ops, hopefully we
> can find a way to get rid of the specific call done inside and then
> remove the ops.
> 
> The initial_mode approach looks hackish, I suggest to make the default
> the thermal zone disabled after creating and then explicitly enable it.
> Note that is what do a lot of drivers already.
> 
> Hopefully, these changes are git-bisect safe.
> 
> Does it make sense ?

Besides the requirement to split the patch it seems that the above
list contains a lot of problematic areas with the existing thermal
code yet to be addressed..

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-06-24  9:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29 15:05 [PATCH v4 02/11] thermal: Store thermal mode in a dedicated enum Guenter Roeck
2020-05-29 15:08 ` Andrzej Pietrasiewicz
2020-05-29 15:30   ` Guenter Roeck
     [not found] <Message-ID: <4493c0e4-51aa-3907-810c-74949ff27ca4@samsung.com>
2020-05-28 19:20 ` [PATCH v4 00/11] Stop monitoring disabled devices Andrzej Pietrasiewicz
2020-05-28 19:20   ` [PATCH v4 02/11] thermal: Store thermal mode in a dedicated enum Andrzej Pietrasiewicz
2020-05-29 14:48     ` Guenter Roeck
2020-05-29 15:13       ` Andrzej Pietrasiewicz
2020-05-29 15:34         ` Guenter Roeck
2020-06-24  9:38     ` Bartlomiej Zolnierkiewicz
2020-06-01 11:36   ` Peter Kästle
  -- strict thread matches above, loose matches on Subject: below --
2020-05-27 13:30 [RFC v3 1/2] thermal: core: Let thermal zone device's mode be stored in its struct Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).