From: Anand Moon <linux.amoon@gmail.com>
To: Mateusz Majewski <m.majewski2@samsung.com>
Cc: alim.akhtar@samsung.com, bzolnier@gmail.com,
daniel.lezcano@linaro.org, justinstitt@google.com,
krzk@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
linux-samsung-soc@vger.kernel.org, llvm@lists.linux.dev,
lukasz.luba@arm.com, morbo@google.com, nathan@kernel.org,
nick.desaulniers+lkml@gmail.com, rafael@kernel.org,
rui.zhang@intel.com
Subject: Re: [PATCH v7 6/7] thermal/drivers/exynos: Handle temperature threshold IRQs with SoC-specific mapping
Date: Wed, 20 Aug 2025 18:58:43 +0530 [thread overview]
Message-ID: <CANAwSgSjkP_wZ2Wvk1bZ2j6GHwAqEw1f5ZXLfQyEWgzcBzb6Mw@mail.gmail.com> (raw)
In-Reply-To: <20250819131704.19780-1-m.majewski2@samsung.com>
Hi Mateusz,
Thanks for your review comments..
On Tue, 19 Aug 2025 at 18:47, Mateusz Majewski <m.majewski2@samsung.com> wrote:
>
> Hello :)
>
> > +/* Map Rise and Falling edges for IRQ Clean */
> > +struct tmu_irq_map {
> > + u32 fall[3];
> > + u32 rise[3];
> > +};
>
Ops, this is an overkill approach that could be simplified further.
static void exynos4412_tmu_clear_irqs(struct exynos_tmu_data *data)
{
unsigned int val_irq, clear_irq = 0;
u32 tmu_intstat = data->tmu_intstat;
u32 tmu_intclear = data->tmu_intclear;
static const u32 irq_bits[] = {
BIT(0), BIT(4), BIT(8), /* Rising edge */
BIT(12), BIT(16), BIT(20) /* Falling edge */
};
val_irq = readl(data->base + tmu_intstat);
/* Set SoC-specific interrupt bit mappings */
for (int i = 0; i < ARRAY_SIZE(irq_bits); i++) {
if (val_irq & irq_bits[i])
clear_irq |= irq_bits[i];
}
if (clear_irq)
writel(clear_irq, data->base + tmu_intclear);
}
> Hmm, we can probably get away with less interrupts. We actually only
> enable one fall interrupt in tmu_set_low_temp and one rise interrupt in
> tmu_set_high_temp.
Got it — we need to enable INTEN for both rising and falling edges,
specific to each SoC.
So each SoC has a one-to-one mapping of INTEN with INTSTAT and INTCLEAR bits
for rising and falling edge detection:.
Exynos4412
Falling edge: bits 20, 16, 12
Rising edge: bits 8, 4, 0
Exynos5422
Falling edge: bits 24, 20, 16
Rising edge: bits 8, 4, 0
Exynos5433
Falling edge: bits 23, 17, 16
Rising edge: bits 7, 1, 0
So we need to enable INTEN like below.
static void exynos4412_tmu_set_low_temp(struct exynos_tmu_data *data, u8 temp)
{
exynos_tmu_update_temp(data, EXYNOS_THD_TEMP_FALL, 0, temp);
- exynos_tmu_update_bit(data, EXYNOS_TMU_REG_INTEN,
- EXYNOS_TMU_INTEN_FALL0_SHIFT, true);
+ for (int i = 0; i < 3; i++)
+ exynos_tmu_update_bit(data, EXYNOS_TMU_REG_INTEN,
+ EXYNOS_TMU_INTEN_FALL0_SHIFT + i
* 4, true);
}
static void exynos4412_tmu_set_high_temp(struct exynos_tmu_data *data, u8 temp)
{
exynos_tmu_update_temp(data, EXYNOS_THD_TEMP_RISE, 8, temp);
- exynos_tmu_update_bit(data, EXYNOS_TMU_REG_INTEN,
- EXYNOS_TMU_INTEN_RISE0_SHIFT + 4, true);
+ for (int i = 0; i < 3; i++)
+ exynos_tmu_update_bit(data, EXYNOS_TMU_REG_INTEN,
+ EXYNOS_TMU_INTEN_RISE0_SHIFT + 1 * 4, true);
}
>
> Regarding tmu_set_crit_temp, on SoCs that have hardware thermal tripping
> there is nothing to clear. On others we will reboot immediately anyway,
> though maybe there is nothing wrong with clearing the interrupt
> beforehand? Regardless of this, there is only a rise critical
> temperature interrupt, we never set a matching fall interrupt.
>
As per my understanding, it depends on the calibration consists of reading the
measured data from e-fuse and wrote the calibrated threshold temperature to
generate interrupts into trigger level 0-3
THRES_TEMP_RISE and THRES_TEMP_FALL.
When the current temperature exceeds a threshold rise temperature,
then it generates the corresponding interrupt (INTREQ_RISE[2:0]).
When the current temperature goes below a threshold fall temperature, t
hen it generates a corresponding interrupt (INTREQ_FALL[2:0].
It also depends on the sample interval
> Maybe it would also be good to add a bool to this struct containing
> information about whether a fall interrupt is in use, and reuse
> the same logic for 4210?
>
> (Nitpick: I am not a native speaker of English, but I think "clean" and
> "clear" have slightly different meanings, and the rest of the code
> consistently uses "clear", so it would be worthwhile to also use "clear"
> here.)
>
> > + break;
>
> Maybe put irq_map inside exynos_tmu_data? exynos_map_dt_data has a
> switch block that is quite similar, in that it also matches on the SoC
> type. This way also there is no need to have a fallback.
>
I want to avoid this If you have any design feedback, plz let me know.
I had attempted to refactor exynos_tmu_data by splitting it per-SoC,
assigning dedicated callback functions for each variant. The goal was
to eliminate
the need for data->soc checks and make the code more modular.
However, the approach didn’t work as expected—devm_thermal_of_zone_register()
wouldn’t bind the sensor-specific callbacks correctly.
static const struct thermal_zone_device_ops exynos_sensor_ops = {
.get_temp = exynos_get_temp,
.set_emul_temp = exynos_tmu_set_emulation,
.set_trips = exynos_set_trips,
};
> Kind regards,
> Mateusz Majewski
Thanks
-Anand
next prev parent reply other threads:[~2025-08-20 13:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 13:09 [PATCH v7 0/7] Exynos Thermal code improvement Anand Moon
2025-08-13 13:09 ` [PATCH v7 1/7] thermal/drivers/exynos: Refactor clk_sec initialization inside SOC-specific case Anand Moon
2025-08-13 13:09 ` [PATCH v7 2/7] thermal/drivers/exynos: Use devm_clk_get_enabled() helpers Anand Moon
2025-08-13 13:09 ` [PATCH v7 3/7] thermal/drivers/exynos: Remove redundant IS_ERR() checks for clk_sec clock Anand Moon
2025-08-13 13:09 ` [PATCH v7 4/7] thermal/drivers/exynos: Fixed the efuse min max value for exynos5422 Anand Moon
2025-08-13 13:09 ` [PATCH v7 5/7] thermal/drivers/exynos: Remove unused base_second mapping and references Anand Moon
2025-08-13 13:09 ` [PATCH v7 6/7] thermal/drivers/exynos: Handle temperature threshold IRQs with SoC-specific mapping Anand Moon
[not found] ` <CGME20250819131732eucas1p26bd491e9b6b747a4857905bfd50420a9@eucas1p2.samsung.com>
2025-08-19 13:17 ` Mateusz Majewski
[not found] ` <CGME20250819134804eucas1p1ed14f9680e66327a86af4e98319eed11@eucas1p1.samsung.com>
2025-08-19 13:47 ` Mateusz Majewski
2025-08-20 13:28 ` Anand Moon [this message]
2025-08-13 13:09 ` [PATCH v7 7/7] thermal/drivers/exynos: Refactor IRQ clear logic using SoC-specific config Anand Moon
[not found] ` <CGME20250819131814eucas1p2c57ccc084cf6736fed01a8a5c0b35fab@eucas1p2.samsung.com>
2025-08-19 13:18 ` Mateusz Majewski
2025-08-20 13:28 ` Anand Moon
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=CANAwSgSjkP_wZ2Wvk1bZ2j6GHwAqEw1f5ZXLfQyEWgzcBzb6Mw@mail.gmail.com \
--to=linux.amoon@gmail.com \
--cc=alim.akhtar@samsung.com \
--cc=bzolnier@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=justinstitt@google.com \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=lukasz.luba@arm.com \
--cc=m.majewski2@samsung.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/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).