Subject: Re: [PATCH RFC net-next 1/7] software node: allow named software node to be created

From: Andy Shevchenko <[email-masked]>
Date: Thu, 23 Mar 2023 16:39:29 +0200

On Thu, Mar 23, 2023 at 02:29:24PM +0000, Russell King (Oracle) wrote:
> On Thu, Mar 23, 2023 at 03:59:07PM +0200, Andy Shevchenko wrote:
> > On Wed, Mar 22, 2023 at 11:59:55AM +0000, Russell King wrote:
> > > From: Vladimir Oltean <[email-masked]>
> > > 
> > > Allow a named software node to be created, which is needed for software
> > > nodes for a fixed-link specification for DSA.

...

> > > +fwnode_create_named_software_node(const struct property_entry *properties,
> > > +				  const struct fwnode_handle *parent,
> > > +				  const char *name)
> > >  {
> > >  	struct fwnode_handle *fwnode;
> > >  	struct software_node *node;
> > > @@ -930,6 +931,7 @@ fwnode_create_software_node(const struct property_entry *properties,
> > >  		return ERR_CAST(node);
> > >  
> > >  	node->parent = p ? p->node : NULL;
> > > +	node->name = name;
> > 
> > The same question stays as before: how can we be sure that the name is unique
> > and we won't have a collision?
> 
> This got discussed at length last time around, starting here:
> 
> https://lore.kernel.org/all/[email-masked]/
> 
> My conclusion is that your concern is invalid, because we're creating
> this tree:
> 
> 	node%d
> 	+- phy-mode property
> 	`- fixed-link node
> 	   +- speed property
> 	   `- full-duplex (optional) property
> 
> Given that node%d will be allocated against the swnode_root_ids IDA,
> then how can there possibly be a naming collision.
> 
> You would be correct if the "fixed-link" node were to be created at
> root level, or if we were intentionally creating two swnodes under
> the same parent with the same name, but we aren't.
> 
> Plus, the code _already_ allows for e.g. multiple "node1" names - for
> example, one in root and one as a child node, since the code uses
> separate IDAs to allocate those.
> 
> Hence, I do not recognise the conern you are raising, and I believe
> your concern is not valid.
> 
> Your concern would be valid if it was a general concern about
> fwnode_create_named_software_node() being used to create the same
> named node under the same parent, but that IMHO is a programming
> bug, no different from trying to create two devices under the same
> parent with the same name.
> 
> So, unless you can be more expansive about _precisely_ what your
> concern is, then I don't think there exists any problem with this.

OK.

I leave it to others to review. I have nothing to add.

-- 
With Best Regards,
Andy Shevchenko