Re: [RFC PATCH] software node: Skip duplicated software_node sysfs

From: Andy Shevchenko
Date: Fri Nov 05 2021 - 15:40:37 EST


On Fri, Nov 5, 2021 at 8:47 PM Qian Cai <quic_qiancai@xxxxxxxxxxx> wrote:
> On 11/1/21 7:51 PM, Andy Shevchenko wrote:
> > No, it’s not so easy. What you are doing is a papering over the real issue
> > which is the limitation of the firmware nodes to two. What we need is to
> > drop the link from struct fwnode_handle, move it to upper layer and modify
> > all fwnode ops to be used over the list of fwnode:s.
> >
> > XHCI driver and DWC3 are sharing the primary fwnode, but at the same time
> > they wanted to have _different_ secondary ones when role is switched. This
> > can’t be done in the current design. And here is the symptom what you got.
>
> Andy, thanks for the pointers so far. I was able to trace
> set_primary_fwnode() and set_secondary_fwnode().

Can you share the trace you have got?

> Anyway, what's the "upper layer"? Is that "struct device" or "struct
> swnode"? I suppose you meant:

struct device here.

> - Remove "secondary" field from "struct fwnode_handle".
> - Replace "fwnode" from "upper layer" with
> "struct list_head fwnode_head;".
> - Modify all functions in "software_node_ops" to use "fwnode_head".
>
> Is that correct?

Yes.

It might be a bit complicated taking into account how much fwnode is
spreaded in the kernel... Basically, you need to fix all direct
accesses to the dev->fwnode first.
Besides that you need to check that fwnode, which is used out of the
device scope, like in IRQ domains, doesn't use secondary pointer(s).

This nevertheless adds a lot of flexibility and we may add whatever
type of fwnodes and mix them together.

--
With Best Regards,
Andy Shevchenko