Re: [PATCH v2 00/17] thermal: enable+check sensor after its setup is finished

From: Zhang Rui
Date: Tue Nov 06 2018 - 02:35:24 EST


Hi, Bartlomiej,

On ä, 2018-11-05 at 17:35 +0100, Bartlomiej Zolnierkiewicz wrote:
> On 11/05/2018 04:04 AM, Zhang Rui wrote:
> >
> > Hi, Bartlomiej,
> Hi Rui,
>
> >
> > Interesting, I'm about to bring this issue to Linux Plumber
> > Conference
> > this year for discussion, and I'm also proposing a solution to fix
> > the
> > issues, but only with thermal core part finished yet.
> > can you please take a look at it?
> > https://patchwork.kernel.org/project/linux-pm/list/?series=38181
> Thank you for the patches but they seem to be far from being
> a complete solution for issues fixed by my patchset.

Right, as I said, this is a draft patch to illustrate my idea for those
issues. And it is not targeting for upstream.

> Even
> thermal core part is not finished yet as it doesn't provide
> a way to register disabled sensors for DT thermal drivers (only
> for platform ones)..

we need sequential change of of_thermal to set tzp->disable
inÂof_parse_thermal_zones.

>
> Why not simply apply my patchset now and incrementally work
> on top of it to implement fixes for issues your patchset is
> addressing?

The main concern is that, as you point out, we have too many private
mode implementation, and I'm looking for the possibility to handle them
in the thermal core framework.

>
> My patchset may not be a perfect solution but IMO it is good
> enough and it has been practically ready since v1 posted in
> April (v2 fixes all issues requested by Eduardo's review from
> September)..

I'm not against doing this, as long as it fixes something and doesn't
break the others.
But, I still have a couple of comments about your patches, and let me
comment in lines.

