linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "thermal: rockchip: fix up the tsadc pinctrl setting error"
@ 2019-05-22 14:12 Heiko Stuebner
  2019-05-22 15:34 ` Doug Anderson
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Stuebner @ 2019-05-22 14:12 UTC (permalink / raw)
  To: edubezval, rui.zhang
  Cc: daniel.lezcano, linux-pm, linux-rockchip, linux-kernel,
	zhangqing, eballetbo, Heiko Stuebner

This reverts commit 28694e009e512451ead5519dd801f9869acb1f60.

The commit causes multiple issues in that:
- the added call to ->control does potentially run unclocked
  causing a hang of the machine
- the added pinctrl-states are undocumented in the binding
- the added pinctrl-states are not backwards compatible, breaking
  old devicetrees.

Fixes: 28694e009e51 ("thermal: rockchip: fix up the tsadc pinctrl setting error")
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/thermal/rockchip_thermal.c | 36 +++---------------------------
 1 file changed, 3 insertions(+), 33 deletions(-)

diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index bda1ca199abd..7ef9c7efe950 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -172,9 +172,6 @@ struct rockchip_thermal_data {
 	int tshut_temp;
 	enum tshut_mode tshut_mode;
 	enum tshut_polarity tshut_polarity;
-	struct pinctrl *pinctrl;
-	struct pinctrl_state *gpio_state;
-	struct pinctrl_state *otp_state;
 };
 
 /**
@@ -1283,8 +1280,6 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
 		return error;
 	}
 
-	thermal->chip->control(thermal->regs, false);
-
 	error = clk_prepare_enable(thermal->clk);
 	if (error) {
 		dev_err(&pdev->dev, "failed to enable converter clock: %d\n",
@@ -1310,30 +1305,6 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
 	thermal->chip->initialize(thermal->grf, thermal->regs,
 				  thermal->tshut_polarity);
 
-	if (thermal->tshut_mode == TSHUT_MODE_GPIO) {
-		thermal->pinctrl = devm_pinctrl_get(&pdev->dev);
-		if (IS_ERR(thermal->pinctrl)) {
-			dev_err(&pdev->dev, "failed to find thermal pinctrl\n");
-			return PTR_ERR(thermal->pinctrl);
-		}
-
-		thermal->gpio_state = pinctrl_lookup_state(thermal->pinctrl,
-							   "gpio");
-		if (IS_ERR_OR_NULL(thermal->gpio_state)) {
-			dev_err(&pdev->dev, "failed to find thermal gpio state\n");
-			return -EINVAL;
-		}
-
-		thermal->otp_state = pinctrl_lookup_state(thermal->pinctrl,
-							  "otpout");
-		if (IS_ERR_OR_NULL(thermal->otp_state)) {
-			dev_err(&pdev->dev, "failed to find thermal otpout state\n");
-			return -EINVAL;
-		}
-
-		pinctrl_select_state(thermal->pinctrl, thermal->otp_state);
-	}
-
 	for (i = 0; i < thermal->chip->chn_num; i++) {
 		error = rockchip_thermal_register_sensor(pdev, thermal,
 						&thermal->sensors[i],
@@ -1404,8 +1375,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
 
 	clk_disable(thermal->pclk);
 	clk_disable(thermal->clk);
-	if (thermal->tshut_mode == TSHUT_MODE_GPIO)
-		pinctrl_select_state(thermal->pinctrl, thermal->gpio_state);
+
+	pinctrl_pm_select_sleep_state(dev);
 
 	return 0;
 }
@@ -1450,8 +1421,7 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
 	for (i = 0; i < thermal->chip->chn_num; i++)
 		rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
 
-	if (thermal->tshut_mode == TSHUT_MODE_GPIO)
-		pinctrl_select_state(thermal->pinctrl, thermal->otp_state);
+	pinctrl_pm_select_default_state(dev);
 
 	return 0;
 }
-- 
2.20.1


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

* Re: [PATCH] Revert "thermal: rockchip: fix up the tsadc pinctrl setting error"
  2019-05-22 14:12 [PATCH] Revert "thermal: rockchip: fix up the tsadc pinctrl setting error" Heiko Stuebner
@ 2019-05-22 15:34 ` Doug Anderson
  2019-05-24  2:20   ` Eduardo Valentin
  0 siblings, 1 reply; 4+ messages in thread
From: Doug Anderson @ 2019-05-22 15:34 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: Eduardo Valentin, Zhang Rui, Daniel Lezcano, Linux PM,
	open list:ARM/Rockchip SoC...,
	LKML, zhangqing, Enric Balletbo Serra, Brian Norris,
	Matthias Kaehlcke

Hi,

On Wed, May 22, 2019 at 7:12 AM Heiko Stuebner <heiko@sntech.de> wrote:
>
> This reverts commit 28694e009e512451ead5519dd801f9869acb1f60.
>
> The commit causes multiple issues in that:
> - the added call to ->control does potentially run unclocked
>   causing a hang of the machine
> - the added pinctrl-states are undocumented in the binding
> - the added pinctrl-states are not backwards compatible, breaking
>   old devicetrees.
>
> Fixes: 28694e009e51 ("thermal: rockchip: fix up the tsadc pinctrl setting error")
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  drivers/thermal/rockchip_thermal.c | 36 +++---------------------------
>  1 file changed, 3 insertions(+), 33 deletions(-)

In case it helps with the urgency, there are lots of people who have
all independently needed to identify which commit stopped their boards
from booting mainline or broke temperature reading.  I'm aware of at
least these reports:

Reported-by: kernelci.org bot <bot@kernelci.org>
Reported-by: Enric Balletbo Serra <eballetbo@gmail.com>
Reported-by: Vicente Bergas <vicencb@gmail.com>
Reported-by: Jack Mitchell <ml@embed.me.uk>
Reported-by: Douglas Anderson <dianders@chromium.org>

I can confirm that my board boots again after this revert, thus:

Tested-by: Douglas Anderson <dianders@chromium.org>

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

* Re: [PATCH] Revert "thermal: rockchip: fix up the tsadc pinctrl setting error"
  2019-05-22 15:34 ` Doug Anderson
@ 2019-05-24  2:20   ` Eduardo Valentin
  2019-05-24  6:32     ` Heiko Stuebner
  0 siblings, 1 reply; 4+ messages in thread
From: Eduardo Valentin @ 2019-05-24  2:20 UTC (permalink / raw)
  To: Doug Anderson, Elaine Zhang
  Cc: Heiko Stuebner, Zhang Rui, Daniel Lezcano, Linux PM,
	open list:ARM/Rockchip SoC...,
	LKML, zhangqing, Enric Balletbo Serra, Brian Norris,
	Matthias Kaehlcke

On Wed, May 22, 2019 at 08:34:34AM -0700, Doug Anderson wrote:
> Hi,
> 
> On Wed, May 22, 2019 at 7:12 AM Heiko Stuebner <heiko@sntech.de> wrote:
> >
> > This reverts commit 28694e009e512451ead5519dd801f9869acb1f60.
> >
> > The commit causes multiple issues in that:
> > - the added call to ->control does potentially run unclocked
> >   causing a hang of the machine
> > - the added pinctrl-states are undocumented in the binding
> > - the added pinctrl-states are not backwards compatible, breaking
> >   old devicetrees.
> >
> > Fixes: 28694e009e51 ("thermal: rockchip: fix up the tsadc pinctrl setting error")
> > Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> > ---
> >  drivers/thermal/rockchip_thermal.c | 36 +++---------------------------
> >  1 file changed, 3 insertions(+), 33 deletions(-)
> 
> In case it helps with the urgency, there are lots of people who have
> all independently needed to identify which commit stopped their boards
> from booting mainline or broke temperature reading.  I'm aware of at
> least these reports:
> 
> Reported-by: kernelci.org bot <bot@kernelci.org>
> Reported-by: Enric Balletbo Serra <eballetbo@gmail.com>
> Reported-by: Vicente Bergas <vicencb@gmail.com>
> Reported-by: Jack Mitchell <ml@embed.me.uk>
> Reported-by: Douglas Anderson <dianders@chromium.org>
> 
> I can confirm that my board boots again after this revert, thus:
> 
> Tested-by: Douglas Anderson <dianders@chromium.org>

