Re: [PATCH v4 4/7] drivers: thermal: tsens: Add critical interrupt support

From: Bjorn Andersson
Date: Mon Feb 03 2020 - 13:14:18 EST


On Thu 30 Jan 05:27 PST 2020, Amit Kucheria wrote:

> TSENS IP v2.x adds critical threshold interrupt support for each sensor
> in addition to the upper/lower threshold interrupt. Add support in the
> driver.
>
> While the critical interrupts themselves aren't currently used by Linux,
> the HW line is also used by the TSENS watchdog. So this patch acts as
> infrastructure to enable watchdog functionality for the TSENS IP.
>
> Signed-off-by: Amit Kucheria <amit.kucheria@xxxxxxxxxx>
> ---

Please do provide a changelog when respinning your patches.

> drivers/thermal/qcom/tsens-common.c | 120 ++++++++++++++++++++++++++--
> drivers/thermal/qcom/tsens-v2.c | 8 +-
> drivers/thermal/qcom/tsens.c | 24 +++++-
> drivers/thermal/qcom/tsens.h | 71 ++++++++++++++++
> 4 files changed, 212 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
[..]
> +irqreturn_t tsens_critical_irq_thread(int irq, void *data)
> +{
> + struct tsens_priv *priv = data;
> + struct tsens_irq_data d;
> + unsigned long flags;
> + int temp, ret, i;
> +
> + for (i = 0; i < priv->num_sensors; i++) {
> + const struct tsens_sensor *s = &priv->sensor[i];
> + u32 hw_id = s->hw_id;
> +
> + if (IS_ERR(s->tzd))
> + continue;
> + if (!tsens_threshold_violated(priv, hw_id, &d))
> + continue;
> + ret = get_temp_tsens_valid(s, &temp);
> + if (ret) {
> + dev_err(priv->dev, "[%u] %s: error reading sensor\n", hw_id, __func__);
> + continue;
> + }
> +
> + spin_lock_irqsave(&priv->crit_lock, flags);
> +

I see that I failed to follow up on the discussion on the previous
revision. The handler is called from a single thread, so you don't need
a lock to protect the irq handler from itself.

Regards,
Bjorn