Skip to contentSkip to conversation

pinctrl: rockchip: fix editing const struct + constify rockchip_pin_ctrl

PATCH In review Quentin Schulz 3 participants 28 messages Jan 31, 2025 – May 6, 2025

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

v2 cover pinctrl: rockchip: fix editing const struct + constify rockchip_pin_ctrl

While testing some WIP work done by Ilias Apalodimas on guaranteeing read-only memory areas truly are handled as read-only[1], my RK3588 Tiger couldn't reach U-Boot CLI anymore because of the pinctrl driver modifying a const struct rockchip_pin_ctrl, triggering a CPU abort.

Instead of going the lazy way and unconstify it, let's fix the actual issue in play.

This also means we should be able to constify the private data of the controller device for all Rockchip devices, instead of having those only for RK356x, RK3588 and RV1126. With the constify done on top of Ilias patch series[1], my PX30 Ringneck, RK3399 Puma and RK3588 Tiger all reach U-Boot CLI. No further testing (like booting into Linux userspace) was done.

[1] https://lore.kernel.org/u-boot/[email protected]/

---
Changes in v2:
- remove removal of bank's pin_base because Jonas said he'll need it for
a new version of https://lore.kernel.org/u-boot/[email protected]/
- fix pin_base computing by init'ing the controller nr_pins to 0,
- make controller nr_pins local to the probe function instead of keeping
it in rockchip_pin_ctrl struct,
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Quentin Schulz (13):
pinctrl: rockchip: fix bank's pin_base computing
pinctrl: rockchip: constify rockchip_pin_ctrl for PX30
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3036
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3066
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3128
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3188
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3228
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3288
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3308
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3328
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3368
pinctrl: rockchip: constify rockchip_pin_ctrl for RK3399
pinctrl: rockchip: constify rockchip_pin_ctrl for RV1108

 drivers/pinctrl/rockchip/pinctrl-px30.c          | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3036.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3066.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3128.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3188.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk322x.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3288.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3308.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3328.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3368.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3399.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rk3568.c        | 1 -
 drivers/pinctrl/rockchip/pinctrl-rk3588.c        | 1 -
 drivers/pinctrl/rockchip/pinctrl-rockchip-core.c | 5 +++--
 drivers/pinctrl/rockchip/pinctrl-rockchip.h      | 1 -
 drivers/pinctrl/rockchip/pinctrl-rv1108.c        | 2 +-
 drivers/pinctrl/rockchip/pinctrl-rv1126.c        | 1 -
 17 files changed, 15 insertions(+), 18 deletions(-)

---
base-commit: 021baf7b08cceb58bb850859dba1614424e16a83
change-id: 20250129-rockchip-pinctrl-const-f4123019a584

Best regards,

Signature · 1 line
Quentin Schulz <[email protected]>
#1 lore raw

PATCH v2 1/13 pinctrl: rockchip: fix bank's pin_base computing

From: Quentin Schulz <[email protected]>

The logic in the core reads the nr_pins of the controller and uses it as the index of the first pin in the bank (pin_base) it currently parses. It then increments the number of pins in the controller before going to the next bank.

This works "fine" for controllers where nr_pins isn't defined in their rockchip_pin_ctrl struct as it defaults to 0. However, when it is already set, it'll make the index pin of each bank offset by the number in nr_pins declared in the struct at initialization, and it'll keep growing while adding banks, which means the total number of pins in the controller will be misrepresented.

Additionally, U-Boot proper may probe this driver twice (pre-reloc and true proper) and not reset nr_pins of the controller in-between meaning the second probe will have an offset of the actual correct nr_pins.

Instead, let's just store locally the number of pins in the controller and make sure it's reset between probes.

Finally, this stops modifying a const struct which will soon be triggering a CPU abort at runtime.

