linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Qian Cai <quic_qiancai@quicinc.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Laurentiu Tudor <laurentiu.tudor@nxp.com>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] software node: Skip duplicated software_node sysfs
Date: Tue, 2 Nov 2021 10:28:41 +0200	[thread overview]
Message-ID: <YYD2uXPcnFmiy54c@kuha.fi.intel.com> (raw)
In-Reply-To: <CAHp75VcrWPdR8EVGpcsniQedT0J4X700N7thFs6+srTP1MTgwQ@mail.gmail.com>

On Tue, Nov 02, 2021 at 01:51:34AM +0200, Andy Shevchenko wrote:
> On Monday, November 1, 2021, Qian Cai <quic_qiancai@quicinc.com> wrote:
> 
> > A recent commit allowed device_create_managed_software_node() to call
> > software_node_notify() which could generate duplicated "software_node"
> > sysfs files. For example,
> >
> > "/devices/platform/808622B7:01/xhci-hcd.3.auto/software_node"
> >
> > Since it was created earlier from another path,
> >
> >   sysfs_create_link
> >   software_node_notify
> >   device_add
> >   platform_device_add
> >   dwc3_host_init
> >   dwc3_probe
> >   platform_probe
> >   really_probe.part.0
> >   really_probe
> >   __driver_probe_device
> >   driver_probe_device
> >   __driver_attach
> >   bus_for_each_dev
> >   driver_attach
> >   bus_add_driver
> >   driver_register
> >   __platform_driver_register
> >   dwc3_driver_init at drivers/usb/dwc3/core.c:2072
> >   do_one_initcall
> >
> > Fixed it by using sysfs_create_link_nowarn() in software_node_notify() to
> > avoid those bad messages during booting,
> 
> 
> 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.

I'm actually not sure what is going on in this case, because this is
the ACPI enumerated BSW board, at least based on the ACPI ID?

That board should not have the initial secondary fwnode assigned by
the time the dwc3 host driver is called.


> sysfs: cannot create duplicatefilename '/devices/platform/808622B7:
> > 01/xhci-hcd.3.auto/software_node'
> >  Call trace:
> >   dump_backtrace
> >   show_stack
> >   dump_stack_lvl
> >   dump_stack
> >   sysfs_warn_dup
> >   sysfs_do_create_link_sd.isra.0
> >   sysfs_create_link
> >   software_node_notify
> >   device_create_managed_software_node
> >   iort_named_component_init
> >   iort_iommu_configure_id
> >   acpi_dma_configure_id
> >   platform_dma_configure
> >   really_probe.part.0
> >   really_probe
> >   __driver_probe_device
> >   driver_probe_device
> >   __driver_attach
> >   bus_for_each_dev
> >   driver_attach
> >   bus_add_driver
> >   driver_register
> >   __platform_driver_register
> >   xhci_plat_init
> >   do_one_initcall
> >   kernel_init_freeable
> >   kernel_init
> >   ret_from_fork
> >
> > Fixes: 5aeb05b27f81 ("software node: balance refcount for managed software
> > nodes")
> > Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
> > ---
> >  drivers/base/swnode.c | 14 ++++++--------
> >  1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> > index 4debcea4fb12..0a266c312aa3 100644
> > --- a/drivers/base/swnode.c
> > +++ b/drivers/base/swnode.c
> > @@ -1126,17 +1126,15 @@ void software_node_notify(struct device *dev)
> >         if (!swnode)
> >                 return;
> >
> > -       ret = sysfs_create_link(&dev->kobj, &swnode->kobj,
> > "software_node");
> > -       if (ret)
> > +       ret = sysfs_create_link_nowarn(&dev->kobj, &swnode->kobj,
> > +                                      "software_node");
> > +       if (ret && ret != -EEXIST)
> >                 return;
> >
> > -       ret = sysfs_create_link(&swnode->kobj, &dev->kobj, dev_name(dev));
> > -       if (ret) {
> > +       if (!sysfs_create_link(&swnode->kobj, &dev->kobj, dev_name(dev)))
> > +               kobject_get(&swnode->kobj);
> > +       else if (!ret)
> >                 sysfs_remove_link(&dev->kobj, "software_node");
> > -               return;
> > -       }
> > -
> > -       kobject_get(&swnode->kobj);
> >  }
> >
> >  void software_node_notify_remove(struct device *dev)

thanks,

-- 
heikki

  parent reply	other threads:[~2021-11-02  8:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 20:03 [RFC PATCH] software node: Skip duplicated software_node sysfs Qian Cai
     [not found] ` <CAHp75VcrWPdR8EVGpcsniQedT0J4X700N7thFs6+srTP1MTgwQ@mail.gmail.com>
2021-11-02  8:28   ` Heikki Krogerus [this message]
2021-11-02  8:32     ` Heikki Krogerus
2021-11-02 14:17     ` Qian Cai
2021-11-02 19:44   ` Qian Cai
2021-11-02 20:20     ` Andy Shevchenko
2021-11-02 20:26       ` Andy Shevchenko
2021-11-05 18:47   ` Qian Cai
2021-11-05 19:39     ` Andy Shevchenko
2021-11-08 16:07       ` Qian Cai
2021-11-08 18:06         ` Andy Shevchenko
2021-11-09  4:43           ` Qian Cai
2021-11-09 15:23             ` Qian Cai
2021-11-16  3:54       ` Qian Cai
2021-11-16 16:29         ` Rafael J. Wysocki
2021-11-17 14:38           ` Qian Cai
2021-11-17 14:45             ` Rafael J. Wysocki
2021-11-17 16:18               ` Qian Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YYD2uXPcnFmiy54c@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_qiancai@quicinc.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).