ARM Sunxi Platform Development
 help / color / mirror / Atom feed
* [PATCH 0/8] pwm: Drop local locking in several drivers
@ 2025-06-24 18:15 Uwe Kleine-König
  2025-06-24 18:15 ` [PATCH 7/8] pwm: sun4i: Drop driver local locking Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2025-06-24 18:15 UTC (permalink / raw)
  To: linux-pwm
  Cc: Claudiu Beznea, Nicolas Ferre, Alexandre Belloni,
	linux-arm-kernel, Vladimir Zapolskiy, Conor Dooley,
	Daire McNamara, linux-riscv, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, linux-sunxi

Hello,

some time ago the pwm core implemented additional locking to protect
lowlevel driver callbacks against driver removal. A side effect is that
.apply() and .get_state() are serialized. This allows to drop some
locking that is now superfluous due to the core's locking.

I identified a few drivers that are affected; these are cleaned up
accordingly here.

Best regards
Uwe

Uwe Kleine-König (8):
  pwm: atmel: Drop driver local locking
  pwm: clps711x: Drop driver local locking
  pwm: fsl-ftm: Drop driver local locking
  pwm: lpc18xx-sct: Drop driver local locking
  pwm: microchip-core: Drop driver local locking
  pwm: sti: Drop driver local locking
  pwm: sun4i: Drop driver local locking
  pwm: twl-led: Drop driver local locking

 drivers/pwm/pwm-atmel.c          | 12 --------
 drivers/pwm/pwm-clps711x.c       |  8 ------
 drivers/pwm/pwm-fsl-ftm.c        | 28 +++++-------------
 drivers/pwm/pwm-lpc18xx-sct.c    | 14 ---------
 drivers/pwm/pwm-microchip-core.c | 17 +----------
 drivers/pwm/pwm-sti.c            | 23 ++++-----------
 drivers/pwm/pwm-sun4i.c          | 10 -------
 drivers/pwm/pwm-twl-led.c        | 49 +++++---------------------------
 8 files changed, 21 insertions(+), 140 deletions(-)

base-commit: f817b6dd2b62d921a6cdc0a3ac599cd1851f343c
-- 
2.49.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 7/8] pwm: sun4i: Drop driver local locking
  2025-06-24 18:15 [PATCH 0/8] pwm: Drop local locking in several drivers Uwe Kleine-König
@ 2025-06-24 18:15 ` Uwe Kleine-König
  2025-07-01  7:57 ` [PATCH 0/8] pwm: Drop local locking in several drivers Uwe Kleine-König
  2025-08-10 21:12 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2025-06-24 18:15 UTC (permalink / raw)
  To: linux-pwm
  Cc: Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, linux-arm-kernel,
	linux-sunxi

The pwm core serializes calls to .apply(), so the driver lock doesn't
add any protection and can safely be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/pwm/pwm-sun4i.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index e60dc7d6b591..6c5591ca868b 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -21,7 +21,6 @@
 #include <linux/pwm.h>
 #include <linux/reset.h>
 #include <linux/slab.h>
-#include <linux/spinlock.h>
 #include <linux/time.h>
 
 #define PWM_CTRL_REG		0x0
@@ -85,7 +84,6 @@ struct sun4i_pwm_chip {
 	struct clk *clk;
 	struct reset_control *rst;
 	void __iomem *base;
-	spinlock_t ctrl_lock;
 	const struct sun4i_pwm_data *data;
 };
 
@@ -258,7 +256,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 		return ret;
 	}
 
-	spin_lock(&sun4ichip->ctrl_lock);
 	ctrl = sun4i_pwm_readl(sun4ichip, PWM_CTRL_REG);
 
 	if (sun4ichip->data->has_direct_mod_clk_output) {
@@ -266,7 +263,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 			ctrl |= BIT_CH(PWM_BYPASS, pwm->hwpwm);
 			/* We can skip other parameter */
 			sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG);
-			spin_unlock(&sun4ichip->ctrl_lock);
 			return 0;
 		}
 
@@ -297,8 +293,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 	sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG);
 
-	spin_unlock(&sun4ichip->ctrl_lock);
-
 	if (state->enabled)
 		return 0;
 
@@ -309,12 +303,10 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	else
 		usleep_range(delay_us, delay_us * 2);
 
-	spin_lock(&sun4ichip->ctrl_lock);
 	ctrl = sun4i_pwm_readl(sun4ichip, PWM_CTRL_REG);
 	ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm);
 	ctrl &= ~BIT_CH(PWM_EN, pwm->hwpwm);
 	sun4i_pwm_writel(sun4ichip, ctrl, PWM_CTRL_REG);
-	spin_unlock(&sun4ichip->ctrl_lock);
 
 	clk_disable_unprepare(sun4ichip->clk);
 
@@ -456,8 +448,6 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
 
 	chip->ops = &sun4i_pwm_ops;
 
-	spin_lock_init(&sun4ichip->ctrl_lock);
-
 	ret = pwmchip_add(chip);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/8] pwm: Drop local locking in several drivers
  2025-06-24 18:15 [PATCH 0/8] pwm: Drop local locking in several drivers Uwe Kleine-König
  2025-06-24 18:15 ` [PATCH 7/8] pwm: sun4i: Drop driver local locking Uwe Kleine-König
@ 2025-07-01  7:57 ` Uwe Kleine-König
  2025-08-10 21:12 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2025-07-01  7:57 UTC (permalink / raw)
  To: linux-pwm
  Cc: Claudiu Beznea, Nicolas Ferre, Alexandre Belloni,
	linux-arm-kernel, Vladimir Zapolskiy, Conor Dooley,
	Daire McNamara, linux-riscv, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 589 bytes --]

Hello,

On Tue, Jun 24, 2025 at 08:15:36PM +0200, Uwe Kleine-König wrote:
> some time ago the pwm core implemented additional locking to protect
> lowlevel driver callbacks against driver removal. A side effect is that
> .apply() and .get_state() are serialized. This allows to drop some
> locking that is now superfluous due to the core's locking.
> 
> I identified a few drivers that are affected; these are cleaned up
> accordingly here.

I applied these patches to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
now.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/8] pwm: Drop local locking in several drivers
  2025-06-24 18:15 [PATCH 0/8] pwm: Drop local locking in several drivers Uwe Kleine-König
  2025-06-24 18:15 ` [PATCH 7/8] pwm: sun4i: Drop driver local locking Uwe Kleine-König
  2025-07-01  7:57 ` [PATCH 0/8] pwm: Drop local locking in several drivers Uwe Kleine-König
@ 2025-08-10 21:12 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-08-10 21:12 UTC (permalink / raw)
  To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig_=3Cu=2Ekleine-koenig=40baylibre=2Ecom=3E?=
  Cc: linux-riscv, linux-pwm, claudiu.beznea, nicolas.ferre,
	alexandre.belloni, linux-arm-kernel, vz, conor.dooley,
	daire.mcnamara, wens, jernej.skrabec, samuel, linux-sunxi

Hello:

This patch was applied to riscv/linux.git (fixes)
by Uwe Kleine-König <ukleinek@kernel.org>:

On Tue, 24 Jun 2025 20:15:36 +0200 you wrote:
> Hello,
> 
> some time ago the pwm core implemented additional locking to protect
> lowlevel driver callbacks against driver removal. A side effect is that
> .apply() and .get_state() are serialized. This allows to drop some
> locking that is now superfluous due to the core's locking.
> 
> [...]

Here is the summary with links:
  - [5/8] pwm: microchip-core: Drop driver local locking
    https://git.kernel.org/riscv/c/9470e7d11fe2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-10 21:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24 18:15 [PATCH 0/8] pwm: Drop local locking in several drivers Uwe Kleine-König
2025-06-24 18:15 ` [PATCH 7/8] pwm: sun4i: Drop driver local locking Uwe Kleine-König
2025-07-01  7:57 ` [PATCH 0/8] pwm: Drop local locking in several drivers Uwe Kleine-König
2025-08-10 21:12 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox