Skip to contentSkip to conversation

Skip clk_put for attached clocks when freeing context

PATCH In review James Kelly 3 participants 3 messages May 15, 2018 – May 17, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Skip clk_put for attached clocks when freeing context

Capability to attach an existing clk to a MMIO regmap was introduced in 4.17rc1.

However, when using attached clk, regmap does not do the clk_get. Therefore it should not do the clk_put when freeing the MMIO regmap context.

There does not appear to be any users of attached clocks yet so this would be a good time to make this change before anything depends on the existing behaviour.

---
 drivers/base/regmap/regmap-mmio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/regmap/regmap-mmio.c +2 -1
index 5cadfd3394d8..8741fb5f8f54 100644
@@ -206,7 +206,8 @@ static void regmap_mmio_free_context(void *context)
 
 	if (!IS_ERR(ctx->clk)) {
 		clk_unprepare(ctx->clk);
-		clk_put(ctx->clk);
+		if (!ctx->attached_clk)
+			clk_put(ctx->clk);
 	}
 	kfree(context);
 }
Signature · 1 line
2.15.1 (Apple Git-101)
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · James Kelly

Capability to attach an existing clk to a MMIO regmap was introduced in 4.17rc1.

However, when using attached clk, regmap does not do the clk_get. Therefore it should not do the clk_put when freeing the MMIO regmap context.

Quoted 5 lines

There does not appear to be any users of attached clocks yet so this would be a good time to make this change before anything depends on the existing behaviour.

Thanks!
Maxime

Signature · 3 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
maintainer
#2 lore raw

Applied "regmap: Skip clk_put for attached clocks when freeing context" to the regmap tree

In reply to James Kelly

The patch

regmap: Skip clk_put for attached clocks when freeing context

has been applied to the regmap tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From eb4a219d19fde99616f120f5655a7121c918cd49 Mon Sep 17 00:00:00 2001

From: James Kelly <[email protected]>
Date: Tue, 15 May 2018 10:59:58 +1000
Subject: [PATCH] regmap: Skip clk_put for attached clocks when freeing context

Capability to attach an existing clk to a MMIO regmap was introduced in 4.17rc1.

However, when using attached clk, regmap does not do the clk_get. Therefore it should not do the clk_put when freeing the MMIO regmap context.

There does not appear to be any users of attached clocks yet so this would be a good time to make this change before anything depends on the existing behaviour.

---
 drivers/base/regmap/regmap-mmio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/regmap/regmap-mmio.c +2 -1
index 5cadfd3394d8..8741fb5f8f54 100644
@@ -206,7 +206,8 @@ static void regmap_mmio_free_context(void *context)
 
 	if (!IS_ERR(ctx->clk)) {
 		clk_unprepare(ctx->clk);
-		clk_put(ctx->clk);
+		if (!ctx->attached_clk)
+			clk_put(ctx->clk);
 	}
 	kfree(context);
 }
Signature · 1 line
2.17.0