[PATCH] clkdev: Update clkdev id usage to allow for longer names

Michael J. Ruhl posted 1 patch 1 year, 11 months ago
There is a newer version of this series
drivers/clk/clkdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] clkdev: Update clkdev id usage to allow for longer names
Posted by Michael J. Ruhl 1 year, 11 months ago
clkdev ID information is limited to arrays of 20 and 16 bytes
(MAX_DEV_ID/MAX_CON_ID).  It is possible that the IDs could be
longer that.  If so, the lookup will fail because the "real ID"
will not match the copied value.

Increase the size of the IDs to allow for longer names.

Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
---
 drivers/clk/clkdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index ee37d0be6877..38549db691f4 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -144,8 +144,8 @@ void clkdev_add_table(struct clk_lookup *cl, size_t num)
 	mutex_unlock(&clocks_mutex);
 }
 
-#define MAX_DEV_ID	20
-#define MAX_CON_ID	16
+#define MAX_DEV_ID	32
+#define MAX_CON_ID	32
 
 struct clk_lookup_alloc {
 	struct clk_lookup cl;
-- 
2.41.0
Re: [PATCH] clkdev: Update clkdev id usage to allow for longer names
Posted by Andy Shevchenko 1 year, 11 months ago
On Fri, Feb 23, 2024 at 09:18:14AM -0500, Michael J. Ruhl wrote:
> clkdev ID information is limited to arrays of 20 and 16 bytes
> (MAX_DEV_ID/MAX_CON_ID).  It is possible that the IDs could be
> longer that.  If so, the lookup will fail because the "real ID"
> will not match the copied value.

Perhaps you need to add a real example.

> Increase the size of the IDs to allow for longer names.

...

> -#define MAX_DEV_ID	20
> -#define MAX_CON_ID	16
> +#define MAX_DEV_ID	32
> +#define MAX_CON_ID	32

Do we need to alter both?

-- 
With Best Regards,
Andy Shevchenko
RE: [PATCH] clkdev: Update clkdev id usage to allow for longer names
Posted by Ruhl, Michael J 1 year, 11 months ago
>-----Original Message-----
>From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>Sent: Friday, February 23, 2024 10:48 AM
>To: Ruhl, Michael J <michael.j.ruhl@intel.com>
>Cc: linux@armlinux.org.uk; linux-arm-kernel@lists.infradead.org; linux-
>kernel@vger.kernel.org
>Subject: Re: [PATCH] clkdev: Update clkdev id usage to allow for longer names
>
>On Fri, Feb 23, 2024 at 09:18:14AM -0500, Michael J. Ruhl wrote:
>> clkdev ID information is limited to arrays of 20 and 16 bytes
>> (MAX_DEV_ID/MAX_CON_ID).  It is possible that the IDs could be
>> longer that.  If so, the lookup will fail because the "real ID"
>> will not match the copied value.
>
>Perhaps you need to add a real example.

How about:

Generating a device name for the I2C Designware module using the PCI
ID can result in a name of:

i2c_designware.39424

clkdev_create will store:

i2c_designware.3942

The stored name is one off and will not match correctly during probe.

>> Increase the size of the IDs to allow for longer names.
>
>...
>
>> -#define MAX_DEV_ID	20
>> -#define MAX_CON_ID	16
>> +#define MAX_DEV_ID	32
>> +#define MAX_CON_ID	32
>
>Do we need to alter both?

It wasn't clear to why there was a difference in sizes.  At the moment the CON_ID isn't
causing me an issue.  Shall I drop that part of the change?

Thanks!

Mike

>--
>With Best Regards,
>Andy Shevchenko
>
Re: [PATCH] clkdev: Update clkdev id usage to allow for longer names
Posted by Andy Shevchenko 1 year, 11 months ago
On Fri, Feb 23, 2024 at 04:09:03PM +0000, Ruhl, Michael J wrote:
> >From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >Sent: Friday, February 23, 2024 10:48 AM
> >On Fri, Feb 23, 2024 at 09:18:14AM -0500, Michael J. Ruhl wrote:
> >> clkdev ID information is limited to arrays of 20 and 16 bytes
> >> (MAX_DEV_ID/MAX_CON_ID).  It is possible that the IDs could be
> >> longer that.  If so, the lookup will fail because the "real ID"
> >> will not match the copied value.
> >
> >Perhaps you need to add a real example.
> 
> How about:
> 
> Generating a device name for the I2C Designware module using the PCI
> ID can result in a name of:
> 
> i2c_designware.39424
> 
> clkdev_create will store:

clkdev_create()

> i2c_designware.3942
> 
> The stored name is one off and will not match correctly during probe.
> 
> >> Increase the size of the IDs to allow for longer names.

...

> >> -#define MAX_DEV_ID	20
> >> -#define MAX_CON_ID	16
> >> +#define MAX_DEV_ID	32

So with the above example increasing by 4 is enough, right?
Maybe we can be modest for now as it will solve your issue?

#define MAX_DEV_ID	24

> >> +#define MAX_CON_ID	32
> >
> >Do we need to alter both?
> 
> It wasn't clear to why there was a difference in sizes.  At the moment the CON_ID isn't
> causing me an issue.  Shall I drop that part of the change?

I think so.

-- 
With Best Regards,
Andy Shevchenko