mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Walleij <linusw@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Philipp Zabel <p.zabel@pengutronix.de>,
	 Ulf Hansson <ulfh@kernel.org>, Frank Li <Frank.Li@nxp.com>,
	 linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	 Linus Walleij <linusw@kernel.org>
Subject: [PATCH] misc: sram: Enable runtime PM
Date: Mon, 16 Nov 2026 00:02:21 +0100	[thread overview]
Message-ID: <20261116-ux500-sram-runtime-pm-v1-1-c554831d6b12@kernel.org> (raw)

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@nxp.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
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@kernel.org>


             reply	other threads:[~2026-11-15 23:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 23:02 Linus Walleij [this message]
2026-11-16  7:18 ` Arnd Bergmann

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=20261116-ux500-sram-runtime-pm-v1-1-c554831d6b12@kernel.org \
    --to=linusw@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=ulfh@kernel.org \
    /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

all inboxes | Powered by JetHome®