public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jordan Hand <jorhand@linux.microsoft.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org, linux-next@vger.kernel.org
Subject: Re: [PATCH] software node: recursively unregister child swnodes
Date: Fri, 5 Jun 2020 09:54:59 +0200	[thread overview]
Message-ID: <20200605075459.GB2209311@kroah.com> (raw)
In-Reply-To: <c6150824-60d3-11ad-ba1a-e75d6a7a916e@linux.microsoft.com>

On Thu, Jun 04, 2020 at 01:57:01PM -0700, Jordan Hand wrote:
> On 6/4/20 1:15 PM, Greg Kroah-Hartman wrote:
> > On Thu, Jun 04, 2020 at 12:36:23PM -0700, jorhand@linux.microsoft.com wrote:
> > > From: Jordan Hand <jorhand@linux.microsoft.com>
> > > 
> > > If a child swnode is unregistered after it's parent, it can lead to
> > > undefined behavior.
> > 
> > Crashing the system is not really "undefined" :)
> 
> Fair point :)
> 
> > 
> > > When a swnode is unregistered, recursively free it's children to avoid
> > > this condition.
> > 
> > Are you sure?  Why would you be unregistering a child after it's parent?
> > Why not just do not do that?
> > 
> 
> The main motivation for doing this was to support
> `software_node_unregister_nodes` so that the passed list of nodes does not
> need to be ordered in any particular way.
> 
> I suppose another way to do this would be to add a new function
> `fwnode_remove_software_node_recursive` and just call that from
> `software_node_unregister_nodes`.
> 
> That said, I suppose just ordering the nodes so that children come before
> parents would also be fine. My thinking was just that accepting any node
> ordering is simpler.

Right now, the way the driver model and sysfs/kobjects work is that all
objects must be removed in child-first order.  The problem of your
change where you want to try to remove the devices in parent-first order
is that you do not really know if you still have a reference to a child
device somewhere else, which would prevent this all from happening
correctly, right?

So if you "know" it is safe to drop a child, that's great, and expected.
Don't work to make  this one tiny user of the kobjects (which I'm still
not quite sure why they are kobjects and not devices), do things in a
different way from the rest of the kernel without a strong reason to do
so.

thanks,

greg k-h

  parent reply	other threads:[~2020-06-05  7:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 19:36 [PATCH] software node: recursively unregister child swnodes jorhand
2020-06-04 20:15 ` Greg Kroah-Hartman
2020-06-04 20:57   ` Jordan Hand
2020-06-04 23:28     ` Jordan Hand
2020-06-05  7:54     ` Greg Kroah-Hartman [this message]
2020-06-05 16:20       ` Jordan Hand

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=20200605075459.GB2209311@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jorhand@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --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