Re: [PATCH] software node: balance refcount for managed sw nodes
From: Heikki Krogerus
Date: Tue Sep 14 2021 - 10:13:18 EST
On Fri, Sep 10, 2021 at 04:00:49PM +0300, Laurentiu Tudor wrote:
> >> I've spent some time looking into this and it turns out that in the
> >> ACPI case, device_create_managed_software_node() ends up being called
> >> twice, first here [1] and after that, in the IORT code here [2]. With
> >> the proposed patch this causes software_node_notify(KOBJ_ADD) being
> >> called twice thus triggering the dup sysfs entry warning.
> >> Any comments / ideas welcomed.
> >>
> >> [1] https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/host.c#L111
> >
> > I think the problem here is that the secondary fwnode get's replaced
> > because the primary fwnode is shared. Can you test it with this, just
> > to see if the problem goes away:
> >
> > diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> > index f29a264635aa1..e4b40f8b8f242 100644
> > --- a/drivers/usb/dwc3/host.c
> > +++ b/drivers/usb/dwc3/host.c
> > @@ -76,7 +76,6 @@ int dwc3_host_init(struct dwc3 *dwc)
> > }
> >
> > xhci->dev.parent = dwc->dev;
> > - ACPI_COMPANION_SET(&xhci->dev, ACPI_COMPANION(dwc->dev));
> >
> > dwc->xhci = xhci;
>
>
> Thanks for looking into this! Yes, this does make the issue go away.
We need to think about how to solve this one. The problem is that we
have to share the ACPI node between the parent dwc3 device and child
xHCI, but at the same xHCI needs to have its own software node.
The fwnode->secondary pointer does not quite bend to this. If the
primary fwnode is shared, the secondary fwnode has to be shared as
well.
thanks,
--
heikki