* [PATCH 0/8] memory: Fix Critical and High issues reported by Sashiko
@ 2026-12-02 9:33 Lee Jones
2026-12-02 9:33 ` [PATCH 2/8] memory: tegra210-emc: Stop timers on suspend and prevent training re-arm Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Lee Jones @ 2026-12-02 9:33 UTC (permalink / raw)
To: lee
Cc: linux-kernel, Alexandre Belloni, Alexandre Torgue, Aneesh V,
Benoit Cousson, Boris Brezillon, Christophe Kerello,
Claudiu Beznea, Grant Likely, Greg Kroah-Hartman,
Jean-Jacques Hiblot, Jonathan Hunter, Joseph Lo,
Krzysztof Kozlowski, linux-arm-kernel, linux-stm32, linux-tegra,
Maxime Coquelin, Nicolas Ferre, Patrice Chotard,
Santosh Shilimkar, Thierry Reding
These issues were reported by Sashiko.
This series addresses all open Critical and High severity reports in
the memory controller subsystem, rebased onto mem-ctrl/for-next. It
fixes a devm lifetime use-after-free in of_update_property(), timer
teardown and re-arm races during suspend/resume, child depopulation
ordering, REQ2ACK bitfield and divide-by-zero bugs, AMCR bitfield
shifting/masking, __fls(0) undefined behaviour, and stale invalid
custom_configs pointers.
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Aneesh V <aneesh@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Boris Brezillon <bbrezillon@kernel.org>
Cc: Christophe Kerello <christophe.kerello@foss.st.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Joseph Lo <josephl@nvidia.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-tegra@vger.kernel.org
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Santosh Shilimkar <ssantosh@kernel.org>
Cc: Thierry Reding <thierry.reding@kernel.org>
Lee Jones (8):
memory: atmel-ebi: Use non-devm allocations for of_update_property()
memory: tegra210-emc: Stop timers on suspend and prevent training
re-arm
memory: stm32_omm: Depopulate child devices before disabling clocks
memory: stm32_omm: Fix double FIELD_PREP() and clamp for REQ2ACK
memory: stm32_omm: Avoid division by zero in req2ack calculation
memory: stm32_omm: Shift and mask AMCR value in stm32_omm_set_amcr()
memory: emif: Avoid __fls(0) and underflow in of_get_ddr_info()
memory: emif: Clear invalid custom_configs in get_device_details()
drivers/memory/atmel-ebi.c | 40 +++++++++++++++++-------
drivers/memory/emif.c | 6 ++--
drivers/memory/stm32_omm.c | 29 +++++++++++------
drivers/memory/tegra/tegra210-emc-core.c | 37 +++++++++++++++++-----
drivers/memory/tegra/tegra210-emc.h | 2 ++
5 files changed, 84 insertions(+), 30 deletions(-)
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/8] memory: tegra210-emc: Stop timers on suspend and prevent training re-arm
2026-12-02 9:33 [PATCH 0/8] memory: Fix Critical and High issues reported by Sashiko Lee Jones
@ 2026-12-02 9:33 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2026-12-02 9:33 UTC (permalink / raw)
To: lee, Krzysztof Kozlowski, Thierry Reding, Jonathan Hunter,
Joseph Lo, linux-kernel, linux-tegra
Cc: stable
tegra210_emc_train() unconditionally calls mod_timer(&emc->training, ...)
after releasing emc->lock. When tegra210_emc_training_stop() deletes
the timer under emc->lock while tegra210_emc_train() is already running
on another CPU, the callback can race with the stop, execute
periodic_compensation() on an untrained rate, and re-arm itself.
In addition, tegra210_emc_suspend() detaches the EMC clock without
synchronously stopping the refresh polling timer or the periodic
training timer, allowing timer callbacks to touch EMC hardware or
re-enable training after suspend.
Track whether periodic training is enabled under emc->lock so
tegra210_emc_train() only runs and re-arms while training is active.
Synchronously stop refresh polling and periodic training in
tegra210_emc_suspend() before detaching the EMC clock, and restart
periodic training (if required by the resumed timing and not already
restarted by clk_set_rate()) and refresh polling in
tegra210_emc_resume().
Fixes: 10de21148f7d ("memory: tegra: Add EMC scaling support code for Tegra210")
Closes: https://sashiko.dev/#/bug/linux-47538f77-fb50-4a06-b49b-92dbee8b538b
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/memory/tegra/tegra210-emc-core.c | 37 +++++++++++++++++++-----
drivers/memory/tegra/tegra210-emc.h | 2 ++
2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/drivers/memory/tegra/tegra210-emc-core.c b/drivers/memory/tegra/tegra210-emc-core.c
index 044ec6f1bc32..06aba71d8fb6 100644
--- a/drivers/memory/tegra/tegra210-emc-core.c
+++ b/drivers/memory/tegra/tegra210-emc-core.c
@@ -560,28 +560,29 @@ static void tegra210_emc_train(struct timer_list *timer)
struct tegra210_emc *emc = timer_container_of(emc, timer, training);
unsigned long flags;
- if (!emc->last)
- return;
-
spin_lock_irqsave(&emc->lock, flags);
- if (emc->sequence->periodic_compensation)
- emc->sequence->periodic_compensation(emc);
+ if (emc->training_enabled && emc->last) {
+ if (emc->sequence->periodic_compensation)
+ emc->sequence->periodic_compensation(emc);
+
+ mod_timer(&emc->training,
+ jiffies + msecs_to_jiffies(emc->training_interval));
+ }
spin_unlock_irqrestore(&emc->lock, flags);
-
- mod_timer(&emc->training,
- jiffies + msecs_to_jiffies(emc->training_interval));
}
static void tegra210_emc_training_start(struct tegra210_emc *emc)
{
+ emc->training_enabled = true;
mod_timer(&emc->training,
jiffies + msecs_to_jiffies(emc->training_interval));
}
static void tegra210_emc_training_stop(struct tegra210_emc *emc)
{
+ emc->training_enabled = false;
timer_delete(&emc->training);
}
@@ -2001,6 +2002,7 @@ static void tegra210_emc_remove(struct platform_device *pdev)
static int __maybe_unused tegra210_emc_suspend(struct device *dev)
{
struct tegra210_emc *emc = dev_get_drvdata(dev);
+ unsigned long flags;
int err;
err = clk_rate_exclusive_get(emc->clk);
@@ -2009,9 +2011,19 @@ static int __maybe_unused tegra210_emc_suspend(struct device *dev)
return err;
}
+ emc->resume_refresh_poll = atomic_read(&emc->refresh_poll) > 0;
+ if (emc->resume_refresh_poll)
+ tegra210_emc_poll_refresh_stop(emc);
+
emc->resume_rate = clk_get_rate(emc->clk);
clk_set_rate(emc->clk, 204000000);
+
+ spin_lock_irqsave(&emc->lock, flags);
+ tegra210_emc_training_stop(emc);
+ spin_unlock_irqrestore(&emc->lock, flags);
+ timer_delete_sync(&emc->training);
+
tegra210_clk_emc_detach(emc->clk);
dev_dbg(dev, "suspending at %lu Hz\n", clk_get_rate(emc->clk));
@@ -2022,6 +2034,7 @@ static int __maybe_unused tegra210_emc_suspend(struct device *dev)
static int __maybe_unused tegra210_emc_resume(struct device *dev)
{
struct tegra210_emc *emc = dev_get_drvdata(dev);
+ unsigned long flags;
int err;
err = tegra210_clk_emc_attach(emc->clk, &emc->provider);
@@ -2033,6 +2046,14 @@ static int __maybe_unused tegra210_emc_resume(struct device *dev)
clk_set_rate(emc->clk, emc->resume_rate);
clk_rate_exclusive_put(emc->clk);
+ spin_lock_irqsave(&emc->lock, flags);
+ if (emc->last && emc->last->periodic_training && !emc->training_enabled)
+ tegra210_emc_training_start(emc);
+ spin_unlock_irqrestore(&emc->lock, flags);
+
+ if (emc->resume_refresh_poll)
+ tegra210_emc_poll_refresh_start(emc);
+
dev_dbg(dev, "resuming at %lu Hz\n", clk_get_rate(emc->clk));
return 0;
diff --git a/drivers/memory/tegra/tegra210-emc.h b/drivers/memory/tegra/tegra210-emc.h
index 8988bcf15290..44379034da8b 100644
--- a/drivers/memory/tegra/tegra210-emc.h
+++ b/drivers/memory/tegra/tegra210-emc.h
@@ -912,6 +912,7 @@ struct tegra210_emc {
unsigned int training_interval;
struct timer_list training;
+ bool training_enabled;
enum tegra210_emc_refresh refresh;
unsigned int refresh_poll_interval;
@@ -923,6 +924,7 @@ struct tegra210_emc {
int clkchange_delay;
unsigned long resume_rate;
+ bool resume_refresh_poll;
struct {
struct dentry *root;
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-02 9:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 9:33 [PATCH 0/8] memory: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-02 9:33 ` [PATCH 2/8] memory: tegra210-emc: Stop timers on suspend and prevent training re-arm Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox