From: Stephen Boyd <swboyd@chromium.org>
To: Amit Kucheria <amit.kucheria@linaro.org>,
Andy Gross <agross@kernel.org>,
bjorn.andersson@linaro.org, edubezval@gmail.com,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
sivaa@codeaurora.org
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
Amit Kucheria <amit.kucheria@verdurent.com>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH 1/3] drivers: thermal: tsens: Add critical interrupt support
Date: Thu, 14 Nov 2019 14:50:17 -0800 [thread overview]
Message-ID: <5dcdda2a.1c69fb81.27852.ac35@mx.google.com> (raw)
In-Reply-To: <4b949a4f401a7f9d403ed0f0c16c7feb083f3524.1573499020.git.amit.kucheria@linaro.org>
Quoting Amit Kucheria (2019-11-11 11:21:27)
> diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
> index 4359a4247ac3..2989cb952cdb 100644
> --- a/drivers/thermal/qcom/tsens-common.c
> +++ b/drivers/thermal/qcom/tsens-common.c
> @@ -321,6 +357,65 @@ static inline u32 masked_irq(u32 hw_id, u32 mask, enum tsens_ver ver)
> return 0;
> }
>
> +/**
> + * tsens_critical_irq_thread - Threaded interrupt handler for critical interrupts
> + * @irq: irq number
> + * @data: tsens controller private data
> + *
> + * Check all sensors to find ones that violated their critical threshold limits.
> + * Clear and then re-enable the interrupt.
> + *
> + * The level-triggered interrupt might deassert if the temperature returned to
> + * within the threshold limits by the time the handler got scheduled. We
> + * consider the irq to have been handled in that case.
> + *
> + * Return: IRQ_HANDLED
> + */
> +irqreturn_t tsens_critical_irq_thread(int irq, void *data)
> +{
> + struct tsens_priv *priv = data;
> + struct tsens_irq_data d;
> + bool enable = true, disable = false;
Why not just use true and false in the one place these variables are
used?
> + unsigned long flags;
> + int temp, ret, i;
> +
> + for (i = 0; i < priv->num_sensors; i++) {
> + struct tsens_sensor *s = &priv->sensor[i];
Maybe make this const?
> + u32 hw_id = s->hw_id;
> +
> + if (IS_ERR(priv->sensor[i].tzd))
IS_ERR(s->tzd)?
> + continue;
> + if (!tsens_threshold_violated(priv, hw_id, &d))
> + continue;
> + ret = get_temp_tsens_valid(s, &temp);
Can this accept a const 's'?
> + if (ret) {
> + dev_err(priv->dev, "[%u] %s: error reading sensor\n", hw_id, __func__);
> + continue;
> + }
> +
> + spin_lock_irqsave(&priv->ul_lock, flags);
> +
> + tsens_read_irq_state(priv, hw_id, s, &d);
> +
> + if (d.crit_viol &&
> + !masked_irq(hw_id, d.crit_irq_mask, tsens_version(priv))) {
> + tsens_set_interrupt(priv, hw_id, CRITICAL, disable);
> + if (d.crit_thresh > temp) {
> + dev_dbg(priv->dev, "[%u] %s: re-arm upper\n",
> + priv->sensor[i].hw_id, __func__);
hw_id instead of priv->sensor...?
> + } else {
> + dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n",
> + hw_id, __func__, temp);
> + }
> + tsens_set_interrupt(priv, hw_id, CRITICAL, enable);
> + }
> +
> + spin_unlock_irqrestore(&priv->crit_lock, flags);
> + }
> +
> + return IRQ_HANDLED;
> +}
> +
> /**
> * tsens_irq_thread - Threaded interrupt handler for uplow interrupts
> * @irq: irq number
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 7d317660211e..784c4976c4f9 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -121,6 +121,27 @@ static int tsens_register(struct tsens_priv *priv)
>
> enable_irq_wake(irq);
>
> + if (tsens_version(priv) > VER_1_X) {
> + irq = platform_get_irq_byname(pdev, "critical");
> + if (irq < 0) {
> + ret = irq;
> + goto err_put_device;
> + }
> +
> + ret = devm_request_threaded_irq(&pdev->dev, irq,
> + NULL, tsens_critical_irq_thread,
> + IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> + dev_name(&pdev->dev), priv);
> + if (ret) {
> + dev_err(&pdev->dev, "%s: failed to get critical irq\n", __func__);
> + goto err_put_device;
Do we need to disable_irq_wake() for the previous irq here?
> + }
> +
> + enable_irq_wake(irq);
> + }
> +
> + return 0;
> +
> err_put_device:
> put_device(&pdev->dev);
> return ret;
next prev parent reply other threads:[~2019-11-14 22:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-11 19:21 [PATCH 0/3] thermal: tsens: Handle critical interrupts Amit Kucheria
2019-11-11 19:21 ` [PATCH 1/3] drivers: thermal: tsens: Add critical interrupt support Amit Kucheria
2019-11-12 19:38 ` Bjorn Andersson
2019-11-28 18:46 ` Amit Kucheria
2019-11-28 21:43 ` Bjorn Andersson
2019-12-03 5:02 ` Amit Kucheria
2019-11-14 22:50 ` Stephen Boyd [this message]
2019-12-03 4:57 ` Amit Kucheria
2019-11-11 19:21 ` [PATCH 2/3] drivers: thermal: tsens: Add watchdog support Amit Kucheria
2019-11-12 19:22 ` Bjorn Andersson
2019-11-28 19:18 ` Amit Kucheria
2019-11-14 22:38 ` Stephen Boyd
2019-11-28 19:16 ` Amit Kucheria
2019-11-11 19:21 ` [PATCH 3/3] arm64: dts: sdm845: thermal: Add critical interrupt support Amit Kucheria
2019-11-12 19:43 ` Bjorn Andersson
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=5dcdda2a.1c69fb81.27852.ac35@mx.google.com \
--to=swboyd@chromium.org \
--cc=agross@kernel.org \
--cc=amit.kucheria@linaro.org \
--cc=amit.kucheria@verdurent.com \
--cc=bjorn.andersson@linaro.org \
--cc=daniel.lezcano@linaro.org \
--cc=edubezval@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sivaa@codeaurora.org \
/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;
as well as URLs for NNTP newsgroup(s).