I see. I can collect this revert if that is what unblocks you guys.

Elaine, do you mind checking why these pinctrl changes are causing
boot issues?



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

* Re: [PATCH] Revert "thermal: rockchip: fix up the tsadc pinctrl setting error"
  2019-05-24  2:20   ` Eduardo Valentin
@ 2019-05-24  6:32     ` Heiko Stuebner
  0 siblings, 0 replies; 4+ messages in thread
From: Heiko Stuebner @ 2019-05-24  6:32 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Doug Anderson, Elaine Zhang, Zhang Rui, Daniel Lezcano, Linux PM,
	open list:ARM/Rockchip SoC...,
	LKML, Enric Balletbo Serra, Brian Norris, Matthias Kaehlcke

Am Freitag, 24. Mai 2019, 04:20:43 CEST schrieb Eduardo Valentin:
> On Wed, May 22, 2019 at 08:34:34AM -0700, Doug Anderson wrote:
> > Hi,
> > 
> > On Wed, May 22, 2019 at 7:12 AM Heiko Stuebner <heiko@sntech.de> wrote:
> > >
> > > This reverts commit 28694e009e512451ead5519dd801f9869acb1f60.
> > >
> > > The commit causes multiple issues in that:
> > > - the added call to ->control does potentially run unclocked
> > >   causing a hang of the machine
> > > - the added pinctrl-states are undocumented in the binding
> > > - the added pinctrl-states are not backwards compatible, breaking
> > >   old devicetrees.
> > >
> > > Fixes: 28694e009e51 ("thermal: rockchip: fix up the tsadc pinctrl setting error")
> > > Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> > > ---
> > >  drivers/thermal/rockchip_thermal.c | 36 +++---------------------------
> > >  1 file changed, 3 insertions(+), 33 deletions(-)
> > 
> > In case it helps with the urgency, there are lots of people who have
> > all independently needed to identify which commit stopped their boards
> > from booting mainline or broke temperature reading.  I'm aware of at
> > least these reports:
> > 
> > Reported-by: kernelci.org bot <bot@kernelci.org>
> > Reported-by: Enric Balletbo Serra <eballetbo@gmail.com>
> > Reported-by: Vicente Bergas <vicencb@gmail.com>
> > Reported-by: Jack Mitchell <ml@embed.me.uk>
> > Reported-by: Douglas Anderson <dianders@chromium.org>
> > 
> > I can confirm that my board boots again after this revert, thus:
> > 
> > Tested-by: Douglas Anderson <dianders@chromium.org>
> 
> I see. I can collect this revert if that is what unblocks you guys.
>
> Elaine, do you mind checking why these pinctrl changes are causing
> boot issues?

The pinctrl issue is secondary, it makes the thermal driver fail to
probe, due to not handling existing devicetrees properly.
Hence the driver needs to stay backwards compatible with existing
devicetrees.

The hang is caused by the call to the per-soc ->control callback before
the clocks get enabled, relying on it being on at boot and that isn't the
case everywhere.

Heiko



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

end of thread, other threads:[~2019-05-24  6:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 14:12 [PATCH] Revert "thermal: rockchip: fix up the tsadc pinctrl setting error" Heiko Stuebner
2019-05-22 15:34 ` Doug Anderson
2019-05-24  2:20   ` Eduardo Valentin
2019-05-24  6:32     ` Heiko Stuebner

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).