netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Russell King <linux@armlinux.org.uk>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Jonathan Corbet <corbet@lwn.net>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-doc@vger.kernel.org, David Jander <david@protonic.nl>
Subject: Re: [PATCH net-next v1 7/7] ethtool: add interface to interact with Ethernet Power Equipment
Date: Sat, 20 Aug 2022 20:48:34 +0200	[thread overview]
Message-ID: <YwEsgpVPNtmvtYni@lunn.ch> (raw)
In-Reply-To: <20220819120109.3857571-8-o.rempel@pengutronix.de>

> +static int pse_get_pse_attributs(struct net_device *dev,
> +				 struct pse_reply_data *data)
> +{
> +	struct phy_device *phydev = dev->phydev;
> +	int ret;
> +
> +	if (!phydev)
> +		return -EOPNOTSUPP;
> +
> +	mutex_lock(&phydev->lock);
> +	if (!phydev->psec) {
> +		ret = -EOPNOTSUPP;
> +		goto error_unlock;
> +	}
> +
> +	ret = pse_podl_get_admin_sate(phydev->psec);
> +	if (ret < 0)
> +		goto error_unlock;

The locking is triggering all sorts of questions in my mind... I don't
have the answers yet, so consider this more a discussion.

You need somewhere to place the psec. Since we are talking power over
copper lines, there will be some sort of PHY, so phydev->psec seems
reasonable. However, there is a general trend of moving all DSA
Ethernet switches to phylink, which is going to make this a bit
tricker to actually get to the phydev object.

But using phydev->lock? Humm. At least in the PoE world, there seems
to be lots of I2C or SPI controllers. Why hold the phydev lock when
performing an I2C transaction? You have a generic linux regulator
driver. How would you see a generic C45.2.9 driver? If it calls in the
PHY driver, the lock is already held, and we have to be careful to not
deadlock.

I'm more thinking along the lines of psec should have a lock of its
own.  pse_podl_get_admin_state(), pse_podl_get_pw_d_status() etc
should take that mutex before calling to the actual driver.

For a PHY which actually supports C45.2.9, i hope that the phylib core
looks at the phy driver structure, sees that some pse_podl ops are
implemented, and instantiates and registers a psec object. The phylib
core provides wrappers, which take the phylib lock before calling into
the driver. And if the PHY strictly follows C45.2.9, the calls are
actually into phylib helpers. Otherwise the PHY driver can do its own
implementation.

     Andrew

      parent reply	other threads:[~2022-08-20 18:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 12:01 [PATCH net-next v1 0/7] add generic PSE support Oleksij Rempel
2022-08-19 12:01 ` [PATCH net-next v1 1/7] dt-bindings: net: pse-dt: add bindings for generic PSE controller Oleksij Rempel
2022-08-22 18:41   ` Rob Herring
2022-08-23 16:22     ` Oleksij Rempel
2022-08-19 12:01 ` [PATCH net-next v1 2/7] dt-bindings: net: phy: add PoDL PSE property Oleksij Rempel
2022-08-22 18:45   ` Rob Herring
2022-08-22 19:34     ` Andrew Lunn
2022-08-23 14:44       ` Oleksij Rempel
2022-08-19 12:01 ` [PATCH net-next v1 3/7] net: add framework to support Ethernet PSE and PDs devices Oleksij Rempel
2022-08-19 12:01 ` [PATCH net-next v1 4/7] net: pse-pd: add generic PSE driver Oleksij Rempel
2022-08-19 20:54   ` Andrew Lunn
2022-08-20 12:00     ` Oleksij Rempel
2022-08-19 21:32   ` Andrew Lunn
2022-08-20 12:10     ` Oleksij Rempel
2022-08-19 12:01 ` [PATCH net-next v1 5/7] net: mdiobus: fwnode_mdiobus_register_phy() rework error handling Oleksij Rempel
2022-08-19 12:01 ` [PATCH net-next v1 6/7] net: mdiobus: search for PSE nodes by parsing PHY nodes Oleksij Rempel
2022-08-19 12:01 ` [PATCH net-next v1 7/7] ethtool: add interface to interact with Ethernet Power Equipment Oleksij Rempel
2022-08-19 16:44   ` kernel test robot
2022-08-19 18:37   ` kernel test robot
2022-08-19 21:15   ` Andrew Lunn
2022-08-20 12:31     ` Oleksij Rempel
2022-08-20  3:08   ` Bagas Sanjaya
2022-08-20 18:16   ` Andrew Lunn
2022-08-21  4:39     ` Oleksij Rempel
2022-08-20 18:48   ` Andrew Lunn [this message]

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=YwEsgpVPNtmvtYni@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=david@protonic.nl \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@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).