[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z7g-WYQNpVp5w7my@pengutronix.de>
Date: Fri, 21 Feb 2025 09:50:33 +0100
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: Kory Maincent <kory.maincent@...tlin.com>
Cc: Andrew Lunn <andrew@...n.ch>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Jonathan Corbet <corbet@....net>,
Donald Hunter <donald.hunter@...il.com>,
Rob Herring <robh@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>,
Simon Horman <horms@...nel.org>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
netdev@...r.kernel.org, linux-doc@...r.kernel.org,
Kyle Swenson <kyle.swenson@....tech>,
Dent Project <dentproject@...uxfoundation.org>,
kernel@...gutronix.de,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v5 02/12] net: pse-pd: Add support for reporting
events
Hi Kory,
On Tue, Feb 18, 2025 at 05:19:06PM +0100, Kory Maincent wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@...tlin.com>
>
> Add support for devm_pse_irq_helper() to register PSE interrupts. This aims
> to report events such as over-current or over-temperature conditions
> similarly to how the regulator API handles them but using a specific PSE
> ethtool netlink socket.
Thank you for your work. Here some comments.
...
> --- a/drivers/net/mdio/fwnode_mdio.c
> +++ b/drivers/net/mdio/fwnode_mdio.c
> @@ -18,7 +18,8 @@ MODULE_LICENSE("GPL");
> MODULE_DESCRIPTION("FWNODE MDIO bus (Ethernet PHY) accessors");
>
> static struct pse_control *
> -fwnode_find_pse_control(struct fwnode_handle *fwnode)
> +fwnode_find_pse_control(struct fwnode_handle *fwnode,
> + struct phy_device *phydev)
> {
This change seems to be not directly related to the commit message.
Is it the preparation for the multi-phy support?
> struct pse_control *psec;
> struct device_node *np;
> @@ -30,7 +31,7 @@ fwnode_find_pse_control(struct fwnode_handle *fwnode)
> if (!np)
> return NULL;
>
> - psec = of_pse_control_get(np);
> + psec = of_pse_control_get(np, phydev);
> if (PTR_ERR(psec) == -ENOENT)
> return NULL;
>
> @@ -128,15 +129,9 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> u32 phy_id;
> int rc;
>
> - psec = fwnode_find_pse_control(child);
> - if (IS_ERR(psec))
> - return PTR_ERR(psec);
> -
> mii_ts = fwnode_find_mii_timestamper(child);
> - if (IS_ERR(mii_ts)) {
> - rc = PTR_ERR(mii_ts);
> - goto clean_pse;
> - }
> + if (IS_ERR(mii_ts))
> + return PTR_ERR(mii_ts);
>
> is_c45 = fwnode_device_is_compatible(child, "ethernet-phy-ieee802.3-c45");
> if (is_c45 || fwnode_get_phy_id(child, &phy_id))
> @@ -169,6 +164,12 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> goto clean_phy;
> }
>
> + psec = fwnode_find_pse_control(child, phy);
> + if (IS_ERR(psec)) {
> + rc = PTR_ERR(psec);
> + goto unregister_phy;
> + }
> +
> phy->psec = psec;
>
> /* phy->mii_ts may already be defined by the PHY driver. A
> @@ -180,12 +181,13 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
>
> return 0;
>
> +unregister_phy:
> + if (is_acpi_node(child) || is_of_node(child))
> + phy_device_remove(phy);
> clean_phy:
> phy_device_free(phy);
> clean_mii_ts:
> unregister_mii_timestamper(mii_ts);
> -clean_pse:
> - pse_control_put(psec);
>
> return rc;
> }
> diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
> index 4602e26eb8c8..10a5ab30afdd 100644
> --- a/drivers/net/pse-pd/pse_core.c
> +++ b/drivers/net/pse-pd/pse_core.c
> @@ -7,6 +7,7 @@
...
> +/**
> + * pse_to_regulator_notifs - Convert PSE notifications to Regulator
> + * notifications
> + * @notifs: PSE notifications
> + *
> + * Return: Regulator notifications
> + */
> +static unsigned long pse_to_regulator_notifs(unsigned long notifs)
I prefer converting it the other way around to make it reusable for
plain regulator-based PSEs. For example, the podl-pse-regulator driver
won’t have its own interrupt handler but will instead use
devm_regulator_register_notifier().
Even full-fledged PSE controllers like the PD692x0 are just one part of
a larger chain of regulators. An overcurrent event may originate from a
downstream regulator that is not part of the PD692x0 itself. In this
case, we need to process the event from the downstream regulator,
convert it into an ethtool event, and forward it to the user.
Here is one example how devm_regulator_register_notifier() can be used:
https://lore.kernel.org/all/20250220074429.2906141-1-o.rempel@pengutronix.de/
> +{
> + unsigned long rnotifs = 0;
> +
> + if (notifs & ETHTOOL_PSE_EVENT_OVER_CURRENT)
> + rnotifs |= REGULATOR_EVENT_OVER_CURRENT;
> + if (notifs & ETHTOOL_PSE_EVENT_OVER_TEMP)
> + rnotifs |= REGULATOR_EVENT_OVER_TEMP;
> +
> + return rnotifs;
> +}
> +
Other parts look ok for me.
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists