All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Samuel Holland <samuel@sholland.org>
Cc: u-boot@lists.denx.de, Jagan Teki <jagan@amarulasolutions.com>,
	Lukasz Majewski <lukma@denx.de>,
	Sean Anderson <seanga2@gmail.com>, Bin Meng <bmeng.cn@gmail.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Maxime Ripard <maxime.ripard@bootlin.com>
Subject: Re: [PATCH 1/7] clk: sunxi: Store the array sizes in the CCU descriptor
Date: Sat, 25 Jun 2022 18:10:48 +0100	[thread overview]
Message-ID: <20220625181048.57e935c6@slackpad.lan> (raw)
In-Reply-To: <20220509052937.42283-2-samuel@sholland.org>

On Mon,  9 May 2022 00:29:31 -0500
Samuel Holland <samuel@sholland.org> wrote:

> The reset array size is currently used for bounds checking in the reset
> driver. The same bounds check should really be done in the clock driver.
> 
> Currently, the array size is provided to the reset driver separately
> from the CCU descriptor, which is a bit strange. Let's do this the usual
> way, with the array sizes next to the arrays themselves.

Checked for typos, all fine. Added the F1C100s on the way.

> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Thanks,
Andre

> ---
> 
>  drivers/clk/sunxi/clk_a10.c   | 2 ++
>  drivers/clk/sunxi/clk_a10s.c  | 2 ++
>  drivers/clk/sunxi/clk_a23.c   | 2 ++
>  drivers/clk/sunxi/clk_a31.c   | 2 ++
>  drivers/clk/sunxi/clk_a31_r.c | 2 ++
>  drivers/clk/sunxi/clk_a64.c   | 2 ++
>  drivers/clk/sunxi/clk_a80.c   | 4 ++++
>  drivers/clk/sunxi/clk_a83t.c  | 2 ++
>  drivers/clk/sunxi/clk_h3.c    | 2 ++
>  drivers/clk/sunxi/clk_h6.c    | 2 ++
>  drivers/clk/sunxi/clk_h616.c  | 2 ++
>  drivers/clk/sunxi/clk_h6_r.c  | 2 ++
>  drivers/clk/sunxi/clk_r40.c   | 2 ++
>  drivers/clk/sunxi/clk_v3s.c   | 2 ++
>  include/clk/sunxi.h           | 2 ++
>  15 files changed, 32 insertions(+)
> 
> diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
> index 90b929d3d3..6b58cffc8a 100644
> --- a/drivers/clk/sunxi/clk_a10.c
> +++ b/drivers/clk/sunxi/clk_a10.c
> @@ -65,6 +65,8 @@ static struct ccu_reset a10_resets[] = {
>  static const struct ccu_desc a10_ccu_desc = {
>  	.gates = a10_gates,
>  	.resets = a10_resets,
> +	.num_gates = ARRAY_SIZE(a10_gates),
> +	.num_resets = ARRAY_SIZE(a10_resets),
>  };
>  
>  static int a10_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
> index addf4f4d5c..81b146ce1e 100644
> --- a/drivers/clk/sunxi/clk_a10s.c
> +++ b/drivers/clk/sunxi/clk_a10s.c
> @@ -50,6 +50,8 @@ static struct ccu_reset a10s_resets[] = {
>  static const struct ccu_desc a10s_ccu_desc = {
>  	.gates = a10s_gates,
>  	.resets = a10s_resets,
> +	.num_gates = ARRAY_SIZE(a10s_gates),
> +	.num_resets = ARRAY_SIZE(a10s_resets),
>  };
>  
>  static int a10s_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
> index c45d2c3529..c7c78bc7d8 100644
> --- a/drivers/clk/sunxi/clk_a23.c
> +++ b/drivers/clk/sunxi/clk_a23.c
> @@ -69,6 +69,8 @@ static struct ccu_reset a23_resets[] = {
>  static const struct ccu_desc a23_ccu_desc = {
>  	.gates = a23_gates,
>  	.resets = a23_resets,
> +	.num_gates = ARRAY_SIZE(a23_gates),
> +	.num_resets = ARRAY_SIZE(a23_resets),
>  };
>  
>  static int a23_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
> index 251fc3b705..c8c7f4ecf5 100644
> --- a/drivers/clk/sunxi/clk_a31.c
> +++ b/drivers/clk/sunxi/clk_a31.c
> @@ -90,6 +90,8 @@ static struct ccu_reset a31_resets[] = {
>  static const struct ccu_desc a31_ccu_desc = {
>  	.gates = a31_gates,
>  	.resets = a31_resets,
> +	.num_gates = ARRAY_SIZE(a31_gates),
> +	.num_resets = ARRAY_SIZE(a31_resets),
>  };
>  
>  static int a31_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_a31_r.c b/drivers/clk/sunxi/clk_a31_r.c
> index 1f08ea956f..7bf1c4578c 100644
> --- a/drivers/clk/sunxi/clk_a31_r.c
> +++ b/drivers/clk/sunxi/clk_a31_r.c
> @@ -31,6 +31,8 @@ static struct ccu_reset a31_r_resets[] = {
>  static const struct ccu_desc a31_r_ccu_desc = {
>  	.gates = a31_r_gates,
>  	.resets = a31_r_resets,
> +	.num_gates = ARRAY_SIZE(a31_r_gates),
> +	.num_resets = ARRAY_SIZE(a31_r_resets),
>  };
>  
>  static int a31_r_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
> index 1004a79503..6da861ddc1 100644
> --- a/drivers/clk/sunxi/clk_a64.c
> +++ b/drivers/clk/sunxi/clk_a64.c
> @@ -76,6 +76,8 @@ static const struct ccu_reset a64_resets[] = {
>  static const struct ccu_desc a64_ccu_desc = {
>  	.gates = a64_gates,
>  	.resets = a64_resets,
> +	.num_gates = ARRAY_SIZE(a64_gates),
> +	.num_resets = ARRAY_SIZE(a64_resets),
>  };
>  
>  static int a64_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c
> index 8a0834d83a..7025d3cbe6 100644
> --- a/drivers/clk/sunxi/clk_a80.c
> +++ b/drivers/clk/sunxi/clk_a80.c
> @@ -75,11 +75,15 @@ static const struct ccu_reset a80_mmc_resets[] = {
>  static const struct ccu_desc a80_ccu_desc = {
>  	.gates = a80_gates,
>  	.resets = a80_resets,
> +	.num_gates = ARRAY_SIZE(a80_gates),
> +	.num_resets = ARRAY_SIZE(a80_resets),
>  };
>  
>  static const struct ccu_desc a80_mmc_clk_desc = {
>  	.gates = a80_mmc_gates,
>  	.resets = a80_mmc_resets,
> +	.num_gates = ARRAY_SIZE(a80_mmc_gates),
> +	.num_resets = ARRAY_SIZE(a80_mmc_resets),
>  };
>  
>  static int a80_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
> index 8c6043f51e..c50d253f84 100644
> --- a/drivers/clk/sunxi/clk_a83t.c
> +++ b/drivers/clk/sunxi/clk_a83t.c
> @@ -73,6 +73,8 @@ static struct ccu_reset a83t_resets[] = {
>  static const struct ccu_desc a83t_ccu_desc = {
>  	.gates = a83t_gates,
>  	.resets = a83t_resets,
> +	.num_gates = ARRAY_SIZE(a83t_gates),
> +	.num_resets = ARRAY_SIZE(a83t_resets),
>  };
>  
>  static int a83t_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
> index 59afba53ee..22c2b236a8 100644
> --- a/drivers/clk/sunxi/clk_h3.c
> +++ b/drivers/clk/sunxi/clk_h3.c
> @@ -89,6 +89,8 @@ static struct ccu_reset h3_resets[] = {
>  static const struct ccu_desc h3_ccu_desc = {
>  	.gates = h3_gates,
>  	.resets = h3_resets,
> +	.num_gates = ARRAY_SIZE(h3_gates),
> +	.num_resets = ARRAY_SIZE(h3_resets),
>  };
>  
>  static int h3_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c
> index 4a53788352..6521811215 100644
> --- a/drivers/clk/sunxi/clk_h6.c
> +++ b/drivers/clk/sunxi/clk_h6.c
> @@ -90,6 +90,8 @@ static struct ccu_reset h6_resets[] = {
>  static const struct ccu_desc h6_ccu_desc = {
>  	.gates = h6_gates,
>  	.resets = h6_resets,
> +	.num_gates = ARRAY_SIZE(h6_gates),
> +	.num_resets = ARRAY_SIZE(h6_resets),
>  };
>  
>  static int h6_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_h616.c b/drivers/clk/sunxi/clk_h616.c
> index af97d3bb9f..26f74c0fa0 100644
> --- a/drivers/clk/sunxi/clk_h616.c
> +++ b/drivers/clk/sunxi/clk_h616.c
> @@ -108,6 +108,8 @@ static struct ccu_reset h616_resets[] = {
>  static const struct ccu_desc h616_ccu_desc = {
>  	.gates = h616_gates,
>  	.resets = h616_resets,
> +	.num_gates = ARRAY_SIZE(h616_gates),
> +	.num_resets = ARRAY_SIZE(h616_resets),
>  };
>  
>  static int h616_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c
> index b9e527e16a..fee9604551 100644
> --- a/drivers/clk/sunxi/clk_h6_r.c
> +++ b/drivers/clk/sunxi/clk_h6_r.c
> @@ -35,6 +35,8 @@ static struct ccu_reset h6_r_resets[] = {
>  static const struct ccu_desc h6_r_ccu_desc = {
>  	.gates = h6_r_gates,
>  	.resets = h6_r_resets,
> +	.num_gates = ARRAY_SIZE(h6_r_gates),
> +	.num_resets = ARRAY_SIZE(h6_r_resets),
>  };
>  
>  static int h6_r_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
> index 4d5b69a976..456a38a159 100644
> --- a/drivers/clk/sunxi/clk_r40.c
> +++ b/drivers/clk/sunxi/clk_r40.c
> @@ -100,6 +100,8 @@ static struct ccu_reset r40_resets[] = {
>  static const struct ccu_desc r40_ccu_desc = {
>  	.gates = r40_gates,
>  	.resets = r40_resets,
> +	.num_gates = ARRAY_SIZE(r40_gates),
> +	.num_resets = ARRAY_SIZE(r40_resets),
>  };
>  
>  static int r40_clk_bind(struct udevice *dev)
> diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
> index cce5c658ca..ab21cd791b 100644
> --- a/drivers/clk/sunxi/clk_v3s.c
> +++ b/drivers/clk/sunxi/clk_v3s.c
> @@ -50,6 +50,8 @@ static struct ccu_reset v3s_resets[] = {
>  static const struct ccu_desc v3s_ccu_desc = {
>  	.gates = v3s_gates,
>  	.resets = v3s_resets,
> +	.num_gates = ARRAY_SIZE(v3s_gates),
> +	.num_resets = ARRAY_SIZE(v3s_resets),
>  };
>  
>  static int v3s_clk_bind(struct udevice *dev)
> diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h
> index a2239b990b..5471b9c831 100644
> --- a/include/clk/sunxi.h
> +++ b/include/clk/sunxi.h
> @@ -65,6 +65,8 @@ struct ccu_reset {
>  struct ccu_desc {
>  	const struct ccu_clk_gate *gates;
>  	const struct ccu_reset *resets;
> +	u8 num_gates;
> +	u8 num_resets;
>  };
>  
>  /**


  reply	other threads:[~2022-06-27  0:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  5:29 [PATCH 0/7] clk: sunxi: Out-of-bounds access fix and driver cleanup Samuel Holland
2022-05-09  5:29 ` [PATCH 1/7] clk: sunxi: Store the array sizes in the CCU descriptor Samuel Holland
2022-06-25 17:10   ` Andre Przywara [this message]
2022-05-09  5:29 ` [PATCH 2/7] clk: sunxi: Prevent out-of-bounds gate array access Samuel Holland
2022-06-26 10:43   ` Andre Przywara
2022-05-09  5:29 ` [PATCH 3/7] reset: sunxi: Get the reset count from the CCU descriptor Samuel Holland
2022-06-26 10:51   ` Andre Przywara
2022-05-09  5:29 ` [PATCH 4/7] clk: sunxi: Use a single driver for all variants Samuel Holland
2022-06-27  0:43   ` Andre Przywara
2022-05-09  5:29 ` [PATCH 5/7] clk: sunxi: Convert driver private data to platform data Samuel Holland
2022-06-27 19:34   ` Andre Przywara
2022-05-09  5:29 ` [PATCH 6/7] reset: " Samuel Holland
2022-06-27 19:41   ` Andre Przywara
2022-05-09  5:29 ` [PATCH 7/7] reset: sunxi: Reuse the platform data from the clock driver Samuel Holland
2022-06-27 23:45   ` Andre Przywara
2022-05-10 23:24 ` [PATCH 0/7] clk: sunxi: Out-of-bounds access fix and driver cleanup Andre Przywara
2022-05-11 15:48 ` Sean Anderson
2022-06-28  0:40 ` Andre Przywara
2022-06-28  2:45   ` Samuel Holland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220625181048.57e935c6@slackpad.lan \
    --to=andre.przywara@arm.com \
    --cc=bmeng.cn@gmail.com \
    --cc=jagan@amarulasolutions.com \
    --cc=lukma@denx.de \
    --cc=maxime.ripard@bootlin.com \
    --cc=samuel@sholland.org \
    --cc=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.