All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amit Kucheria <amit.kucheria@linaro.org>
To: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	Eric Anholt <eric@anholt.net>,
	Stefan Wahren <stefan.wahren@i2se.com>,
	Markus Mayer <mmayer@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	Heiko Stuebner <heiko@sntech.de>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Keerthy <j-keerthy@ti.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Jun Nie <jun.nie@linaro.org>, Baoyou Xie <baoyou.xie@linaro.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Linux PM list <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 03/17] thermal: separate sensor enable and check operations
Date: Fri, 26 Oct 2018 17:41:14 +0530	[thread overview]
Message-ID: <CAHLCerNisNkLptW3sHaue_eR8siy3-6VGo=80A9svtYfmdoiTQ@mail.gmail.com> (raw)
In-Reply-To: <1539791563-5959-4-git-send-email-b.zolnierkie@samsung.com>

On Wed, Oct 17, 2018 at 9:23 PM Bartlomiej Zolnierkiewicz
<b.zolnierkie@samsung.com> wrote:
>
> [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 prepare for fixing all abovementioned issues separate
> sensor enable and check operations in the core thermal code and
> update thermal drivers accordingly:

The commit message on this patch and patch 4 are identical upto here.
Perhaps consider moving the actual difference in the commit message to
the top and post the TL;DR version below it?

> * Add set_mode_skip_check flag to struct thermal_zone_device_ops and
>   set it in drivers that don't check the thermal zone device in their
>   ->set_mode method implementations.
>
> * Move thermal_zone_device_check() from ->set_mode implementations to
>   the users of thermal_zone_set_mode() (only place which calls
>   ->set_mode). Modify mode_store() in thermal_sysfs.c accordingly.
>
> There should be no functional changes caused by this patch.
>
> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> ---
>  drivers/acpi/thermal.c                             |  2 ++
>  drivers/net/ethernet/mellanox/mlxsw/core_thermal.c |  2 --
>  drivers/platform/x86/acerhdf.c                     |  2 ++
>  drivers/thermal/db8500_thermal.c                   |  2 ++
>  drivers/thermal/hisi_thermal.c                     |  2 ++
>  drivers/thermal/imx_thermal.c                      |  2 --
>  drivers/thermal/int340x_thermal/int3400_thermal.c  |  1 +
>  drivers/thermal/of-thermal.c                       |  6 +++---
>  drivers/thermal/rockchip_thermal.c                 | 16 ++++++++++++----
>  drivers/thermal/thermal_sysfs.c                    |  3 +++
>  include/linux/thermal.h                            |  2 ++
>  11 files changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
> index b8b275e1..a7e3d9e 100644
> --- a/drivers/acpi/thermal.c
> +++ b/drivers/acpi/thermal.c
> @@ -879,6 +879,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
>         .get_crit_temp = thermal_get_crit_temp,
>         .get_trend = thermal_get_trend,
>         .notify = thermal_notify,
> +
> +       .set_mode_skip_check = true,
>  };
>
>  static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
> index b0afd36..5f4b3bd 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
> @@ -170,8 +170,6 @@ static int mlxsw_thermal_set_mode(struct thermal_zone_device *tzdev,
>
>         thermal->mode = mode;
>
> -       thermal_zone_device_check(tzdev);
> -
>         return 0;
>  }
>
> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
> index 5a2b93a..884fd83 100644
> --- a/drivers/platform/x86/acerhdf.c
> +++ b/drivers/platform/x86/acerhdf.c
> @@ -507,6 +507,8 @@ static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal,
>         .get_trip_hyst = acerhdf_get_trip_hyst,
>         .get_trip_temp = acerhdf_get_trip_temp,
>         .get_crit_temp = acerhdf_get_crit_temp,
> +
> +       .set_mode_skip_check = true,
>  };
>
>
> diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
> index ab66b2d7..c4d0fb1 100644
> --- a/drivers/thermal/db8500_thermal.c
> +++ b/drivers/thermal/db8500_thermal.c
> @@ -220,6 +220,8 @@ static int db8500_sys_get_crit_temp(struct thermal_zone_device *thermal,
>         .get_trip_type = db8500_sys_get_trip_type,
>         .get_trip_temp = db8500_sys_get_trip_temp,
>         .get_crit_temp = db8500_sys_get_crit_temp,
> +
> +       .set_mode_skip_check = true,
>  };
>
>  static void db8500_thermal_update_config(struct db8500_thermal_zone *pzone,
> diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
> index 63d4fc3..6151e55 100644
> --- a/drivers/thermal/hisi_thermal.c
> +++ b/drivers/thermal/hisi_thermal.c
> @@ -561,6 +561,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)
>         }
>
>         thermal_zone_set_mode((&data->sensor)->tzd, THERMAL_DEVICE_ENABLED);
> +       thermal_zone_device_check((&data->sensor)->tzd);
>
>         return 0;
>  }
> @@ -570,6 +571,7 @@ static int hisi_thermal_remove(struct platform_device *pdev)
>         struct hisi_thermal_data *data = platform_get_drvdata(pdev);
>
>         thermal_zone_set_mode((&data->sensor)->tzd, THERMAL_DEVICE_DISABLED);
> +       thermal_zone_device_check((&data->sensor)->tzd);
>
>         data->disable_sensor(data);
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 22f57ef..7abad6c 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -385,8 +385,6 @@ static int imx_set_mode(struct thermal_zone_device *tz,
>
>         data->mode = mode;
>
> -       thermal_zone_device_check(tz);
> -
>         return 0;
>  }
>
> diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
> index e26b01c..d1f0641 100644
> --- a/drivers/thermal/int340x_thermal/int3400_thermal.c
> +++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
> @@ -305,6 +305,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
>         if (priv->uuid_bitmap & 1 << INT3400_THERMAL_PASSIVE_1) {
>                 int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
>                 int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
> +               int3400_thermal_ops.set_mode_skip_check = true;
>         }
>         priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0,
>                                                 priv, &int3400_thermal_ops,
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index c422b08..f1dcb7d 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -272,8 +272,6 @@ static int of_thermal_set_mode(struct thermal_zone_device *tz,
>
>         data->mode = mode;
>
> -       thermal_zone_device_check(tz);
> -
>         return 0;
>  }
>
> @@ -496,9 +494,11 @@ struct thermal_zone_device *
>                 if (sensor_specs.np == sensor_np && id == sensor_id) {
>                         tzd = thermal_zone_of_add_sensor(child, sensor_np,
>                                                          data, ops);
> -                       if (!IS_ERR(tzd))
> +                       if (!IS_ERR(tzd)) {
>                                 thermal_zone_set_mode(tzd,
>                                                       THERMAL_DEVICE_ENABLED);
> +                               thermal_zone_device_check(tzd);
> +                       }

You add this here and then remove it in patch 4. I'm guessing this is
to help with git-bisect. But...

>                         of_node_put(sensor_specs.np);
>                         of_node_put(child);
> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> index 5640675..715f4cd 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -1281,9 +1281,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
>
>         thermal->chip->control(thermal->regs, true);
>
> -       for (i = 0; i < thermal->chip->chn_num; i++)
> +       for (i = 0; i < thermal->chip->chn_num; i++) {
>                 thermal_zone_set_mode((&thermal->sensors[i])->tzd,
>                                       THERMAL_DEVICE_ENABLED);
> +               thermal_zone_device_check((&thermal->sensors[i])->tzd);
> +       }

Similarly, most of patch 4 are about calling set_mode and device_check
after the registration across all drivers. So it seems to be that it
might be easier to just merge these two patches to make it easier to
understand what is happening.

>         platform_set_drvdata(pdev, thermal);
>
> @@ -1302,9 +1304,11 @@ static int rockchip_thermal_remove(struct platform_device *pdev)
>         struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev);
>         int i;
>
> -       for (i = 0; i < thermal->chip->chn_num; i++)
> +       for (i = 0; i < thermal->chip->chn_num; i++) {
>                 thermal_zone_set_mode((&thermal->sensors[i])->tzd,
>                                       THERMAL_DEVICE_DISABLED);
> +               thermal_zone_device_check((&thermal->sensors[i])->tzd);
> +       }
>
>         thermal->chip->control(thermal->regs, false);
>
> @@ -1320,9 +1324,11 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
>         struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev);
>         int i;
>
> -       for (i = 0; i < thermal->chip->chn_num; i++)
> +       for (i = 0; i < thermal->chip->chn_num; i++) {
>                 thermal_zone_set_mode((&thermal->sensors[i])->tzd,
>                                       THERMAL_DEVICE_DISABLED);
> +               thermal_zone_device_check((&thermal->sensors[i])->tzd);
> +       }
>
>         thermal->chip->control(thermal->regs, false);
>
> @@ -1372,9 +1378,11 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
>
>         thermal->chip->control(thermal->regs, true);
>
> -       for (i = 0; i < thermal->chip->chn_num; i++)
> +       for (i = 0; i < thermal->chip->chn_num; i++) {
>                 thermal_zone_set_mode((&thermal->sensors[i])->tzd,
>                                       THERMAL_DEVICE_ENABLED);
> +               thermal_zone_device_check((&thermal->sensors[i])->tzd);
> +       }
>
>         pinctrl_pm_select_default_state(dev);
>
> diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
> index 3b38fb9..ac39fb6 100644
> --- a/drivers/thermal/thermal_sysfs.c
> +++ b/drivers/thermal/thermal_sysfs.c
> @@ -85,6 +85,9 @@
>         if (result)
>                 return result;
>
> +       if (!tz->ops->set_mode_skip_check)
> +               thermal_zone_device_check(tz);
> +
>         return count;
>  }
>
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 3e325b3..92c460e 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -113,6 +113,8 @@ struct thermal_zone_device_ops {
>                           enum thermal_trend *);
>         int (*notify) (struct thermal_zone_device *, int,
>                        enum thermal_trip_type);
> +
> +       bool set_mode_skip_check;
>  };
>
>  struct thermal_cooling_device_ops {
> --
> 1.9.1
>

  reply	other threads:[~2018-10-26 12:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20181017155314epcas2p4a5aa24978b36354a2ccb2f9b0fb6f0f6@epcas2p4.samsung.com>
2018-10-17 15:52 ` [PATCH v2 00/17] thermal: enable+check sensor after its setup is finished Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155320epcas2p439b713149d94aa485b3c2ffba063ea03@epcas2p4.samsung.com>
2018-10-17 15:52     ` [PATCH v2 01/17] thermal: add thermal_zone_set_mode() helper Bartlomiej Zolnierkiewicz
2018-11-06  8:11       ` Zhang Rui
2018-11-06 16:11         ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155326epcas2p21d8b703f27fe54561a0f741fa7920dce@epcas2p2.samsung.com>
2018-10-17 15:52     ` [PATCH v2 02/17] thermal: add thermal_zone_device_check() helper Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155332epcas2p499ac9d53678d82a9984b3533e723a0dd@epcas2p4.samsung.com>
2018-10-17 15:52     ` [PATCH v2 03/17] thermal: separate sensor enable and check operations Bartlomiej Zolnierkiewicz
2018-10-26 12:11       ` Amit Kucheria [this message]
     [not found]   ` <CGME20181017155338epcas1p3a22cd0b22e757c3e51eb72ccee545478@epcas1p3.samsung.com>
2018-10-17 15:52     ` [PATCH v2 04/17] thermal: separate sensor registration and enable+check operations Bartlomiej Zolnierkiewicz
2018-10-31 12:40       ` Amit Kucheria
     [not found]   ` <CGME20181017155345epcas1p18dee37b9a46f2bf0b68aa3ded43f2717@epcas1p1.samsung.com>
2018-10-17 15:52     ` [PATCH v2 05/17] thermal: bcm2835: enable+check sensor after its setup is finished Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155351epcas1p171637911ef29cdec96dda648cfac51a5@epcas1p1.samsung.com>
2018-10-17 15:52     ` [PATCH v2 06/17] thermal: brcmstb: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155357epcas1p3900b1d3522c636fdee27ab9928c076e1@epcas1p3.samsung.com>
2018-10-17 15:52     ` [PATCH v2 07/17] thermal: hisi_thermal: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155403epcas2p1ed9777e96c6b2c77c2c5b67466be9843@epcas2p1.samsung.com>
2018-10-17 15:52     ` [PATCH v2 08/17] thermal: qcom: tsens: " Bartlomiej Zolnierkiewicz
2018-10-26 12:11       ` Amit Kucheria
2018-10-26 12:39         ` Amit Kucheria
     [not found]   ` <CGME20181017155409epcas2p41b5770668abdb4af99646841a3dd24ec@epcas2p4.samsung.com>
2018-10-17 15:52     ` [PATCH v2 09/17] thermal: qoriq: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155416epcas2p32f63571e9c06cd1aba2b40bcf23de8e1@epcas2p3.samsung.com>
2018-10-17 15:52     ` [PATCH v2 10/17] thermal: rcar_gen3_thermal: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155422epcas1p1644d897c62ceb36b57d33ecd4e3bc81c@epcas1p1.samsung.com>
2018-10-17 15:52     ` [PATCH v2 11/17] thermal: rockchip_thermal: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155428epcas2p1aca0b5e7b30b89db7be7026dfa740fc6@epcas2p1.samsung.com>
2018-10-17 15:52     ` [PATCH v2 12/17] thermal: exynos: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155434epcas1p33a6de1fda3c69cc966f954796a95a935@epcas1p3.samsung.com>
2018-10-17 15:52     ` [PATCH v2 13/17] thermal: tegra: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155440epcas1p12c33048a8c1c083496d1a8996591d884@epcas1p1.samsung.com>
2018-10-17 15:52     ` [PATCH v2 14/17] thermal: ti-soc-thermal: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155447epcas2p2db761f6575de357b65eb5e39b709fead@epcas2p2.samsung.com>
2018-10-17 15:52     ` [PATCH v2 15/17] thermal: uniphier: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155453epcas1p3be6976375c18583bcbebc7ff7853ae50@epcas1p3.samsung.com>
2018-10-17 15:52     ` [PATCH v2 16/17] thermal: zx2967: " Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20181017155459epcas1p470bd73f433cdbb0f7a11aa8d46212e4e@epcas1p4.samsung.com>
2018-10-17 15:52     ` [PATCH v2 17/17] thermal: warn on attempts to read temperature on disabled sensors Bartlomiej Zolnierkiewicz
     [not found]   ` <1541387097.2124.9.camel@intel.com>
2018-11-05 16:35     ` [PATCH v2 00/17] thermal: enable+check sensor after its setup is finished Bartlomiej Zolnierkiewicz
2018-11-06  0:46       ` Eduardo Valentin
2018-11-06  7:34       ` Zhang Rui

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='CAHLCerNisNkLptW3sHaue_eR8siy3-6VGo=80A9svtYfmdoiTQ@mail.gmail.com' \
    --to=amit.kucheria@linaro.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=baoyou.xie@linaro.org \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=edubezval@gmail.com \
    --cc=eric@anholt.net \
    --cc=heiko@sntech.de \
    --cc=j-keerthy@ti.com \
    --cc=jonathanh@nvidia.com \
    --cc=jun.nie@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mmayer@broadcom.com \
    --cc=rui.zhang@intel.com \
    --cc=shawnguo@kernel.org \
    --cc=stefan.wahren@i2se.com \
    --cc=thierry.reding@gmail.com \
    --cc=yamada.masahiro@socionext.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.