[PATCH] misc: sram: Enable runtime PM
From: Linus Walleij
Date: Sun Nov 15 2026 - 18:02:32 EST
Enable runtime PM for generic SRAM devices after probe has initialized
the SRAM mappings and partitions.
This lets SRAM devices with attached power domains be managed through
runtime PM references from their consumers.
Keep sysfs-exported SRAM and SRAM requiring platform initialization
powered while the driver is bound. This preserves exported contents
and avoids unpowered sysfs accesses or an unsupported resume sequence.
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
Signed-off-by: Linus Walleij <linusw@xxxxxxxxxx>
---
Enable runtime PM for SRAM suppliers so consumers can manage their power
domains through runtime PM device links. Keep sysfs-exported SRAM and
SRAM with platform initialization powered while the driver is bound.
The Ux500 genpd prerequisites have been merged into the powerdomain tree.
Arnd/Greg: you can either apply this directly (if it checks out) or ask
me to send it to the SoC tree.
---
drivers/misc/sram.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index c8990e83a65a..4d2477bb5cd9 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -13,6 +13,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/mfd/syscon.h>
@@ -380,6 +381,8 @@ static int sram_probe(struct platform_device *pdev)
int ret;
struct resource *res;
struct clk *clk;
+ bool keep_active;
+ unsigned int i;
config = of_device_get_match_data(&pdev->dev);
@@ -425,6 +428,24 @@ static int sram_probe(struct platform_device *pdev)
goto err_free_partitions;
}
+ /*
+ * Sysfs users need retained contents; init-only platforms have no
+ * runtime resume support. Keep both powered while the driver is bound.
+ */
+ keep_active = config && config->init;
+ for (i = 0; i < sram->partitions; i++)
+ keep_active |= sram->partition[i].battr.size != 0;
+
+ if (keep_active) {
+ ret = devm_pm_runtime_get_noresume(sram->dev);
+ if (ret)
+ goto err_free_partitions;
+ }
+
+ ret = devm_pm_runtime_set_active_enabled(&pdev->dev);
+ if (ret)
+ goto err_free_partitions;
+
if (sram->pool)
dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
gen_pool_size(sram->pool) / 1024, sram->virt_base);
---
base-commit: 9ae477db090b44816741fd9c49a3c459fc7d407b
change-id: 20261115-ux500-sram-runtime-pm-2e1578439a63
Best regards,
--
Linus Walleij <linusw@xxxxxxxxxx>