---
 drivers/pinctrl/rockchip/pinctrl-rk3568.c        | 1 -
 drivers/pinctrl/rockchip/pinctrl-rk3588.c        | 1 -
 drivers/pinctrl/rockchip/pinctrl-rockchip-core.c | 5 +++--
 drivers/pinctrl/rockchip/pinctrl-rockchip.h      | 1 -
 drivers/pinctrl/rockchip/pinctrl-rv1126.c        | 1 -
 5 files changed, 3 insertions(+), 6 deletions(-)
drivers/pinctrl/rockchip/pinctrl-rk3568.c +0 -1
index 5deedc648a41950461b6a468e4852fa0a5384207..c8a91b8bb6e925e0f2e7d6cd09f8a06a58be60dd 100644
@@ -345,7 +345,6 @@ static struct rockchip_pin_bank rk3568_pin_banks[] = {
 static const struct rockchip_pin_ctrl rk3568_pin_ctrl = {
 	.pin_banks		= rk3568_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3568_pin_banks),
-	.nr_pins		= 160,
 	.grf_mux_offset		= 0x0,
 	.pmu_mux_offset		= 0x0,
 	.iomux_routes		= rk3568_mux_route_data,
drivers/pinctrl/rockchip/pinctrl-rk3588.c +0 -1
index 98ababc7c90700c4b27359fc3625519f20437306..fd8e617b9108c7314b8fdd4bbe1dfae71f1b6449 100644
@@ -324,7 +324,6 @@ static struct rockchip_pin_bank rk3588_pin_banks[] = {
 static const struct rockchip_pin_ctrl rk3588_pin_ctrl = {
 	.pin_banks		= rk3588_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3588_pin_banks),
-	.nr_pins		= 160,
 	.set_mux		= rk3588_set_mux,
 	.set_pull		= rk3588_set_pull,
 	.set_drive		= rk3588_set_drive,
drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +3 -2
index d449d07d32e74d1dec1978b1405bec94887908a2..4de67aba1c3453673891482babf2f009fa053a97 100644
@@ -532,6 +532,7 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *d
 			(struct rockchip_pin_ctrl *)dev_get_driver_data(dev);
 	struct rockchip_pin_bank *bank;
 	int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, i, j;
+	u32 ctrl_nr_pins = 0;
 
 	grf_offs = ctrl->grf_mux_offset;
 	pmu_offs = ctrl->pmu_mux_offset;
@@ -543,8 +544,8 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *d
 		int bank_pins = 0;
 
 		bank->priv = priv;
-		bank->pin_base = ctrl->nr_pins;
-		ctrl->nr_pins += bank->nr_pins;
+		bank->pin_base = ctrl_nr_pins;
+		ctrl_nr_pins += bank->nr_pins;
 
 		/* calculate iomux and drv offsets */
 		for (j = 0; j < 4; j++) {
drivers/pinctrl/rockchip/pinctrl-rockchip.h +0 -1
index df7bc684d29fae4ec650d1e14fe88b35b03244ac..65c7488f8e399b36fda685b281db778cb55ba695 100644
@@ -500,7 +500,6 @@ struct rockchip_mux_route_data {
 struct rockchip_pin_ctrl {
 	struct rockchip_pin_bank	*pin_banks;
 	u32				nr_banks;
-	u32				nr_pins;
 	int				grf_mux_offset;
 	int				pmu_mux_offset;
 	int				grf_drv_offset;
drivers/pinctrl/rockchip/pinctrl-rv1126.c +0 -1
index efa2408b204b421ad1c5a36b039d8c07c5b7237e..3878a5420dcc98f591e4eefadd78a2fe98b61c7e 100644
@@ -381,7 +381,6 @@ static struct rockchip_pin_bank rv1126_pin_banks[] = {
 static const struct rockchip_pin_ctrl rv1126_pin_ctrl = {
 	.pin_banks		= rv1126_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rv1126_pin_banks),
-	.nr_pins		= 130,
 	.grf_mux_offset		= 0x10004, /* mux offset from GPIO0_D0 */
 	.pmu_mux_offset		= 0x0,
 	.iomux_routes		= rv1126_mux_route_data,
Signature · 1 line
2.48.1
Reviewed-by on v2 1/13
#2 lore raw

Re: [PATCH v2 01/13] pinctrl: rockchip: fix bank's pin_base computing

Quoted 18 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

The logic in the core reads the nr_pins of the controller and uses it as the index of the first pin in the bank (pin_base) it currently parses. It then increments the number of pins in the controller before going to the next bank.

This works "fine" for controllers where nr_pins isn't defined in their rockchip_pin_ctrl struct as it defaults to 0. However, when it is already set, it'll make the index pin of each bank offset by the number in nr_pins declared in the struct at initialization, and it'll keep growing while adding banks, which means the total number of pins in the controller will be misrepresented.

Additionally, U-Boot proper may probe this driver twice (pre-reloc and true proper) and not reset nr_pins of the controller in-between meaning the second probe will have an offset of the actual correct nr_pins.

Quoted 7 lines

Instead, let's just store locally the number of pins in the controller and make sure it's reset between probes.

Finally, this stops modifying a const struct which will soon be triggering a CPU abort at runtime.

Thanks,
- Kever

Quoted 80 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3568.c        | 1 -
  drivers/pinctrl/rockchip/pinctrl-rk3588.c        | 1 -
  drivers/pinctrl/rockchip/pinctrl-rockchip-core.c | 5 +++--
  drivers/pinctrl/rockchip/pinctrl-rockchip.h      | 1 -
  drivers/pinctrl/rockchip/pinctrl-rv1126.c        | 1 -
  5 files changed, 3 insertions(+), 6 deletions(-)
drivers/pinctrl/rockchip/pinctrl-rk3568.c +0 -1
index 5deedc648a41950461b6a468e4852fa0a5384207..c8a91b8bb6e925e0f2e7d6cd09f8a06a58be60dd 100644
@@ -345,7 +345,6 @@ static struct rockchip_pin_bank rk3568_pin_banks[] = {
  static const struct rockchip_pin_ctrl rk3568_pin_ctrl = {
  	.pin_banks		= rk3568_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3568_pin_banks),
-	.nr_pins		= 160,
  	.grf_mux_offset		= 0x0,
  	.pmu_mux_offset		= 0x0,
  	.iomux_routes		= rk3568_mux_route_data,
drivers/pinctrl/rockchip/pinctrl-rk3588.c +0 -1
index 98ababc7c90700c4b27359fc3625519f20437306..fd8e617b9108c7314b8fdd4bbe1dfae71f1b6449 100644
@@ -324,7 +324,6 @@ static struct rockchip_pin_bank rk3588_pin_banks[] = {
  static const struct rockchip_pin_ctrl rk3588_pin_ctrl = {
  	.pin_banks		= rk3588_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3588_pin_banks),
-	.nr_pins		= 160,
  	.set_mux		= rk3588_set_mux,
  	.set_pull		= rk3588_set_pull,
  	.set_drive		= rk3588_set_drive,
drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +3 -2
index d449d07d32e74d1dec1978b1405bec94887908a2..4de67aba1c3453673891482babf2f009fa053a97 100644
@@ -532,6 +532,7 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *d
  			(struct rockchip_pin_ctrl *)dev_get_driver_data(dev);
  	struct rockchip_pin_bank *bank;
  	int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, i, j;
+	u32 ctrl_nr_pins = 0;
 
  	grf_offs = ctrl->grf_mux_offset;
  	pmu_offs = ctrl->pmu_mux_offset;
@@ -543,8 +544,8 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *d
  		int bank_pins = 0;
 
  		bank->priv = priv;
-		bank->pin_base = ctrl->nr_pins;
-		ctrl->nr_pins += bank->nr_pins;
+		bank->pin_base = ctrl_nr_pins;
+		ctrl_nr_pins += bank->nr_pins;
 
  		/* calculate iomux and drv offsets */
  		for (j = 0; j < 4; j++) {
drivers/pinctrl/rockchip/pinctrl-rockchip.h +0 -1
index df7bc684d29fae4ec650d1e14fe88b35b03244ac..65c7488f8e399b36fda685b281db778cb55ba695 100644
@@ -500,7 +500,6 @@ struct rockchip_mux_route_data {
  struct rockchip_pin_ctrl {
  	struct rockchip_pin_bank	*pin_banks;
  	u32				nr_banks;
-	u32				nr_pins;
  	int				grf_mux_offset;
  	int				pmu_mux_offset;
  	int				grf_drv_offset;
drivers/pinctrl/rockchip/pinctrl-rv1126.c +0 -1
index efa2408b204b421ad1c5a36b039d8c07c5b7237e..3878a5420dcc98f591e4eefadd78a2fe98b61c7e 100644
@@ -381,7 +381,6 @@ static struct rockchip_pin_bank rv1126_pin_banks[] = {
  static const struct rockchip_pin_ctrl rv1126_pin_ctrl = {
  	.pin_banks		= rv1126_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rv1126_pin_banks),
-	.nr_pins		= 130,
  	.grf_mux_offset		= 0x10004, /* mux offset from GPIO0_D0 */
  	.pmu_mux_offset		= 0x0,
  	.iomux_routes		= rv1126_mux_route_data,
#3 lore raw

PATCH v2 2/13 pinctrl: rockchip: constify rockchip_pin_ctrl for PX30

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-px30.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-px30.c +1 -1
index cc7885bae40802eccfc2cad377727da9ee899139..4595d8a4a23fbf1299ab382fb92eca32527ae637 100644
@@ -324,7 +324,7 @@ static struct rockchip_pin_bank px30_pin_banks[] = {
 			    ),
 };
 
-static struct rockchip_pin_ctrl px30_pin_ctrl = {
+static const struct rockchip_pin_ctrl px30_pin_ctrl = {
 	.pin_banks		= px30_pin_banks,
 	.nr_banks		= ARRAY_SIZE(px30_pin_banks),
 	.grf_mux_offset		= 0x0,
Signature · 1 line
2.48.1
Reviewed-by on v2 2/13
#4 lore raw

Re: [PATCH v2 02/13] pinctrl: rockchip: constify rockchip_pin_ctrl for PX30

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-px30.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-px30.c +1 -1
index cc7885bae40802eccfc2cad377727da9ee899139..4595d8a4a23fbf1299ab382fb92eca32527ae637 100644
@@ -324,7 +324,7 @@ static struct rockchip_pin_bank px30_pin_banks[] = {
  			    ),
  };
 
-static struct rockchip_pin_ctrl px30_pin_ctrl = {
+static const struct rockchip_pin_ctrl px30_pin_ctrl = {
  	.pin_banks		= px30_pin_banks,
  	.nr_banks		= ARRAY_SIZE(px30_pin_banks),
  	.grf_mux_offset		= 0x0,
#5 lore raw

PATCH v2 3/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3036

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3036.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3036.c +1 -1
index b14386ccd937d2fcced72b6c9be6f7809194d3c1..8d0c0e0b6552a28e10758eff178e56e1dd0f865e 100644
@@ -80,7 +80,7 @@ static struct rockchip_pin_bank rk3036_pin_banks[] = {
 	PIN_BANK(2, 32, "gpio2"),
 };
 
-static struct rockchip_pin_ctrl rk3036_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3036_pin_ctrl = {
 	.pin_banks		= rk3036_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3036_pin_banks),
 	.grf_mux_offset		= 0xa8,
Signature · 1 line
2.48.1
Reviewed-by on v2 3/13
#6 lore raw

Re: [PATCH v2 03/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3036

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3036.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3036.c +1 -1
index b14386ccd937d2fcced72b6c9be6f7809194d3c1..8d0c0e0b6552a28e10758eff178e56e1dd0f865e 100644
@@ -80,7 +80,7 @@ static struct rockchip_pin_bank rk3036_pin_banks[] = {
  	PIN_BANK(2, 32, "gpio2"),
  };
 
-static struct rockchip_pin_ctrl rk3036_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3036_pin_ctrl = {
  	.pin_banks		= rk3036_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3036_pin_banks),
  	.grf_mux_offset		= 0xa8,
#7 lore raw

PATCH v2 4/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3066

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3066.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3066.c +1 -1
index 60e088a9a6f0d9133cd0822a9f4816cea18a524d..f773f2a3dab86dc866965cdcfd9b56da9e777acc 100644
@@ -82,7 +82,7 @@ static struct rockchip_pin_bank rk3066_pin_banks[] = {
 	PIN_BANK(6, 16, "gpio6"),
 };
 
-static struct rockchip_pin_ctrl rk3066_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3066_pin_ctrl = {
 	.pin_banks		= rk3066_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3066_pin_banks),
 	.grf_mux_offset		= 0xa8,
Signature · 1 line
2.48.1
Reviewed-by on v2 4/13
#8 lore raw

Re: [PATCH v2 04/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3066

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3066.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3066.c +1 -1
index 60e088a9a6f0d9133cd0822a9f4816cea18a524d..f773f2a3dab86dc866965cdcfd9b56da9e777acc 100644
@@ -82,7 +82,7 @@ static struct rockchip_pin_bank rk3066_pin_banks[] = {
  	PIN_BANK(6, 16, "gpio6"),
  };
 
-static struct rockchip_pin_ctrl rk3066_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3066_pin_ctrl = {
  	.pin_banks		= rk3066_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3066_pin_banks),
  	.grf_mux_offset		= 0xa8,
#9 lore raw

PATCH v2 5/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3128

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3128.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3128.c +1 -1
index d00fc3da8b234667a86d0afea10e47b700cb1e00..9f9c358694ac615f78011b196c22e1b597771c97 100644
@@ -171,7 +171,7 @@ static struct rockchip_pin_bank rk3128_pin_banks[] = {
 	PIN_BANK(3, 32, "gpio3"),
 };
 
-static struct rockchip_pin_ctrl rk3128_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3128_pin_ctrl = {
 	.pin_banks		= rk3128_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3128_pin_banks),
 	.grf_mux_offset		= 0xa8,
Signature · 1 line
2.48.1
Reviewed-by on v2 5/13
#10 lore raw

Re: [PATCH v2 05/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3128

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3128.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3128.c +1 -1
index d00fc3da8b234667a86d0afea10e47b700cb1e00..9f9c358694ac615f78011b196c22e1b597771c97 100644
@@ -171,7 +171,7 @@ static struct rockchip_pin_bank rk3128_pin_banks[] = {
  	PIN_BANK(3, 32, "gpio3"),
  };
 
-static struct rockchip_pin_ctrl rk3128_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3128_pin_ctrl = {
  	.pin_banks		= rk3128_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3128_pin_banks),
  	.grf_mux_offset		= 0xa8,
#11 lore raw

PATCH v2 6/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3188

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3188.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3188.c +1 -1
index 83db51f66ae43c713a3f80a5442d1f8467a918e9..3a93db5622d70b85dafeea54e064d6df3551f35d 100644
@@ -105,7 +105,7 @@ static struct rockchip_pin_bank rk3188_pin_banks[] = {
 	PIN_BANK(3, 32, "gpio3"),
 };
 
-static struct rockchip_pin_ctrl rk3188_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3188_pin_ctrl = {
 	.pin_banks		= rk3188_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3188_pin_banks),
 	.grf_mux_offset		= 0x60,
Signature · 1 line
2.48.1
Reviewed-by on v2 6/13
#12 lore raw

Re: [PATCH v2 06/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3188

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3188.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3188.c +1 -1
index 83db51f66ae43c713a3f80a5442d1f8467a918e9..3a93db5622d70b85dafeea54e064d6df3551f35d 100644
@@ -105,7 +105,7 @@ static struct rockchip_pin_bank rk3188_pin_banks[] = {
  	PIN_BANK(3, 32, "gpio3"),
  };
 
-static struct rockchip_pin_ctrl rk3188_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3188_pin_ctrl = {
  	.pin_banks		= rk3188_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3188_pin_banks),
  	.grf_mux_offset		= 0x60,
#13 lore raw

PATCH v2 7/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3228

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk322x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk322x.c +1 -1
index b804597c048415f3875222b201442fc025b35658..a80978685d4c84edf4297e24958b52a147b3c1f7 100644
@@ -257,7 +257,7 @@ static struct rockchip_pin_bank rk3228_pin_banks[] = {
 	PIN_BANK(3, 32, "gpio3"),
 };
 
-static struct rockchip_pin_ctrl rk3228_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3228_pin_ctrl = {
 	.pin_banks		= rk3228_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3228_pin_banks),
 	.grf_mux_offset		= 0x0,
Signature · 1 line
2.48.1
Reviewed-by on v2 7/13
#14 lore raw

Re: [PATCH v2 07/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3228

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk322x.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk322x.c +1 -1
index b804597c048415f3875222b201442fc025b35658..a80978685d4c84edf4297e24958b52a147b3c1f7 100644
@@ -257,7 +257,7 @@ static struct rockchip_pin_bank rk3228_pin_banks[] = {
  	PIN_BANK(3, 32, "gpio3"),
  };
 
-static struct rockchip_pin_ctrl rk3228_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3228_pin_ctrl = {
  	.pin_banks		= rk3228_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3228_pin_banks),
  	.grf_mux_offset		= 0x0,
#15 lore raw

PATCH v2 8/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3288

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3288.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3288.c +1 -1
index 3870c1b7a341f998cc0b3cfcaa3a0acbdd0daa39..d3ad1f70e5d60929fafff533c41bd66d1afb3401 100644
@@ -212,7 +212,7 @@ static struct rockchip_pin_bank rk3288_pin_banks[] = {
 	PIN_BANK(8, 16, "gpio8"),
 };
 
-static struct rockchip_pin_ctrl rk3288_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3288_pin_ctrl = {
 	.pin_banks		= rk3288_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3288_pin_banks),
 	.grf_mux_offset		= 0x0,
Signature · 1 line
2.48.1
Reviewed-by on v2 8/13
#16 lore raw

Re: [PATCH v2 08/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3288

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3288.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3288.c +1 -1
index 3870c1b7a341f998cc0b3cfcaa3a0acbdd0daa39..d3ad1f70e5d60929fafff533c41bd66d1afb3401 100644
@@ -212,7 +212,7 @@ static struct rockchip_pin_bank rk3288_pin_banks[] = {
  	PIN_BANK(8, 16, "gpio8"),
  };
 
-static struct rockchip_pin_ctrl rk3288_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3288_pin_ctrl = {
  	.pin_banks		= rk3288_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3288_pin_banks),
  	.grf_mux_offset		= 0x0,
#17 lore raw

PATCH v2 9/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3308

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3308.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3308.c +1 -1
index 2cd91b10a3bdbb55cf1e1a56a1b3a240a2899047..5c0e34a7baad835c54f6975017d7e183db5cd84d 100644
@@ -421,7 +421,7 @@ static struct rockchip_pin_bank rk3308_pin_banks[] = {
 					     IOMUX_8WIDTH_2BIT),
 };
 
-static struct rockchip_pin_ctrl rk3308_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3308_pin_ctrl = {
 	.pin_banks		= rk3308_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3308_pin_banks),
 	.grf_mux_offset		= 0x0,
Signature · 1 line
2.48.1
Reviewed-by on v2 9/13
#18 lore raw

Re: [PATCH v2 09/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3308

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3308.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3308.c +1 -1
index 2cd91b10a3bdbb55cf1e1a56a1b3a240a2899047..5c0e34a7baad835c54f6975017d7e183db5cd84d 100644
@@ -421,7 +421,7 @@ static struct rockchip_pin_bank rk3308_pin_banks[] = {
  					     IOMUX_8WIDTH_2BIT),
  };
 
-static struct rockchip_pin_ctrl rk3308_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3308_pin_ctrl = {
  	.pin_banks		= rk3308_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3308_pin_banks),
  	.grf_mux_offset		= 0x0,
#19 lore raw

PATCH v2 10/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3328

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3328.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3328.c +1 -1
index 47c2e923a1bb5292bdbe934a91fdb78404c37327..cc9f20a2e43e66d19375b5a112a4abddd81fa2ff 100644
@@ -285,7 +285,7 @@ static struct rockchip_pin_bank rk3328_pin_banks[] = {
 			     0),
 };
 
-static struct rockchip_pin_ctrl rk3328_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3328_pin_ctrl = {
 	.pin_banks		= rk3328_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3328_pin_banks),
 	.grf_mux_offset		= 0x0,
Signature · 1 line
2.48.1
Reviewed-by on v2 10/13
#20 lore raw

Re: [PATCH v2 10/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3328

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3328.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3328.c +1 -1
index 47c2e923a1bb5292bdbe934a91fdb78404c37327..cc9f20a2e43e66d19375b5a112a4abddd81fa2ff 100644
@@ -285,7 +285,7 @@ static struct rockchip_pin_bank rk3328_pin_banks[] = {
  			     0),
  };
 
-static struct rockchip_pin_ctrl rk3328_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3328_pin_ctrl = {
  	.pin_banks		= rk3328_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3328_pin_banks),
  	.grf_mux_offset		= 0x0,
#21 lore raw

PATCH v2 11/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3368

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3368.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3368.c +1 -1
index 9ae06ed19e9cda76f6d466fce2e01f48520a668a..aaf24719a16e191478ea407846bd50fc4cd29210 100644
@@ -152,7 +152,7 @@ static struct rockchip_pin_bank rk3368_pin_banks[] = {
 	PIN_BANK(3, 32, "gpio3"),
 };
 
-static struct rockchip_pin_ctrl rk3368_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3368_pin_ctrl = {
 	.pin_banks		= rk3368_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3368_pin_banks),
 	.grf_mux_offset		= 0x0,
Signature · 1 line
2.48.1
Reviewed-by on v2 11/13
#22 lore raw

Re: [PATCH v2 11/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3368

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3368.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3368.c +1 -1
index 9ae06ed19e9cda76f6d466fce2e01f48520a668a..aaf24719a16e191478ea407846bd50fc4cd29210 100644
@@ -152,7 +152,7 @@ static struct rockchip_pin_bank rk3368_pin_banks[] = {
  	PIN_BANK(3, 32, "gpio3"),
  };
 
-static struct rockchip_pin_ctrl rk3368_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3368_pin_ctrl = {
  	.pin_banks		= rk3368_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3368_pin_banks),
  	.grf_mux_offset		= 0x0,
#23 lore raw

PATCH v2 12/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3399

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rk3399.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3399.c +1 -1
index b7a5092c032ba3bac0889921d9421bf0d3cd7277..928ed59aec6903fafa97ef6c3f95ad22422475fc 100644
@@ -279,7 +279,7 @@ static struct rockchip_pin_bank rk3399_pin_banks[] = {
 			   ),
 };
 
-static struct rockchip_pin_ctrl rk3399_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3399_pin_ctrl = {
 	.pin_banks		= rk3399_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rk3399_pin_banks),
 	.grf_mux_offset		= 0xe000,
Signature · 1 line
2.48.1
Reviewed-by on v2 12/13
#24 lore raw

Re: [PATCH v2 12/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RK3399

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rk3399.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rk3399.c +1 -1
index b7a5092c032ba3bac0889921d9421bf0d3cd7277..928ed59aec6903fafa97ef6c3f95ad22422475fc 100644
@@ -279,7 +279,7 @@ static struct rockchip_pin_bank rk3399_pin_banks[] = {
  			   ),
  };
 
-static struct rockchip_pin_ctrl rk3399_pin_ctrl = {
+static const struct rockchip_pin_ctrl rk3399_pin_ctrl = {
  	.pin_banks		= rk3399_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rk3399_pin_banks),
  	.grf_mux_offset		= 0xe000,
#25 lore raw

PATCH v2 13/13 pinctrl: rockchip: constify rockchip_pin_ctrl for RV1108

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

---
 drivers/pinctrl/rockchip/pinctrl-rv1108.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rv1108.c +1 -1
index 3eff5f59598c0d9ea9393a1b5e1a82efa8449eb6..780da1e946ea6361fb4c3cad0299296051cee77a 100644
@@ -263,7 +263,7 @@ static struct rockchip_pin_bank rv1108_pin_banks[] = {
 	PIN_BANK_IOMUX_FLAGS(3, 32, "gpio3", 0, 0, 0, 0),
 };
 
-static struct rockchip_pin_ctrl rv1108_pin_ctrl = {
+static const struct rockchip_pin_ctrl rv1108_pin_ctrl = {
 	.pin_banks		= rv1108_pin_banks,
 	.nr_banks		= ARRAY_SIZE(rv1108_pin_banks),
 	.grf_mux_offset		= 0x10,
Signature · 1 line
2.48.1
Reviewed-by on v2 13/13
#26 lore raw

Re: [PATCH v2 13/13] pinctrl: rockchip: constify rockchip_pin_ctrl for RV1108

Quoted 6 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

There's no need to modify private data from the controller, so let's make that struct const.

Thanks,
- Kever

Quoted 18 lines
---
  drivers/pinctrl/rockchip/pinctrl-rv1108.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/rockchip/pinctrl-rv1108.c +1 -1
index 3eff5f59598c0d9ea9393a1b5e1a82efa8449eb6..780da1e946ea6361fb4c3cad0299296051cee77a 100644
@@ -263,7 +263,7 @@ static struct rockchip_pin_bank rv1108_pin_banks[] = {
  	PIN_BANK_IOMUX_FLAGS(3, 32, "gpio3", 0, 0, 0, 0),
  };
 
-static struct rockchip_pin_ctrl rv1108_pin_ctrl = {
+static const struct rockchip_pin_ctrl rv1108_pin_ctrl = {
  	.pin_banks		= rv1108_pin_banks,
  	.nr_banks		= ARRAY_SIZE(rv1108_pin_banks),
  	.grf_mux_offset		= 0x10,
#27 lore raw
In reply to Quentin Schulz

Hi Kever,

Quoted 15 lines · Quentin Schulz

While testing some WIP work done by Ilias Apalodimas on guaranteeing read-only memory areas truly are handled as read-only[1], my RK3588 Tiger couldn't reach U-Boot CLI anymore because of the pinctrl driver modifying a const struct rockchip_pin_ctrl, triggering a CPU abort.

Instead of going the lazy way and unconstify it, let's fix the actual issue in play.

This also means we should be able to constify the private data of the controller device for all Rockchip devices, instead of having those only for RK356x, RK3588 and RV1126. With the constify done on top of Ilias patch series[1], my PX30 Ringneck, RK3399 Puma and RK3588 Tiger all reach U-Boot CLI. No further testing (like booting into Linux userspace) was done.

Quoted 4 lines

[1] https://lore.kernel.org/u-boot/[email protected]/

---

Gentle ping as I don't see it in your u-boot-rockchip custodian tree right now? I see that you added your Reviewed-by on the v1, but please take the v2!

Cheers,
Quentin