From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Sean Anderson <sean.anderson@seco.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
Madalin Bucur <madalin.bucur@nxp.com>,
"David S . Miller" <davem@davemloft.net>,
Paolo Abeni <pabeni@redhat.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
linux-kernel@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
Andrew Lunn <andrew@lunn.ch>,
Frank Rowand <frowand.list@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Saravana Kannan <saravanak@google.com>,
devicetree@vger.kernel.org
Subject: Re: [RFC PATCH net-next 3/9] net: pcs: Add helpers for registering and finding PCSs
Date: Mon, 11 Jul 2022 21:59:04 +0100 [thread overview]
Message-ID: <YsyPGMOiIGktUlqD@shell.armlinux.org.uk> (raw)
In-Reply-To: <20220711160519.741990-4-sean.anderson@seco.com>
Hi Sean,
It's a good attempt and may be nice to have, but I'm afraid the
implementation has a flaw to do with the lifetime of data structures
which always becomes a problem when we have multiple devices being
used in aggregate.
On Mon, Jul 11, 2022 at 12:05:13PM -0400, Sean Anderson wrote:
> +/**
> + * pcs_get_tail() - Finish getting a PCS
> + * @pcs: The PCS to get, or %NULL if one could not be found
> + *
> + * This performs common operations necessary when getting a PCS (chiefly
> + * incrementing reference counts)
> + *
> + * Return: @pcs, or an error pointer on failure
> + */
> +static struct phylink_pcs *pcs_get_tail(struct phylink_pcs *pcs)
> +{
> + if (!pcs)
> + return ERR_PTR(-EPROBE_DEFER);
> +
> + if (!try_module_get(pcs->ops->owner))
> + return ERR_PTR(-ENODEV);
What you're trying to prevent here is the PCS going away - but holding a
reference to the module doesn't prevent that with the driver model. The
driver model design is such that a device can be unbound from its driver
at any moment. Taking a reference to the module doesn't prevent that,
all it does is ensure that the user can't remove the module. It doesn't
mean that the "pcs" structure will remain allocated.
The second issue that this creates is if a MAC driver creates the PCS
and then "gets" it through this interface, then the MAC driver module
ends up being locked in until the MAC driver devices are all unbound,
which isn't friendly at all.
So, anything that proposes to create a new subsystem where we have
multiple devices that make up an aggregate device needs to nicely cope
with any of those devices going away. For that to happen in this
instance, phylink would need to know that its in-use PCS for a
particular MAC is going away, then it could force the link down before
removing all references to the PCS device.
Another solution would be devlinks, but I am really not a fan of that
when there may be a single struct device backing multiple network
interfaces, where some of them may require PCS and others do not. One
wouldn't want the network interface with nfs-root to suddenly go away
because a PCS was unbound from its driver!
> + get_device(pcs->dev);
This helps, but not enough. All it means is the struct device won't
go away, the "pcs" can still go away if the device is unbound from the
driver.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2022-07-11 20:59 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 16:05 [RFC PATCH net-next 0/9] net: pcs: Add support for devices probed in the "usual" manner Sean Anderson
2022-07-11 16:05 ` [RFC PATCH net-next 1/9] dt-bindings: net: Add lynx PCS Sean Anderson
2022-07-12 8:47 ` Krzysztof Kozlowski
2022-07-12 14:57 ` Sean Anderson
2022-07-12 15:00 ` Krzysztof Kozlowski
2022-07-12 15:06 ` Sean Anderson
2022-07-11 16:05 ` [RFC PATCH net-next 2/9] dt-bindings: net: Expand pcs-handle to an array Sean Anderson
2022-07-12 8:51 ` Krzysztof Kozlowski
2022-07-12 15:06 ` Sean Anderson
2022-07-12 15:18 ` Krzysztof Kozlowski
2022-07-12 15:23 ` Sean Anderson
2022-07-12 15:59 ` Russell King (Oracle)
2022-07-14 10:45 ` Krzysztof Kozlowski
2022-07-18 19:46 ` Rob Herring
2022-07-11 16:05 ` [RFC PATCH net-next 3/9] net: pcs: Add helpers for registering and finding PCSs Sean Anderson
2022-07-11 19:42 ` Saravana Kannan
2022-07-11 19:53 ` Sean Anderson
2022-07-11 20:59 ` Russell King (Oracle) [this message]
2022-07-11 21:47 ` Sean Anderson
2022-07-11 21:55 ` Sean Anderson
2022-07-12 15:51 ` Russell King (Oracle)
2022-07-12 23:15 ` Sean Anderson
2022-07-11 16:05 ` [RFC PATCH net-next 7/9] arm64: dts: Add compatible strings for Lynx PCSs Sean Anderson
2022-07-11 16:05 ` [RFC PATCH net-next 8/9] powerpc: " Sean Anderson
2022-07-19 15:25 ` [RFC PATCH net-next 0/9] net: pcs: Add support for devices probed in the "usual" manner Vladimir Oltean
2022-07-19 15:28 ` Sean Anderson
2022-07-19 15:38 ` Vladimir Oltean
2022-07-19 15:46 ` Sean Anderson
2022-07-19 18:11 ` Vladimir Oltean
2022-07-19 19:34 ` Sean Anderson
2022-07-20 13:53 ` Vladimir Oltean
2022-07-21 21:42 ` Sean Anderson
[not found] ` <8622e12e-66c9-e338-27a1-07e53390881e@seco.com>
2022-07-29 22:15 ` Sean Anderson
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=YsyPGMOiIGktUlqD@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=frowand.list@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh+dt@kernel.org \
--cc=saravanak@google.com \
--cc=sean.anderson@seco.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).