ACPI/DT mdiobus module owner fixes
Subsystems (4)
v2 cover ACPI/DT mdiobus module owner fixes
This patch series fixes wrong mdiobus module ownership for MDIO buses registered from DT or ACPI.
Thanks Maxime for providing the first patch and making me see that ACPI also had the same issue.
Changes in v2:
- fixed missing kdoc in the first patch
Florian Fainelli (1):
net: mdio: fix owner field for mdio buses registered using ACPI
Maxime Bizon (1):
net: mdio: fix owner field for mdio buses registered using device-tree
drivers/net/mdio/acpi_mdio.c | 10 ++++++---- drivers/net/mdio/of_mdio.c | 12 +++++++----- drivers/net/phy/mdio_devres.c | 11 ++++++----- include/linux/acpi_mdio.h | 9 ++++++++- include/linux/of_mdio.h | 22 +++++++++++++++++++--- 5 files changed, 46 insertions(+), 18 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 net: mdio: fix owner field for mdio buses registered using device-tree
From: Maxime Bizon <[email protected]>
Bus ownership is wrong when using of_mdiobus_register() to register an mdio bus. That function is not inline, so when it calls mdiobus_register() the wrong THIS_MODULE value is captured.
--- drivers/net/mdio/of_mdio.c | 12 +++++++----- drivers/net/phy/mdio_devres.c | 11 ++++++----- include/linux/of_mdio.h | 22 +++++++++++++++++++--- 3 files changed, 32 insertions(+), 13 deletions(-)
drivers/net/mdio/of_mdio.c +7 -5
@@ -139,21 +139,23 @@ bool of_mdiobus_child_is_phy(struct device_node *child)EXPORT_SYMBOL (of_mdiobus_child_is_phy);/** -* of_mdiobus_register - Register mii_bus and create PHYs from the device tree +* __of_mdiobus_register - Register mii_bus and create PHYs from the device tree * @mdio: pointer to mii_bus structure * @np: pointer to device_node of MDIO bus. +* @owner: module owning the @mdio object. * * This function registers the mii_bus structure and registers a phy_device * for each child node of @np. */ -int of_mdiobus_register (struct mii_bus *mdio,struct device_node *np) +int __of_mdiobus_register (struct mii_bus *mdio,struct device_node *np, +struct module *owner) {struct device_node *child;bool scanphys = false;int addr, rc;if (!np) -return mdiobus_register (mdio); +return __mdiobus_register (mdio, owner);/* Do not continue if the node is disabled */ if (!of_device_is_available (np))
@@ -172,7 +174,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)of_property_read_u32 (np,"reset-post-delay-us" , &mdio->reset_post_delay_us);/* Register the MDIO bus */ - rc =mdiobus_register (mdio); + rc =__mdiobus_register (mdio, owner);if (rc)return rc;
@@ -236,7 +238,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)mdiobus_unregister (mdio);return rc; } -EXPORT_SYMBOL (of_mdiobus_register); +EXPORT_SYMBOL (__of_mdiobus_register);/** * of_mdio_find_device - Given a device tree node, find the mdio_device
drivers/net/phy/mdio_devres.c +6 -5
@@ -98,13 +98,14 @@ EXPORT_SYMBOL(__devm_mdiobus_register);#if IS_ENABLED (CONFIG_OF_MDIO )/** -* devm_of_mdiobus_register - Resource managed variant of of_mdiobus_register() +* __devm_of_mdiobus_register - Resource managed variant of of_mdiobus_register() * @dev: Device to register mii_bus for * @mdio: MII bus structure to register * @np: Device node to parse +* @owner: Owning module */ -int devm_of_mdiobus_register (struct device *dev,struct mii_bus *mdio, -struct device_node *np) +int __devm_of_mdiobus_register (struct device *dev,struct mii_bus *mdio, +struct device_node *np,struct module *owner) {struct mdiobus_devres *dr;int ret;
@@ -117,7 +118,7 @@ int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,if (!dr)return -ENOMEM ; - ret =of_mdiobus_register (mdio, np); + ret =__of_mdiobus_register (mdio, np, owner);if (ret) {devres_free (dr);return ret;
@@ -127,7 +128,7 @@ int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,devres_add (dev, dr); return 0; } -EXPORT_SYMBOL (devm_of_mdiobus_register); +EXPORT_SYMBOL (__devm_of_mdiobus_register);#endif /* CONFIG_OF_MDIO */ MODULE_LICENSE ("GPL" );
include/linux/of_mdio.h +19 -3
@@ -14,9 +14,25 @@#if IS_ENABLED (CONFIG_OF_MDIO )bool of_mdiobus_child_is_phy (struct device_node *child); -int of_mdiobus_register (struct mii_bus *mdio,struct device_node *np); -int devm_of_mdiobus_register (struct device *dev,struct mii_bus *mdio, -struct device_node *np); +int __of_mdiobus_register (struct mii_bus *mdio,struct device_node *np, +struct module *owner); + +static inline int of_mdiobus_register (struct mii_bus *mdio, +struct device_node *np) +{ +return __of_mdiobus_register (mdio, np,THIS_MODULE ); +} + +int __devm_of_mdiobus_register (struct device *dev,struct mii_bus *mdio, +struct device_node *np,struct module *owner); + +static inline int devm_of_mdiobus_register (struct device *dev, +struct mii_bus *mdio, +struct device_node *np) +{ +return __devm_of_mdiobus_register (dev, mdio, np,THIS_MODULE ); +} +struct mdio_device *of_mdio_find_device (struct device_node *np);struct phy_device *of_phy_find_device (struct device_node *phy_np); struct phy_device *
Signature · 1 line
2.34.1
Re: [PATCH v2 1/2] net: mdio: fix owner field for mdio buses registered using device-tree
Quoted 10 lines · Florian Fainelli
From: Maxime Bizon <[email protected]>
Bus ownership is wrong when using
of_mdiobus_register()to register an mdio bus. That function is not inline, so when it callsmdiobus_register()the wrongTHIS_MODULEvalue is captured.Signed-off-by Maxime Bizon <[email protected]>Fixes 90eff9096c01 ("net: phy: Allow splitting MDIO bus/device support from PHYs")[florian: fix kdoc, added Fixes tag]Signed-off-by Florian Fainelli <[email protected]>
PATCH v2 2/2 net: mdio: fix owner field for mdio buses registered using ACPI
In reply to Florian FainelliBus ownership is wrong when using acpi_mdiobus_register() to register an mdio bus. That function is not inline, so when it calls mdiobus_register() the wrong THIS_MODULE value is captured.
--- drivers/net/mdio/acpi_mdio.c | 10 ++++++---- include/linux/acpi_mdio.h | 9 ++++++++- 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/net/mdio/acpi_mdio.c +6 -4
@@ -18,16 +18,18 @@ MODULE_AUTHOR("Calvin Johnson <[email protected]>");MODULE_LICENSE ("GPL" );/** -* acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL. +* __acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL. * @mdio: pointer to mii_bus structure * @fwnode: pointer to fwnode of MDIO bus. This fwnode is expected to represent +* @owner: module owning this @mdio object. * an ACPI device object corresponding to the MDIO bus and its children are * expected to correspond to the PHY devices on that bus. * * This function registers the mii_bus structure and registers a phy_device * for each child node of @fwnode. */ -int acpi_mdiobus_register (struct mii_bus *mdio,struct fwnode_handle *fwnode) +int __acpi_mdiobus_register (struct mii_bus *mdio,struct fwnode_handle *fwnode, +struct module *owner) {struct fwnode_handle *child;u32 addr;
@@ -35,7 +37,7 @@ int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)/* Mask out all PHYs from auto probing. */ mdio->phy_mask =GENMASK (31 ,0 ); - ret =mdiobus_register (mdio); + ret =__mdiobus_register (mdio, owner);if (ret)return ret;
@@ -55,4 +57,4 @@ int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) }return 0 ; } -EXPORT_SYMBOL (acpi_mdiobus_register); +EXPORT_SYMBOL (__acpi_mdiobus_register);
include/linux/acpi_mdio.h +8 -1
@@ -9,7 +9,14 @@#include <linux/phy.h> #if IS_ENABLED (CONFIG_ACPI_MDIO ) -int acpi_mdiobus_register (struct mii_bus *mdio,struct fwnode_handle *fwnode); +int __acpi_mdiobus_register (struct mii_bus *mdio,struct fwnode_handle *fwnode, +struct module *owner); + +static inline int +acpi_mdiobus_register (struct mii_bus *mdio,struct fwnode_handle *handle) +{ +return __acpi_mdiobus_register (mdio, handle,THIS_MODULE ); +}#else /* CONFIG_ACPI_MDIO */ static inline int acpi_mdiobus_register (struct mii_bus *mdio,struct fwnode_handle *fwnode)
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] net: mdio: fix owner field for mdio buses registered using ACPI
Quoted 7 lines · Florian Fainelli
Bus ownership is wrong when using
acpi_mdiobus_register()to register an mdio bus. That function is not inline, so when it callsmdiobus_register()the wrongTHIS_MODULEvalue is captured.CC Maxime Bizon <[email protected]>Fixes 803ca24d2f92 ("net: mdio: Add ACPI support code for mdio")Signed-off-by Florian Fainelli <[email protected]>
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Thu, 16 Mar 2023 16:33:15 -0700 you wrote:
This patch series fixes wrong mdiobus module ownership for MDIO buses registered from DT or ACPI.
Thanks Maxime for providing the first patch and making me see that ACPI also had the same issue.
Changes in v2:
[...]
Here is the summary with links:
- [v2,1/2] net: mdio: fix owner field for mdio buses registered using device-tree
https://git.kernel.org/netdev/net/c/99669259f336 - [v2,2/2] net: mdio: fix owner field for mdio buses registered using ACPI https://git.kernel.org/netdev/net/c/30b605b8501e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html