Skip to contentSkip to conversation

clk: renesas: Lock initialization cleanups

PATCH In review Geert Uytterhoeven 3 participants 9 messages May 29, 2024 – Jun 3, 2024

Subsystems (3)
lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

cover clk: renesas: Lock initialization cleanups

Hi all,

This patch series contains a few spin lock initialization cleanups for R-Car Gen2+ clock drivers. It has been tested on a variety of R-Car Gen2+ systems.

I plan to queued these in renesas-clk for v6.11.

Thanks for your comments!

Geert Uytterhoeven (3):
clk: renesas: r8a77970: Use common cpg_lock
clk: renesas: cpg-lib: Use DEFINE_SPINLOCK() for global spinlock
clk: renesas: rcar-gen2: Use DEFINE_SPINLOCK() for static spinlock

 drivers/clk/renesas/r8a77970-cpg-mssr.c | 5 +----
 drivers/clk/renesas/rcar-cpg-lib.c      | 2 +-
 drivers/clk/renesas/rcar-gen2-cpg.c     | 4 +---
 drivers/clk/renesas/rcar-gen3-cpg.c     | 2 --
 drivers/clk/renesas/rcar-gen4-cpg.c     | 2 --
 5 files changed, 3 insertions(+), 12 deletions(-)
Signature · 12 lines
2.34.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
author maintainer
#1 lore raw

PATCH 1/3 clk: renesas: r8a77970: Use common cpg_lock

R-Car Gen3 Socs use the common CPG/MSSR library functions in rcar-cpg-lib.c, so the R-Car V3M sub-driver can use the common cpg_lock instead of a driver-private lock.

---
 drivers/clk/renesas/r8a77970-cpg-mssr.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/clk/renesas/r8a77970-cpg-mssr.c +1 -4
index 7e90e94c4b68821b..3cec0f501b947eae 100644
@@ -18,6 +18,7 @@
 #include <dt-bindings/clock/r8a77970-cpg-mssr.h>
 
 #include "renesas-cpg-mssr.h"
+#include "rcar-cpg-lib.h"
 #include "rcar-gen3-cpg.h"
 
 #define CPG_SD0CKCR		0x0074
@@ -47,8 +48,6 @@ enum clk_ids {
 	MOD_CLK_BASE
 };
 
-static spinlock_t cpg_lock;
-
 static const struct clk_div_table cpg_sd0h_div_table[] = {
 	{  0,  2 }, {  1,  3 }, {  2,  4 }, {  3,  6 },
 	{  4,  8 }, {  5, 12 }, {  6, 16 }, {  7, 18 },
@@ -213,8 +212,6 @@ static int __init r8a77970_cpg_mssr_init(struct device *dev)
 	if (error)
 		return error;
 
-	spin_lock_init(&cpg_lock);
-
 	cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
 
 	return rcar_gen3_cpg_init(cpg_pll_config, CLK_EXTALR, cpg_mode);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] clk: renesas: r8a77970: Use common cpg_lock

Quoting Geert Uytterhoeven (2024-05-29 02:35:08)

Quoted 6 lines

R-Car Gen3 Socs use the common CPG/MSSR library functions in rcar-cpg-lib.c, so the R-Car V3M sub-driver can use the common cpg_lock instead of a driver-private lock.

---

author maintainer
#3 lore raw

PATCH 2/3 clk: renesas: cpg-lib: Use DEFINE_SPINLOCK() for global spinlock

In reply to Geert Uytterhoeven

A global spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

---
 drivers/clk/renesas/rcar-cpg-lib.c  | 2 +-
 drivers/clk/renesas/rcar-gen3-cpg.c | 2 --
 drivers/clk/renesas/rcar-gen4-cpg.c | 2 --
 3 files changed, 1 insertion(+), 5 deletions(-)
drivers/clk/renesas/rcar-cpg-lib.c +1 -1
index 5a15f8788b9227d9..42b126ea3e1337c1 100644
@@ -22,7 +22,7 @@
 
 #include "rcar-cpg-lib.h"
 
-spinlock_t cpg_lock;
+DEFINE_SPINLOCK(cpg_lock);
 
 void cpg_reg_modify(void __iomem *reg, u32 clear, u32 set)
 {
drivers/clk/renesas/rcar-gen3-cpg.c +0 -2
index d0129a6509411662..20b89eb6c35c1f07 100644
@@ -551,7 +551,5 @@ int __init rcar_gen3_cpg_init(const struct rcar_gen3_cpg_pll_config *config,
 		cpg_quirks = (uintptr_t)attr->data;
 	pr_debug("%s: mode = 0x%x quirks = 0x%x\n", __func__, mode, cpg_quirks);
 
-	spin_lock_init(&cpg_lock);
-
 	return 0;
 }
drivers/clk/renesas/rcar-gen4-cpg.c +0 -2
index 8e4559fbb0bc3352..0e2c27adcfe784a0 100644
@@ -507,7 +507,5 @@ int __init rcar_gen4_cpg_init(const struct rcar_gen4_cpg_pll_config *config,
 	cpg_clk_extalr = clk_extalr;
 	cpg_mode = mode;
 
-	spin_lock_init(&cpg_lock);
-
 	return 0;
 }
Signature · 1 line
2.34.1
maintainer
#4 lore raw

Re: [PATCH 2/3] clk: renesas: cpg-lib: Use DEFINE_SPINLOCK() for global spinlock

Quoting Geert Uytterhoeven (2024-05-29 02:35:09)

Quoted 6 lines

A global spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

---

Shouldn't this be first so that the previous patch can use the initialized spinlock?

#5 lore raw

Re: [PATCH 2/3] clk: renesas: cpg-lib: Use DEFINE_SPINLOCK() for global spinlock

Hi Stephen,

Quoted 10 lines · Stephen Boyd

Quoting Geert Uytterhoeven (2024-05-29 02:35:09)

Quoted 6 lines

A global spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

---

Shouldn't this be first so that the previous patch can use the initialized spinlock?

Order of the patches doesn't matter.

r8a77970_cpg_mssr_init() in the R-Car V3M sub-driver calls into rcar_gen3_cpg_init() in the Gen3 family sub-driver, which initialized the spinlock.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Reviewed-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] clk: renesas: cpg-lib: Use DEFINE_SPINLOCK() for global spinlock

In reply to Geert Uytterhoeven

Quoting Geert Uytterhoeven (2024-05-29 02:35:09)

Quoted 6 lines

A global spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

---

author maintainer
#7 lore raw

PATCH 3/3 clk: renesas: rcar-gen2: Use DEFINE_SPINLOCK() for static spinlock

In reply to Geert Uytterhoeven

A static spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

---
 drivers/clk/renesas/rcar-gen2-cpg.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clk/renesas/rcar-gen2-cpg.c +1 -3
index edae874fa2b63369..4c3764972bad905f 100644
@@ -30,7 +30,7 @@
 #define CPG_ADSPCKCR		0x025c
 #define CPG_RCANCKCR		0x0270
 
-static spinlock_t cpg_lock;
+static DEFINE_SPINLOCK(cpg_lock);
 
 /*
  * Z Clock
@@ -387,7 +387,5 @@ int __init rcar_gen2_cpg_init(const struct rcar_gen2_cpg_pll_config *config,
 		cpg_quirks = (uintptr_t)attr->data;
 	pr_debug("%s: mode = 0x%x quirks = 0x%x\n", __func__, mode, cpg_quirks);
 
-	spin_lock_init(&cpg_lock);
-
 	return 0;
 }
Signature · 1 line
2.34.1