lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <TYCPR01MB11332395B91D672D6BD46CECD8687A@TYCPR01MB11332.jpnprd01.prod.outlook.com>
Date: Tue, 6 Jan 2026 15:41:10 +0000
From: Biju Das <biju.das.jz@...renesas.com>
To: Frank Li <Frank.li@....com>
CC: Tommaso Merciai <tommaso.merciai.xr@...renesas.com>, Tommaso Merciai
	<tomm.merciai@...il.com>, "linux-renesas-soc@...r.kernel.org"
	<linux-renesas-soc@...r.kernel.org>, wsa+renesas
	<wsa+renesas@...g-engineering.com>, Alexandre Belloni
	<alexandre.belloni@...tlin.com>, Philipp Zabel <p.zabel@...gutronix.de>,
	Geert Uytterhoeven <geert+renesas@...der.be>, magnus.damm
	<magnus.damm@...il.com>, "linux-i3c@...ts.infradead.org"
	<linux-i3c@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v4 1/4] i3c: renesas: Switch to clk_bulk API and store
 clocks in private data

Hi Frank Li,

> -----Original Message-----
> From: Frank Li <Frank.li@....com>
> Sent: 06 January 2026 15:17
> Subject: Re: [PATCH v4 1/4] i3c: renesas: Switch to clk_bulk API and store clocks in private data
> 
> On Tue, Jan 06, 2026 at 03:01:49PM +0000, Biju Das wrote:
> > Hi Frank Li,
> >
> > Thanks for the feedback.
> >
> > > -----Original Message-----
> > > From: Frank Li <Frank.li@....com>
> > > Sent: 06 January 2026 14:49
> > > Subject: Re: [PATCH v4 1/4] i3c: renesas: Switch to clk_bulk API and
> > > store clocks in private data
> > >
> > > On Mon, Jan 05, 2026 at 06:06:19PM +0000, Biju Das wrote:
> > > > Hi Frank Li,
> > > >
> > > > > -----Original Message-----
> > > > > From: Frank Li <Frank.li@....com>
> > > > > Sent: 05 January 2026 17:12
> > > > > Subject: Re: [PATCH v4 1/4] i3c: renesas: Switch to clk_bulk API
> > > > > and store clocks in private data
> > > > >
> > > > > On Mon, Jan 05, 2026 at 11:49:59AM +0100, Tommaso Merciai wrote:
> > > > > > Replace individual devm_clk_get_enabled() calls with the
> > > > > > clk_bulk API and store the clock handles in the driver's private data structure.
> > > > > >
> > > > > > All clocks required by the controller are now acquired and
> > > > > > enabled using devm_clk_bulk_get_all_enabled(), removing the
> > > > > > need for per-SoC clock handling and the renesas_i3c_config data.
> > > > > > The TCLK is accessed via a fixed index in the bulk clock array.
> > > > > >
> > > > > > Simplify the code and prepare the driver for upcoming
> > > > > > suspend/resume support.
> > > > > >
> > > > > > No functional change intended.
> > > > > >
> > > > > > Reviewed-by: Biju Das <biju.das.jz@...renesas.com>
> > > > > > Signed-off-by: Tommaso Merciai
> > > > > > <tommaso.merciai.xr@...renesas.com>
> > > > > > ---
> > > > > > v3->v4:
> > > > > >  - Collected Biju Das tag.
> > > > > >
> > > > > > v2->v3:
> > > > > >  - Added define for TCLK index.
> > > > > >  - Use devm_clk_bulk_get_all_enabled() into renesas_i3c_probe().
> > > > > >  - Improved commit body.
> > > > > >  - Dropped unnecessary static const char * const renesas_i3c_clks[].
> > > > > >  - Removed the need for per-SoC clock handling and the renesas_i3c_config data.
> > > > > >
> > > > > > v1->v2:
> > > > > >  - New patch.
> > > > > >
> > > > > >  drivers/i3c/master/renesas-i3c.c | 43
> > > > > > ++++++++------------------------
> > > > > >  1 file changed, 11 insertions(+), 32 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/i3c/master/renesas-i3c.c
> > > > > > b/drivers/i3c/master/renesas-i3c.c
> > > > > > index 426a418f29b6..1b8f4be9ad67 100644
> > > > > > --- a/drivers/i3c/master/renesas-i3c.c
> > > > > > +++ b/drivers/i3c/master/renesas-i3c.c
> > > > > > @@ -198,6 +198,8 @@
> > > > > >  #define RENESAS_I3C_MAX_DEVS	8
> > > > > >  #define I2C_INIT_MSG		-1
> > > > > >
> > > > > > +#define RENESAS_I3C_TCLK_IDX	1
> > > > > > +
> > > > > >  enum i3c_internal_state {
> > > > > >  	I3C_INTERNAL_STATE_DISABLED,
> > > > > >  	I3C_INTERNAL_STATE_CONTROLLER_IDLE,
> > > > > > @@ -259,7 +261,8 @@ struct renesas_i3c {
> > > > > >  	u8 addrs[RENESAS_I3C_MAX_DEVS];
> > > > > >  	struct renesas_i3c_xferqueue xferqueue;
> > > > > >  	void __iomem *regs;
> > > > > > -	struct clk *tclk;
> > > > > > +	struct clk_bulk_data *clks;
> > > > > > +	u8 num_clks;
> > > > > >  };
> > > > > >
> > > > > >  struct renesas_i3c_i2c_dev_data { @@ -272,10 +275,6 @@ struct
> > > > > > renesas_i3c_irq_desc {
> > > > > >  	const char *desc;
> > > > > >  };
> > > > > >
> > > > > > -struct renesas_i3c_config {
> > > > > > -	unsigned int has_pclkrw:1;
> > > > > > -};
> > > > > > -
> > > > > >  static inline void renesas_i3c_reg_update(void __iomem *reg,
> > > > > > u32 mask, u32 val)  {
> > > > > >  	u32 data = readl(reg);
> > > > > > @@ -489,7 +488,7 @@ static int renesas_i3c_bus_init(struct i3c_master_controller *m)
> > > > > >  	int od_high_ticks, od_low_ticks, i2c_total_ticks;
> > > > > >  	int ret;
> > > > > >
> > > > > > -	rate = clk_get_rate(i3c->tclk);
> > > > > > +	rate = clk_get_rate(i3c->clks[RENESAS_I3C_TCLK_IDX].clk);
> > > > > >  	if (!rate)
> > > > > >  		return -EINVAL;
> > > > > >
> > > > > > @@ -1302,13 +1301,8 @@ static int renesas_i3c_probe(struct
> > > > > > platform_device *pdev)  {
> > > > > >  	struct renesas_i3c *i3c;
> > > > > >  	struct reset_control *reset;
> > > > > > -	struct clk *clk;
> > > > > > -	const struct renesas_i3c_config *config = of_device_get_match_data(&pdev->dev);
> > > > > >  	int ret, i;
> > > > > >
> > > > > > -	if (!config)
> > > > > > -		return -ENODATA;
> > > > > > -
> > > > > >  	i3c = devm_kzalloc(&pdev->dev, sizeof(*i3c), GFP_KERNEL);
> > > > > >  	if (!i3c)
> > > > > >  		return -ENOMEM;
> > > > > > @@ -1317,19 +1311,11 @@ static int renesas_i3c_probe(struct platform_device *pdev)
> > > > > >  	if (IS_ERR(i3c->regs))
> > > > > >  		return PTR_ERR(i3c->regs);
> > > > > >
> > > > > > -	clk = devm_clk_get_enabled(&pdev->dev, "pclk");
> > > > > > -	if (IS_ERR(clk))
> > > > > > -		return PTR_ERR(clk);
> > > > > > -
> > > > > > -	if (config->has_pclkrw) {
> > > > > > -		clk = devm_clk_get_enabled(&pdev->dev, "pclkrw");
> > > > > > -		if (IS_ERR(clk))
> > > > > > -			return PTR_ERR(clk);
> > > > > > -	}
> > > > > > +	ret = devm_clk_bulk_get_all_enabled(&pdev->dev, &i3c->clks);
> > > > > > +	if (ret < 0)
> > > > > > +		return ret;
> > > > > >
> > > > > > -	i3c->tclk = devm_clk_get_enabled(&pdev->dev, "tclk");
> > > > > > -	if (IS_ERR(i3c->tclk))
> > > > > > -		return PTR_ERR(i3c->tclk);
> > > > > > +	i3c->num_clks = ret;
> > > > >
> > > > > Need check num_clks > RENESAS_I3C_TCLK_IDX to avoid outbound
> > > > > access at
> > > > > i3c->clks[RENESAS_I3C_TCLK_IDX].clk
> > > >
> > > > I guess dt binding check validate this as well. Eg: a single clk
> > > > defined in the DT instead of minimum 2, will give DT warnings.
> > > >
> > > > Do you expect additional check in C code as well?
> > >
> > > Yes, worry about a wrong dtb cause kernel crash. Direct access
> > > i3c->clks[RENESAS_I3C_TCLK_IDX] without check is risk.  if clock
> > > i3c->wrong in
> > > dtb,generally, it just impact function. but this may cause crash. So
> > > I suggest add addtional check here.
> >
> > OK, to avoid a crash num_clks > RENESAS_I3C_TCLK_IDX check is
> > sufficient
> 
> Yes,
> 
> > But it does not check whether tclk in 0th entry or first entry.
> >
> > >
> > > Or search 'tclk' in array i3c->clks.
> > > for (i = 0; i < i3c->num_clks; i++)
> > > 	if (!strcmp("tclk", i3c->clks[i]->id))
> > > 		break;
> >
> > But this returns correct index of the "tclk"
> 
> This is just more flexiable for clk schema. If your schema is simple enough check num_clks >
> RENESAS_I3C_TCLK_IDX should be enough.

For avoiding crash that check is sufficient, but as you said wrong dtb like crash
can also lead to non-functional i3c device

Eg:

>From bindings, we expect the below entries in DTS for RZ/G3S

"pclk", "tclk" for RZ/G3S

But user mistakenly just added "pclk", that will lead to kernel crash

Or

Swap the clocks

"tclk", "pclk" this will lead to non-functional i3c device

On both cases, user ignored DT binding check warnings.

As you said crash is fatal, maybe stick with just num_clks > RENESAS_I3C_TCLK_IDX

Cheers,
Biju

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