Re: [PATCH v4 5/7] drivers: thermal: tsens: Add watchdog support

From: Amit Kucheria
Date: Tue Feb 18 2020 - 13:08:14 EST


On Tue, Feb 4, 2020 at 12:12 AM Bjorn Andersson
<bjorn.andersson@xxxxxxxxxx> wrote:
>
> On Thu 30 Jan 05:27 PST 2020, Amit Kucheria wrote:
>
> > TSENS IP v2.3 onwards adds support for a watchdog to detect if the TSENS
> > HW FSM is stuck. Add support to detect and restart the FSM in the
> > driver. The watchdog is configured by the bootloader, we just enable the
> > watchdog bark as a debug feature in the kernel.
> >
> > Signed-off-by: Amit Kucheria <amit.kucheria@xxxxxxxxxx>
> > ---
> > drivers/thermal/qcom/tsens-common.c | 43 +++++++++++++++++++++++++++++
> > drivers/thermal/qcom/tsens-v2.c | 10 +++++++
> > drivers/thermal/qcom/tsens.h | 14 ++++++++++
> > 3 files changed, 67 insertions(+)
> >
> > diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
> > index 9d1594d2f1ed..ee2414f33606 100644
> > --- a/drivers/thermal/qcom/tsens-common.c
> > +++ b/drivers/thermal/qcom/tsens-common.c
> > @@ -377,6 +377,26 @@ irqreturn_t tsens_critical_irq_thread(int irq, void *data)
> > struct tsens_irq_data d;
> > unsigned long flags;
> > int temp, ret, i;
> > + u32 wdog_status, wdog_count;
> > +
> > + if (priv->feat->has_watchdog) {
> > + ret = regmap_field_read(priv->rf[WDOG_BARK_STATUS], &wdog_status);
> > + if (ret)
> > + return ret;
> > +
> > + if (wdog_status) {
> > + /* Clear WDOG interrupt */
> > + regmap_field_write(priv->rf[WDOG_BARK_CLEAR], 1);
> > + regmap_field_write(priv->rf[WDOG_BARK_CLEAR], 0);
> > + ret = regmap_field_read(priv->rf[WDOG_BARK_COUNT], &wdog_count);
> > + if (ret)
> > + return ret;
> > + if (wdog_count)
> > + dev_dbg(priv->dev, "%s: watchdog count: %d\n", __func__, wdog_count);
> > +
> > + return IRQ_HANDLED;
>
> Patch looks good, but would is make sense to fall through and handle
> critical interrupts as well (both in positive and error cases of this
> hunk)?

Yes, it makes sense. I'll remove the return IRQ_HANDLED and add a
comment instead.

> Reviewed-by: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx>
>
> Regards,
> Bjorn