Message ID | 20220120200153.1214-1-benl@squareup.com |
---|---|
State | New |
Headers | show |
Series | [v3] drivers: thermal: tsens: respect thermal_device_mode in threshold irq reporting | expand |
On Fri, Feb 25, 2022 at 6:02 AM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > Some drivers that support thermal zone disabling implement a set_mode > > operation and simply disable the sensor or the relevant IRQ(s), so they > > actually don't log anything when zones are disabled. These drivers are > > imx_thermal.c, intel_quark_dts_thermal.c, and int3400_thermal.c. > > > > For tsens.c, implementing a change_mode would require migrating the driver > > from devm_thermal_zone_of_sensor_register to thermal_zone_device_register > > (or updating thermal_of.c to add a change_mode operation in thermal_zone_ > > of_device_ops). > > > > stm_thermal.c seems to use this patch's model of not disabling IRQs when > > the zone is disabled (they still perform the thermal_zone_device_update > > upon IRQ, but return -EAGAIN from their get_temp). > > What is the concern by changing the core code to have a correct handling > of the disabled / enabled state in this driver ? (and by this way give > the opportunity to other drivers to fix their code)' It seems fine, is that the preference? Updating thermal_of.c to add a change_mode operation in thermal_zone_of_device_ops? Ben > > > -- > <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs > > Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | > <http://twitter.com/#!/linaroorg> Twitter | > <http://www.linaro.org/linaro-blog/> Blog
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 99a8d9f3e03c..dd0002829536 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -509,10 +509,14 @@ static irqreturn_t tsens_irq_thread(int irq, void *data) spin_unlock_irqrestore(&priv->ul_lock, flags); if (trigger) { - dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n", - hw_id, __func__, temp); - thermal_zone_device_update(s->tzd, - THERMAL_EVENT_UNSPECIFIED); + if (s->tzd->mode == THERMAL_DEVICE_ENABLED) { + dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n", + hw_id, __func__, temp); + thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED); + } else { + dev_info_ratelimited(priv->dev, "[%u] %s: TZ update trigger (%d mC) skipped - zone disabled, operating outside of safety limits!\n", + hw_id, __func__, temp); + } } else { dev_dbg(priv->dev, "[%u] %s: no violation: %d\n", hw_id, __func__, temp);