pinctrl: rockchip: fix editing const struct + constify rockchip_pin_ctrl
Subsystems (2)
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.
The member modified in the const is only ever used for setting a member from another struct (not const that one). However this other member is never read! Therefore we can simply afford to remove it which means the sole reader of the member in the const is now gone, thus making it possible to remove the member from the const struct as well.
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 branch[1], my PX30 Ringneck, RK3399 Puma and RK3588 Tiger all reach U-Boot CLI. No further test (like booting into Linux userspace) was done.
[1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/tree/fix_memory_permissions
---
Quentin Schulz (14):
pinctrl: rockchip: remove unused base_pin bank member
pinctrl: rockchip: remove unused nr_pins controller member
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 | 2 -- drivers/pinctrl/rockchip/pinctrl-rockchip.h | 3 --- drivers/pinctrl/rockchip/pinctrl-rv1108.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rv1126.c | 1 - 17 files changed, 12 insertions(+), 20 deletions(-)
---
base-commit: a2b489b170f8382f746202c36616eaf2bc38fe86
change-id: 20250129-rockchip-pinctrl-const-f4123019a584
Best regards,
Signature · 1 line
Quentin Schulz <[email protected]>
PATCH 1/14 pinctrl: rockchip: remove unused base_pin bank member
From: Quentin Schulz <[email protected]>
Each bank has a base_pin member that is only set in the core and never used, so it can be removed.
--- drivers/pinctrl/rockchip/pinctrl-rockchip-core.c | 1 - drivers/pinctrl/rockchip/pinctrl-rockchip.h | 2 -- 2 files changed, 3 deletions(-)
drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +0 -1
@@ -543,7 +543,6 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *dint bank_pins =0 ; bank->priv = priv; - bank->pin_base = ctrl->nr_pins; ctrl->nr_pins += bank->nr_pins;/* calculate iomux and drv offsets */
drivers/pinctrl/rockchip/pinctrl-rockchip.h +0 -2
@@ -262,7 +262,6 @@ struct rockchip_drv {/** * @priv: common pinctrl private basedata -* @pin_base: first pin number * @nr_pins: number of pins in this bank * @name: name of the bank * @bank_num: number of the bank, to account for holes
@@ -274,7 +273,6 @@ struct rockchip_drv {*/ struct rockchip_pin_bank {struct rockchip_pinctrl_priv *priv; -u32 pin_base;u8 nr_pins;char *name;u8 bank_num;
Signature · 1 line
2.48.1
Re: [PATCH 01/14] pinctrl: rockchip: remove unused base_pin bank member
Quoted 6 lines · Quentin Schulz
From: Quentin Schulz <[email protected]>
Each bank has a
base_pinmember that is only set in the core and never used, so it can be removed.Signed-off-by Quentin Schulz <[email protected]>
Thanks,
- Kever
Quoted 38 lines
--- drivers/pinctrl/rockchip/pinctrl-rockchip-core.c | 1 - drivers/pinctrl/rockchip/pinctrl-rockchip.h | 2 -- 2 files changed, 3 deletions(-)drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +0
-1@@ -543,7 +543,6 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *dint bank_pins =0 ; bank->priv = priv; - bank->pin_base = ctrl->nr_pins; ctrl->nr_pins += bank->nr_pins;/* calculate iomux and drv offsets */ drivers/pinctrl/rockchip/pinctrl-rockchip.h +0
-2@@ -262,7 +262,6 @@ struct rockchip_drv {/** * @priv: common pinctrl private basedata -* @pin_base: first pin number * @nr_pins: number of pins in this bank * @name: name of the bank * @bank_num: number of the bank, to account for holes @@ -274,7 +273,6 @@ struct rockchip_drv {*/ struct rockchip_pin_bank {struct rockchip_pinctrl_priv *priv; -u32 pin_base;u8 nr_pins;char *name;u8 bank_num;
PATCH 2/14 pinctrl: rockchip: remove unused nr_pins controller member
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
Each controller has an nr_pins member that is set either through the rockchip_pin_ctrl struct or from the core (or both).
This is an issue because on RK3568, RK3588 and RV1126, the struct is const, this means it shouldn't be modified at all. This will trigger a CPU abort once we enforce the read-only at the MMU level in a few releases, therefore let's remove this useless (and broken, and soon breaking) code.
--- drivers/pinctrl/rockchip/pinctrl-rk3568.c | 1 - drivers/pinctrl/rockchip/pinctrl-rk3588.c | 1 - drivers/pinctrl/rockchip/pinctrl-rockchip-core.c | 1 - drivers/pinctrl/rockchip/pinctrl-rockchip.h | 1 - drivers/pinctrl/rockchip/pinctrl-rv1126.c | 1 - 5 files changed, 5 deletions(-)
drivers/pinctrl/rockchip/pinctrl-rk3568.c +0 -1
@@ -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
@@ -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 +0 -1
@@ -543,7 +543,6 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *dint bank_pins =0 ; bank->priv = priv; - 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
@@ -498,7 +498,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
@@ -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
Re: [PATCH 02/14] pinctrl: rockchip: remove unused nr_pins controller member
Quoted 5 lines · Quentin Schulz
From: Quentin Schulz <[email protected]>
Each controller has an
nr_pinsmember that is set either through therockchip_pin_ctrlstruct or from the core (or both).
Quoted 7 lines
This is an issue because on RK3568, RK3588 and RV1126, the struct is const, this means it shouldn't be modified at all. This will trigger a CPU abort once we enforce the read-only at the MMU level in a few releases, therefore let's remove this useless (and broken, and soon breaking) code.
Signed-off-by Quentin Schulz <[email protected]>
Thanks,
- Kever
Quoted 69 lines
--- drivers/pinctrl/rockchip/pinctrl-rk3568.c | 1 - drivers/pinctrl/rockchip/pinctrl-rk3588.c | 1 - drivers/pinctrl/rockchip/pinctrl-rockchip-core.c | 1 - drivers/pinctrl/rockchip/pinctrl-rockchip.h | 1 - drivers/pinctrl/rockchip/pinctrl-rv1126.c | 1 - 5 files changed, 5 deletions(-)drivers/pinctrl/rockchip/pinctrl-rk3568.c +0
-1@@ -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@@ -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 +0
-1@@ -543,7 +543,6 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *dint bank_pins =0 ; bank->priv = priv; - 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@@ -498,7 +498,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@@ -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,
PATCH 3/14 pinctrl: rockchip: constify rockchip_pin_ctrl for PX30
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 03/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 4/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3036
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 04/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 5/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3066
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 05/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 6/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3128
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 06/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 7/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3188
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 07/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 8/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3228
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 08/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 9/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3288
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 09/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 10/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3308
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 10/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 11/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3328
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 11/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 12/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3368
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 12/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 13/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RK3399
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 13/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
PATCH 14/14 pinctrl: rockchip: constify rockchip_pin_ctrl for RV1108
In reply to Quentin SchulzFrom: 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
@@ -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
Re: [PATCH 14/14] 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.
Signed-off-by Quentin Schulz <[email protected]>
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@@ -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 ,
Hi Quentin,
Quoted 21 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.
The member modified in the const is only ever used for setting a member from another struct (not const that one). However this other member is never read! Therefore we can simply afford to remove it which means the sole reader of the member in the const is now gone, thus making it possible to remove the member from the const struct as well.
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 branch[1], my PX30 Ringneck, RK3399 Puma and RK3588 Tiger all reach U-Boot CLI. No further test (like booting into Linux userspace) was done.
Quoted 7 lines
[1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/tree/fix_memory_permissions
Signed-off-by Quentin Schulz <[email protected]>---
Quentin Schulz (14):
pinctrl: rockchip: remove unusedbase_pinbank member
pinctrl: rockchip: remove unusednr_pinscontroller member
pin_base and nr_pins is used after my "rockchip: pinctrl: Add support for pinmux status cmd" series [1].
The pin_base should probably be moved to udevice priv data or similar. nr_pins can probably also be moved to udevice priv data or constify in driver data.
Do you want me to re-work/re-store these fields in a different way once I finally send a v3 of that series?
[1] https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
Regards,
Jonas
Quoted 36 lines
pinctrl: rockchip: constify
rockchip_pin_ctrlfor PX30
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3036
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3066
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3128
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3188
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3228
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3288
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3308
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3328
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3368
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RK3399
pinctrl: rockchip: constifyrockchip_pin_ctrlfor RV1108drivers/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 | 2 -- drivers/pinctrl/rockchip/pinctrl-rockchip.h | 3 --- drivers/pinctrl/rockchip/pinctrl-rv1108.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rv1126.c | 1 - 17 files changed, 12 insertions(+), 20 deletions(-)---
base-commit:a2b489b170f8382f746202c36616eaf2bc38fe86
change-id: 20250129-rockchip-pinctrl-const-f4123019a584Best regards,
Hi Jonas,
Quoted 35 lines · Jonas Karlman
Hi Quentin,
Quoted 21 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.
The member modified in the const is only ever used for setting a member from another struct (not const that one). However this other member is never read! Therefore we can simply afford to remove it which means the sole reader of the member in the const is now gone, thus making it possible to remove the member from the const struct as well.
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 branch[1], my PX30 Ringneck, RK3399 Puma and RK3588 Tiger all reach U-Boot CLI. No further test (like booting into Linux userspace) was done.
Quoted 7 lines
[1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/tree/fix_memory_permissions
Signed-off-by Quentin Schulz <[email protected]>---
Quentin Schulz (14):
pinctrl: rockchip: remove unusedbase_pinbank member
pinctrl: rockchip: remove unusednr_pinscontroller member
pin_baseandnr_pinsis used after my "rockchip: pinctrl: Add support for pinmux status cmd" series [1].
Quoted 7 lines
The
pin_baseshould probably be moved to udevice priv data or similar.nr_pinscan probably also be moved to udevice priv data or constify in driver data.Do you want me to re-work/re-store these fields in a different way once I finally send a v3 of that series?
What I can suggest is to remove the setting of ctrl->nr_pins as I believe we shouldn't be modifying it and we don't need to store it, even in your patch series as we discussed on IRC, and keep pin_base from the bank.
What I can offer instead is to use a local variable to replace the one from the controller struct.
"""
drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +5 -3
@@ -531,20 +531,22 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *dstruct rockchip_pin_ctrl *ctrl = (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; +int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, ctrl_nr_pins, i, j; grf_offs = ctrl->grf_mux_offset; pmu_offs = ctrl->pmu_mux_offset; drv_pmu_offs = ctrl->pmu_drv_offset; drv_grf_offs = ctrl->grf_drv_offset; bank = ctrl->pin_banks; + ctrl_nr_pins =0 ; +for (i =0 ; i < ctrl->nr_banks; ++i, ++bank) {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++) {
"""
Something like that to replace patches 1 and 2. This should allow you to keep working on your other patch series without me making it too much more difficult for you to rebase?
We need this patch series in before https://lore.kernel.org/u-boot/[email protected]/T/#t gets is otherwise we don't be able to boot anymore on RK356x, RK3588 and RV1126. I don't think there's going to be much bikeshedding or controversy about my series here (in v2 if you agree with the above diff), the pinctrl series from last August seems like it could be opening many can of worms so better not rebase this series on top of that series. Do you agree with that?
Cheers,
Quentin
Hi Quentin,
Quoted 89 lines · Quentin Schulz
Hi Jonas,
Quoted 35 lines · Jonas Karlman
Hi Quentin,
Quoted 21 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.
The member modified in the const is only ever used for setting a member from another struct (not const that one). However this other member is never read! Therefore we can simply afford to remove it which means the sole reader of the member in the const is now gone, thus making it possible to remove the member from the const struct as well.
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 branch[1], my PX30 Ringneck, RK3399 Puma and RK3588 Tiger all reach U-Boot CLI. No further test (like booting into Linux userspace) was done.
Quoted 7 lines
[1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/tree/fix_memory_permissions
Signed-off-by Quentin Schulz <[email protected]>---
Quentin Schulz (14):
pinctrl: rockchip: remove unusedbase_pinbank member
pinctrl: rockchip: remove unusednr_pinscontroller member
pin_baseandnr_pinsis used after my "rockchip: pinctrl: Add support for pinmux status cmd" series [1].Quoted 7 lines
The
pin_baseshould probably be moved to udevice priv data or similar.nr_pinscan probably also be moved to udevice priv data or constify in driver data.Do you want me to re-work/re-store these fields in a different way once I finally send a v3 of that series?
What I can suggest is to remove the setting of
ctrl->nr_pinsas I believe we shouldn't be modifying it and we don't need to store it, even in your patch series as we discussed on IRC, and keeppin_basefrom the bank.What I can offer instead is to use a local variable to replace the one from the controller struct.
"""
drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +5
-3@@ -531,20 +531,22 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *d struct rockchip_pin_ctrl *ctrl = (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; +int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, ctrl_nr_pins, i, j; grf_offs = ctrl->grf_mux_offset; pmu_offs = ctrl->pmu_mux_offset; drv_pmu_offs = ctrl->pmu_drv_offset; drv_grf_offs = ctrl->grf_drv_offset; bank = ctrl->pin_banks; + ctrl_nr_pins =0 ; +for (i =0 ; i < ctrl->nr_banks; ++i, ++bank) {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++) {
"""
Quoted 3 lines
Something like that to replace patches 1 and 2. This should allow you to keep working on your other patch series without me making it too much more difficult for you to rebase?
Thanks for taking a look, and I agree this should help when I pick up and re-spin my series.
Quoted 9 lines
We need this patch series in before
https://lore.kernel.org/u-boot/[email protected]/T/#t
gets is otherwise we don't be able to boot anymore on RK356x, RK3588 and RV1126. I don't think there's going to be much bikeshedding or controversy about my series here (in v2 if you agree with the above diff), the pinctrl series from last August seems like it could be opening many can of worms so better not rebase this series on top of that series. Do you agree with that?
I fully agree, better to get this in first, I will try to re-spin my series on top of this sometime later once this has landed.
Regards,
Jonas
Quoted 3 lines
Cheers,
Quentin
Hi Jonas,
Quoted 110 lines · Jonas Karlman
Hi Quentin,
Quoted 87 lines · Quentin Schulz
Hi Jonas,
Quoted 35 lines · Jonas Karlman
Hi Quentin,
Quoted 21 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.
The member modified in the const is only ever used for setting a member from another struct (not const that one). However this other member is never read! Therefore we can simply afford to remove it which means the sole reader of the member in the const is now gone, thus making it possible to remove the member from the const struct as well.
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 branch[1], my PX30 Ringneck, RK3399 Puma and RK3588 Tiger all reach U-Boot CLI. No further test (like booting into Linux userspace) was done.
Quoted 7 lines
[1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/tree/fix_memory_permissions
Signed-off-by Quentin Schulz <[email protected]>---
Quentin Schulz (14):
pinctrl: rockchip: remove unusedbase_pinbank member
pinctrl: rockchip: remove unusednr_pinscontroller member
pin_baseandnr_pinsis used after my "rockchip: pinctrl: Add support for pinmux status cmd" series [1].Quoted 7 lines
The
pin_baseshould probably be moved to udevice priv data or similar.nr_pinscan probably also be moved to udevice priv data or constify in driver data.Do you want me to re-work/re-store these fields in a different way once I finally send a v3 of that series?
What I can suggest is to remove the setting of
ctrl->nr_pinsas I believe we shouldn't be modifying it and we don't need to store it, even in your patch series as we discussed on IRC, and keeppin_basefrom the bank.What I can offer instead is to use a local variable to replace the one from the controller struct.
"""
drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +5
-3@@ -531,20 +531,22 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(struct udevice *d struct rockchip_pin_ctrl *ctrl = (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; +int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, ctrl_nr_pins, i, j; grf_offs = ctrl->grf_mux_offset; pmu_offs = ctrl->pmu_mux_offset; drv_pmu_offs = ctrl->pmu_drv_offset; drv_grf_offs = ctrl->grf_drv_offset; bank = ctrl->pin_banks; + ctrl_nr_pins =0 ; +for (i =0 ; i < ctrl->nr_banks; ++i, ++bank) {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++) {Quoted 5 lines
"""
Something like that to replace patches 1 and 2. This should allow you to keep working on your other patch series without me making it too much more difficult for you to rebase?
Thanks for taking a look, and I agree this should help when I pick up and re-spin my series.
Quoted 9 lines
We need this patch series in before
https://lore.kernel.org/u-boot/[email protected]/T/#t
gets is otherwise we don't be able to boot anymore on RK356x, RK3588 and RV1126. I don't think there's going to be much bikeshedding or controversy about my series here (in v2 if you agree with the above diff), the pinctrl series from last August seems like it could be opening many can of worms so better not rebase this series on top of that series. Do you agree with that?
Quoted 2 lines
I fully agree, better to get this in first, I will try to re-spin my series on top of this sometime later once this has landed.
Ok, I'll post this after the weekend in case I get more review comments. Keep in mind that i'll hide it behind a Kconfig option for now, since we seem to have enough cases of code writing const variables
Cheers
/Ilias
Quoted 8 lines
Regards,
JonasQuoted 3 lines
Cheers,
Quentin