thanks,
rui
>
> >
> > thanks,
> > rui
> >
> > On ä, 2018-10-17 at 17:52 +0200, Bartlomiej Zolnierkiewicz wrote:
> > >
> > > Hi,
> > >
> > > [devm]_thermal_zone_of_sensor_register() is used to register
> > > thermal sensor by thermal drivers using DeviceTree. Besides
> > > registering sensor this function also immediately:
> > >
> > > - enables it:
> > >
> > > Â tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED)
> > > Â (->set_mode is set to of_thermal_set_mode() in of-thermal.c)
> > >
> > > - checks it (indirectly by using of_thermal_set_mode()):
> > >
> > > Â thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
> > > Â (which in turn ends up using ->get_temp method).
> > >
> > > For many DT thermal drivers this causes a problem because:
> > >
> > > - [devm]_thermal_zone_of_sensor_register() need to be called in
> > > Â order to obtain data about thermal trips which are then used to
> > > Â finish hardware sensor setup (only after which ->get_temp can
> > > Â be used)
> > >
> > > There is also related issue for DT thermal drivers that support
> > > IRQ (i.e. exynos and rockchip ones):
> > >
> > > - sensor hardware should be enabled only after IRQ handler is
> > > Â requested (because otherwise we might get IRQs that we can't
> > > Â handle)
> > >
> > > - IRQ handler needs tzd structure which is obtained from
> > > Â [devm_]thermal_zone_of_sensor_register()
> > >
> > > - after [devm_]thermal_zone_of_sensor_register() call core
> > > Â thermal code assumes that sensor is enabled and ready to use
> > > Â (i.e. that IRQ handler has been requested and sensor hardware
> > > Â has been enabled)
> > >
> > > In order to fix all abovementioned issues sensor registration,
> > > enable and check operations are separated in the core DT thermal
> > > code and corresponding DT thermal drivers are modified to do
> > > sensor
> > > setup correctly.
> > >
> > > Changes since v1:
> > > - rebased on the current -next kernel (next-20181015)
> > > - enhanced patch descriptions and cover letter
> > > - renamed thermal_zone_device_toggler() to
> > > thermal_zone_set_mode()
> > > - converted thermal_zone_set_mode() to use enum
> > > thermal_device_mode
> > > - added CONFIG_THERMAL=n stubs for thermal_zone_set_mode() and
> > > Â thermal_zone_device_check()
> > > - fixed uses of [devm]_thermal_zone_of_sensor_register() outside
> > > of
> > > Â drivers/thermal/
> > > - changed ordering between patch #2 and #3 in order to add all
> > > Â needed core helpers first before fixing sensor setup code
> > > - changed ordering between patch #3 and #4 in order to simplify
> > > them
> > > - renamed patch #3 to "thermal: separate sensor enable and check
> > > Â operations"
> > > - renamed patch #4 to "thermal: separate sensor registration and
> > > Â enable+check operations"
> > >
> > > Best regards,
> > > --
> > > Bartlomiej Zolnierkiewicz
> > > Samsung R&D Institute Poland
> > > Samsung Electronics
> > >
> > >
> > > Bartlomiej Zolnierkiewicz (17):
> > > Â thermal: add thermal_zone_set_mode() helper
> > > Â thermal: add thermal_zone_device_check() helper
> > > Â thermal: separate sensor enable and check operations
> > > Â thermal: separate sensor registration and enable+check
> > > operations
> > > Â thermal: bcm2835: enable+check sensor after its setup is
> > > finished
> > > Â thermal: brcmstb: enable+check sensor after its setup is
> > > finished
> > > Â thermal: hisi_thermal: enable+check sensor after its setup is
> > > finished
> > > Â thermal: qcom: tsens: enable+check sensor after its setup is
> > > finished
> > > Â thermal: qoriq: enable+check sensor after its setup is finished
> > > Â thermal: rcar_gen3_thermal: enable+check sensor after its setup
> > > is
> > > ÂÂÂÂfinished
> > > Â thermal: rockchip_thermal: enable+check sensor after its setup
> > > is
> > > ÂÂÂÂfinished
> > > Â thermal: exynos: enable+check sensor after its setup is
> > > finished
> > > Â thermal: tegra: enable+check sensor after its setup is finished
> > > Â thermal: ti-soc-thermal: enable+check sensor after its setup is
> > > ÂÂÂÂfinished
> > > Â thermal: uniphier: enable+check sensor after its setup is
> > > finished
> > > Â thermal: zx2967: enable+check sensor after its setup is
> > > finished
> > > Â thermal: warn on attempts to read temperature on disabled
> > > sensors
> > >
> > > Âdrivers/acpi/thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ5 +--
> > > Âdrivers/ata/ahci_imx.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 10 ++++--
> > > Âdrivers/hwmon/hwmon.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ5 +++
> > > Âdrivers/hwmon/ntc_thermistor.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ4 +++
> > > Âdrivers/hwmon/scpi-hwmon.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ4 +++
> > > Âdrivers/iio/adc/sun4i-gpadc-iio.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ5 +++
> > > Âdrivers/input/touchscreen/sun4i-ts.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ8 ++++-
> > > Âdrivers/net/ethernet/mellanox/mlxsw/core_thermal.c |ÂÂ1 -
> > > Âdrivers/platform/x86/acerhdf.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ6 +++-
> > > Âdrivers/regulator/max8973-regulator.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ6 ++--
> > > Âdrivers/thermal/armada_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/broadcom/bcm2835_thermal.cÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/broadcom/brcmstb_thermal.cÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/broadcom/ns-thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/da9062-thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ7 ++--
> > > Âdrivers/thermal/db8500_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ5 ++-
> > > Âdrivers/thermal/hisi_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 22 ++++--
> > > ----
> > > ---
> > > Âdrivers/thermal/imx_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 +-
> > > Âdrivers/thermal/int340x_thermal/int3400_thermal.cÂÂ|ÂÂ1 +
> > > Âdrivers/thermal/intel_bxt_pmic_thermal.cÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 +-
> > > Âdrivers/thermal/intel_soc_dts_iosf.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 +-
> > > Âdrivers/thermal/max77620_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ6 ++--
> > > Âdrivers/thermal/mtk_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/of-thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ6 ++--
> > > Âdrivers/thermal/qcom-spmi-temp-alarm.cÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ5 ++-
> > > Âdrivers/thermal/qcom/tsens.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ6 ++++
> > > Âdrivers/thermal/qoriq_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/rcar_gen3_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ7 ++--
> > > Âdrivers/thermal/rcar_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ7 ++--
> > > Âdrivers/thermal/rockchip_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 38
> > > +++++++++++-
> > > ----------
> > > Âdrivers/thermal/samsung/exynos_tmu.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ7 +++-
> > > Âdrivers/thermal/st/st_thermal_memmap.cÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 +-
> > > Âdrivers/thermal/tango_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ5 +++
> > > Âdrivers/thermal/tegra/soctherm.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/tegra/tegra-bpmp-thermal.cÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/thermal-generic-adc.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âdrivers/thermal/thermal_core.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 14 ++++----
> > > Âdrivers/thermal/thermal_helpers.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 32
> > > ++++++++++++++++++
> > > Âdrivers/thermal/thermal_sysfs.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 17 ++++++
> > > ----
> > > Âdrivers/thermal/ti-soc-thermal/ti-thermal-common.c |ÂÂ7 +++-
> > > Âdrivers/thermal/uniphier_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ6 +++-
> > > Âdrivers/thermal/x86_pkg_temp_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ2 +-
> > > Âdrivers/thermal/zx2967_thermal.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ3 ++
> > > Âinclude/linux/thermal.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 11 +++++++
> > > Â44 files changed, 220 insertions(+), 87 deletions(-)
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics