From: Florian Fainelli <f.fainelli@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>,
Lino Sanfilippo <LinoSanfilippo@gmx.de>,
Saravana Kannan <saravanak@google.com>
Cc: p.rosenberger@kunbus.com, woojung.huh@microchip.com,
UNGLinuxDriver@microchip.com, andrew@lunn.ch,
vivien.didelot@gmail.com, davem@davemloft.net, kuba@kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] Fix for KSZ DSA switch shutdown
Date: Thu, 9 Sep 2021 19:15:40 -0700 [thread overview]
Message-ID: <35466c02-16da-0305-6d53-1c3bbf326418@gmail.com> (raw)
In-Reply-To: <20210909225457.figd5e5o3yw76mcs@skbuf>
On 9/9/2021 3:54 PM, Vladimir Oltean wrote:
[snip]
> Question 6: How about a patch on the device core that is more lightweight?
> Wouldn't it be sensible for device_shutdown() to just call ->remove if
> the device's bus has no ->shutdown, and the device's driver doesn't have
> a ->shutdown either?
>
> Answer: This would sometimes work, the vast majority of DSA switch
> drivers, and Ethernet controllers (in this case used as DSA masters) do
> not have a .shutdown method implemented. But their bus does: PCI does,
> SPI controllers do, most of the time. So it would work for limited
> scenarios, but would be ineffective in the general sense.
Having wondered about that question as well, I don't really see a
compelling reason as to why we do not default to calling .remove() when
.shutdown() is not implemented. In almost all of the cases the semantics
of .remove() are superior to those required by .shutdown().
>
> Question 7: I said that .shutdown, as opposed to .remove, doesn't really
> care so much about the integrity of data structures. So how far should
> we really go to fix this issue? Should we even bother to unbind the
> whole DSA tree, when the sole problem is that we are the DSA master's
> upper, and that is keeping a reference on it?
>
> Answer: Well, any solution that does unnecessary data structure teardown
> only delays the reboot for nothing. Lino's patch just bluntly calls
> dsa_tree_teardown() from the switch .shutdown method, and this leaks
> memory, namely dst->ports. But does this really matter? Nope, so let's
> extrapolate. In this case, IMO, the simplest possible solution would be
> to patch bcmgenet to not unregister the net device. Then treat every
> other DSA master driver in the same way as they come, one by one.
> Do you need to unregister_netdevice() at shutdown? No. Then don't.
> Is it nice? Probably not, but I'm not seeing alternatives.
It does not really scale but we also don't have that many DSA masters to
support, I believe I can name them all: bcmgenet, stmmac, bcmsysport,
enetc, mv643xx_eth, cpsw, macb. If you want me to patch bcmgenet, give
me a few days to test and make sure there is no power management
regression, that's the primary concern I have.
>
> Also, unless I'm missing something, Lino probably still sees the WARN_ON
> in bcmgenet's unregister_netdevice() about eth0 getting unregistered
> while having an upper interface. If not, it's by sheer luck that the DSA
> switch's ->shutdown gets called before bcmgenet's ->shutdown. But for
> this reason, it isn't a great solution either. If the device links can't
> guarantee us some sort of shutdown ordering (what we ideally want, as
> mentioned, is for the DSA switch driver to get _unbound_ (->remove)
> before the DSA master gets unbound or shut down).
>
All of your questions are good and I don't have answers to any of them,
however I would like you and others to reason about .shutdown() not just
in the context of a reboot, or kexec'd kernel but also in the context of
putting the system into ACPI S5 (via poweroff). In that case the goal is
not only to quiesce the device, the goal is also to put it in a low
power mode.
For bcmgenet specifically the code path that leads to a driver remove is
well tested and is guaranteeing the network device registration, thus
putting the PHY into suspend, shutting down DMAs, turning off clocks.
This is a big hammer, but it gets the job done and does not introduce
yet another code path to test, it's the same as the module removal.
--
Florian
next prev parent reply other threads:[~2021-09-10 2:15 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 9:53 [PATCH 0/3] Fix for KSZ DSA switch shutdown Lino Sanfilippo
2021-09-09 9:53 ` [PATCH 1/3] net: dsa: introduce function dsa_tree_shutdown() Lino Sanfilippo
2021-09-09 9:53 ` [PATCH 2/3] net: dsa: microchip: provide the function ksz_switch_shutdown() Lino Sanfilippo
2021-09-09 9:53 ` [PATCH 3/3] net: dsa: microchip: tear down DSA tree at system shutdown Lino Sanfilippo
2021-09-09 10:14 ` [PATCH 0/3] Fix for KSZ DSA switch shutdown Vladimir Oltean
2021-09-09 11:08 ` Lino Sanfilippo
2021-09-09 11:42 ` Vladimir Oltean
2021-09-09 12:56 ` Vladimir Oltean
2021-09-09 13:19 ` Aw: " Lino Sanfilippo
2021-09-09 14:29 ` Lino Sanfilippo
2021-09-09 15:17 ` Andrew Lunn
2021-09-09 16:41 ` Lino Sanfilippo
2021-09-09 15:11 ` Andrew Lunn
2021-09-09 16:46 ` Lino Sanfilippo
2021-09-09 17:55 ` Andrew Lunn
2021-09-09 15:47 ` Vladimir Oltean
2021-09-09 16:00 ` Florian Fainelli
2021-09-10 1:32 ` Saravana Kannan
2021-09-09 16:37 ` Lino Sanfilippo
2021-09-09 16:44 ` Florian Fainelli
2021-09-09 17:07 ` Lino Sanfilippo
2021-09-09 22:54 ` Vladimir Oltean
2021-09-09 23:23 ` Vladimir Oltean
2021-09-10 1:08 ` Vladimir Oltean
2021-09-10 2:15 ` Florian Fainelli [this message]
2021-09-10 11:51 ` Andrew Lunn
2021-09-10 14:58 ` Vladimir Oltean
2021-09-11 11:44 ` Vladimir Oltean
[not found] ` <53f2509f-b648-b33d-1542-17a2c9d69966@gmx.de>
2021-09-12 20:29 ` Vladimir Oltean
2021-09-13 10:32 ` Aw: " Lino Sanfilippo
2021-09-13 10:44 ` Vladimir Oltean
2021-09-13 11:01 ` Aw: " Lino Sanfilippo
2021-09-14 18:48 ` Vladimir Oltean
2021-09-15 5:42 ` Lino Sanfilippo
2021-09-18 19:37 ` Lino Sanfilippo
2021-09-18 22:04 ` Vladimir Oltean
2021-09-19 0:29 ` Vladimir Oltean
2021-09-09 12:40 ` Andrew Lunn
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=35466c02-16da-0305-6d53-1c3bbf326418@gmail.com \
--to=f.fainelli@gmail.com \
--cc=LinoSanfilippo@gmx.de \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=p.rosenberger@kunbus.com \
--cc=saravanak@google.com \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.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