From: Leon Romanovsky <leon@kernel.org>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Asmaa Mnebhi <asmaa@nvidia.com>,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org, cai.huoqing@linux.dev,
brgl@bgdev.pl, chenhao288@hisilicon.com,
huangguangbin2@huawei.com,
David Thompson <davthompson@nvidia.com>
Subject: Re: [PATCH net v2 1/1] mlxbf_gige: Fix kernel panic at shutdown
Date: Tue, 13 Jun 2023 10:19:59 +0300 [thread overview]
Message-ID: <20230613071959.GU12152@unreal> (raw)
In-Reply-To: <20230612140521.tzhgliaok5u3q67o@skbuf>
On Mon, Jun 12, 2023 at 05:05:21PM +0300, Vladimir Oltean wrote:
> On Mon, Jun 12, 2023 at 04:38:53PM +0300, Leon Romanovsky wrote:
> > On Mon, Jun 12, 2023 at 04:28:41PM +0300, Vladimir Oltean wrote:
> > > The sequence of operations is:
> > >
> > > * device_shutdown() walks the devices_kset backwards, thus shutting down
> > > children before parents
> > > * .shutdown() method of child gets called
> > > * .shutdown() method of parent gets called
> > > * parent implements .shutdown() as .remove()
> > > * the parent's .remove() logic calls device_del() on its children
> > > * .remove() method of child gets called
> >
> > But both child and parent are locked so they parent can't call to
> > child's remove while child is performing shutdown.
>
> Please view the call chain I've posted in an email client capable of
> showing the indentation correctly.
Thanks for the suggestion, right now I'm using mutt and lore to read
emails. Should I use another email client?
> The 2 lines:
>
> * .shutdown() method of child gets called
> * .shutdown() method of parent gets called
>
> have the same level of indentation because they occur sequentially
> within the same function.
Right
>
> This means 2 things:
>
> 1. when the parent runs its .shutdown(), the .shutdown() of the child
> has already finished
Right, it is done to make sure we release childs before parents.
>
> 2. device_shutdown() only locks "dev" and "dev->parent" for the duration
> of the "dev->driver->shutdown(dev)" procedure. However, the situation
> that you deem impossible due to locking is the dev->driver->shutdown(dev)
> of the parent device. That parent wasn't found through any dev->parent
> pointer, instead it is just another device in the devices_kset list.
> The logic of locking "dev" and "dev->parent" there won't help, since
> we would be locking the parent and the parent of the parent. This
> will obviously not prevent the original parent from calling any
> method of the original child - we're already one step higher in the
> hierarchy.
But once child finishes device_shutdown(), it will be removed from devices_kset
list and dev->driver should be NULL at that point for the child. In driver core,
dev->driver is the marker if driver is bound. It means parent/bus won't/shouldn't
call to anything driver related to child which doesn't have valid dev->driver pointer.
>
> So your objection above does not really apply.
We have a different opinion here.
>
> > BTW, I read the same device_shutdown() function before my first reply
> > and came to different conclusions from you.
>
> Well, you could try to experiment with putting ".shutdown = xxx_remove,"
> in some bus drivers and see what happens.
Like I said, this is a bug in bus logic which allows calls to device
which doesn't have driver bound to it.
>
> Admittedly it was a few years ago, but I did study this problem and I
> did have to fix real issues reported by real people based on the above
> observations (which here are reproduced only from memory):
> https://lore.kernel.org/all/20210920214209.1733768-2-vladimir.oltean@nxp.com/
I believe you, just think that behaviour found in i2c/spi isn't how
device model works.
Thanks
next prev parent reply other threads:[~2023-06-13 7:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 14:03 [PATCH net v2 1/1] mlxbf_gige: Fix kernel panic at shutdown Asmaa Mnebhi
2023-06-08 23:25 ` Samudrala, Sridhar
2023-06-12 17:26 ` Jakub Kicinski
2023-06-11 18:11 ` Leon Romanovsky
2023-06-12 11:34 ` Maciej Fijalkowski
2023-06-12 11:59 ` Leon Romanovsky
2023-06-12 12:37 ` Vladimir Oltean
2023-06-12 13:17 ` Leon Romanovsky
2023-06-12 13:28 ` Vladimir Oltean
2023-06-12 13:38 ` Leon Romanovsky
2023-06-12 14:05 ` Vladimir Oltean
2023-06-13 7:19 ` Leon Romanovsky [this message]
2023-06-13 8:30 ` Vladimir Oltean
2023-06-13 9:09 ` Leon Romanovsky
2023-06-13 9:35 ` Vladimir Oltean
2023-06-13 10:10 ` Leon Romanovsky
2023-06-13 10:34 ` Vladimir Oltean
2023-06-13 11:28 ` Leon Romanovsky
2023-06-13 11:40 ` Vladimir Oltean
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=20230613071959.GU12152@unreal \
--to=leon@kernel.org \
--cc=asmaa@nvidia.com \
--cc=brgl@bgdev.pl \
--cc=cai.huoqing@linux.dev \
--cc=chenhao288@hisilicon.com \
--cc=davem@davemloft.net \
--cc=davthompson@nvidia.com \
--cc=edumazet@google.com \
--cc=huangguangbin2@huawei.com \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/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).