* [PATCH net-next] net: phy: make mdio consumer / device layer a separate module
@ 2025-05-15 5:48 Heiner Kallweit
2025-05-15 6:26 ` Heiner Kallweit
2025-05-16 9:31 ` kernel test robot
0 siblings, 2 replies; 5+ messages in thread
From: Heiner Kallweit @ 2025-05-15 5:48 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Andrew Lunn, Paolo Abeni,
Eric Dumazet, Jakub Kicinski, David Miller
Cc: netdev@vger.kernel.org
After having factored out the provider part from mdio_bus.c, we can
make the mdio consumer / device layer a separate module. This also
allows to remove Kconfig symbol MDIO_DEVICE.
The module init / exit functions from mdio_bus.c no longer have to be
called from phy_device.c. The link order defined in
drivers/net/phy/Makefile ensures that init / exit functions are called
in the right order.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/mdio/Kconfig | 16 ++--------------
drivers/net/phy/Kconfig | 2 +-
drivers/net/phy/Makefile | 18 +++++-------------
drivers/net/phy/mdio_bus.c | 14 ++++++--------
drivers/net/phy/phy_device.c | 11 ++---------
include/linux/phy.h | 3 ---
6 files changed, 16 insertions(+), 48 deletions(-)
diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index d3219ca19..7db40aaa0 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -3,21 +3,10 @@
# MDIO Layer Configuration
#
-menuconfig MDIO_DEVICE
- tristate "MDIO bus device drivers"
- help
- MDIO devices and driver infrastructure code.
-
-if MDIO_DEVICE
-
config MDIO_BUS
- tristate
- default m if PHYLIB=m
- default MDIO_DEVICE
+ tristate "MDIO bus consumer layer"
help
- This internal symbol is used for link time dependencies and it
- reflects whether the mdio_bus/mdio_device code is built as a
- loadable module or built-in.
+ MDIO bus consumer layer
if PHYLIB
@@ -291,4 +280,3 @@ config MDIO_BUS_MUX_MMIOREG
endif
-endif
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 677d56e06..127a9fd0f 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -14,7 +14,7 @@ config PHYLINK
menuconfig PHYLIB
tristate "PHY Device support and infrastructure"
- select MDIO_DEVICE
+ select MDIO_BUS
help
Ethernet controllers are usually attached to PHY
devices. This option provides infrastructure for
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 59ac3a9a3..7de69320a 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -6,27 +6,19 @@ libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \
phy_package.o phy_caps.o mdio_bus_provider.o
mdio-bus-y += mdio_bus.o mdio_device.o
-ifdef CONFIG_MDIO_DEVICE
-obj-y += mdio-boardinfo.o
-endif
-
-# PHYLIB implies MDIO_DEVICE, in that case, we have a bunch of circular
-# dependencies that does not make it possible to split mdio-bus objects into a
-# dedicated loadable module, so we bundle them all together into libphy.ko
ifdef CONFIG_PHYLIB
-libphy-y += $(mdio-bus-y)
-# the stubs are built-in whenever PHYLIB is built-in or module
-obj-y += stubs.o
-else
-obj-$(CONFIG_MDIO_DEVICE) += mdio-bus.o
+# built-in whenever PHYLIB is built-in or module
+obj-y += stubs.o mdio-boardinfo.o
endif
-obj-$(CONFIG_PHYLIB) += mdio_devres.o
+
libphy-$(CONFIG_SWPHY) += swphy.o
libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o
libphy-$(CONFIG_OPEN_ALLIANCE_HELPERS) += open_alliance_helpers.o
+obj-$(CONFIG_MDIO_BUS) += mdio-bus.o
obj-$(CONFIG_PHYLINK) += phylink.o
obj-$(CONFIG_PHYLIB) += libphy.o
+obj-$(CONFIG_PHYLIB) += mdio_devres.o
obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += mii_timestamper.o
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index f5ccbe33a..a6bcb0fee 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -988,7 +988,7 @@ const struct bus_type mdio_bus_type = {
};
EXPORT_SYMBOL(mdio_bus_type);
-int __init mdio_bus_init(void)
+static int __init mdio_bus_init(void)
{
int ret;
@@ -1002,16 +1002,14 @@ int __init mdio_bus_init(void)
return ret;
}
-#if IS_ENABLED(CONFIG_PHYLIB)
-void mdio_bus_exit(void)
+static void __exit mdio_bus_exit(void)
{
class_unregister(&mdio_bus_class);
bus_unregister(&mdio_bus_type);
}
-EXPORT_SYMBOL_GPL(mdio_bus_exit);
-#else
-module_init(mdio_bus_init);
-/* no module_exit, intentional */
+
+subsys_initcall(mdio_bus_init);
+module_exit(mdio_bus_exit);
+
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("MDIO bus/device layer");
-#endif
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index f85c172c4..c06a1ff9b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3557,19 +3557,15 @@ static int __init phy_init(void)
phylib_register_stubs();
rtnl_unlock();
- rc = mdio_bus_init();
- if (rc)
- goto err_ethtool_phy_ops;
-
rc = phy_caps_init();
if (rc)
- goto err_mdio_bus;
+ goto err_ethtool_phy_ops;
features_init();
rc = phy_driver_register(&genphy_c45_driver, THIS_MODULE);
if (rc)
- goto err_mdio_bus;
+ goto err_ethtool_phy_ops;
rc = phy_driver_register(&genphy_driver, THIS_MODULE);
if (rc)
@@ -3579,8 +3575,6 @@ static int __init phy_init(void)
err_c45:
phy_driver_unregister(&genphy_c45_driver);
-err_mdio_bus:
- mdio_bus_exit();
err_ethtool_phy_ops:
rtnl_lock();
phylib_unregister_stubs();
@@ -3594,7 +3588,6 @@ static void __exit phy_exit(void)
{
phy_driver_unregister(&genphy_c45_driver);
phy_driver_unregister(&genphy_driver);
- mdio_bus_exit();
rtnl_lock();
phylib_unregister_stubs();
ethtool_set_ethtool_phy_ops(NULL);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7c29d346d..92a88b5ce 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2033,9 +2033,6 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev,
const struct ethtool_link_ksettings *cmd);
int phy_ethtool_nway_reset(struct net_device *ndev);
-int __init mdio_bus_init(void);
-void mdio_bus_exit(void);
-
int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);
int phy_ethtool_get_sset_count(struct phy_device *phydev);
int phy_ethtool_get_stats(struct phy_device *phydev,
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: phy: make mdio consumer / device layer a separate module
2025-05-15 5:48 [PATCH net-next] net: phy: make mdio consumer / device layer a separate module Heiner Kallweit
@ 2025-05-15 6:26 ` Heiner Kallweit
2025-05-15 13:32 ` Jakub Kicinski
2025-05-16 9:31 ` kernel test robot
1 sibling, 1 reply; 5+ messages in thread
From: Heiner Kallweit @ 2025-05-15 6:26 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Andrew Lunn, Paolo Abeni,
Eric Dumazet, Jakub Kicinski, David Miller
Cc: netdev@vger.kernel.org
On 15.05.2025 07:48, Heiner Kallweit wrote:
> After having factored out the provider part from mdio_bus.c, we can
> make the mdio consumer / device layer a separate module. This also
> allows to remove Kconfig symbol MDIO_DEVICE.
> The module init / exit functions from mdio_bus.c no longer have to be
> called from phy_device.c. The link order defined in
> drivers/net/phy/Makefile ensures that init / exit functions are called
> in the right order.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/mdio/Kconfig | 16 ++--------------
> drivers/net/phy/Kconfig | 2 +-
> drivers/net/phy/Makefile | 18 +++++-------------
> drivers/net/phy/mdio_bus.c | 14 ++++++--------
> drivers/net/phy/phy_device.c | 11 ++---------
> include/linux/phy.h | 3 ---
> 6 files changed, 16 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
> index d3219ca19..7db40aaa0 100644
> --- a/drivers/net/mdio/Kconfig
> +++ b/drivers/net/mdio/Kconfig
> @@ -3,21 +3,10 @@
> # MDIO Layer Configuration
> #
>
> -menuconfig MDIO_DEVICE
> - tristate "MDIO bus device drivers"
> - help
> - MDIO devices and driver infrastructure code.
> -
> -if MDIO_DEVICE
> -
> config MDIO_BUS
> - tristate
> - default m if PHYLIB=m
> - default MDIO_DEVICE
> + tristate "MDIO bus consumer layer"
> help
> - This internal symbol is used for link time dependencies and it
> - reflects whether the mdio_bus/mdio_device code is built as a
> - loadable module or built-in.
> + MDIO bus consumer layer
>
> if PHYLIB
>
> @@ -291,4 +280,3 @@ config MDIO_BUS_MUX_MMIOREG
>
>
> endif
> -endif
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index 677d56e06..127a9fd0f 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -14,7 +14,7 @@ config PHYLINK
>
> menuconfig PHYLIB
> tristate "PHY Device support and infrastructure"
> - select MDIO_DEVICE
> + select MDIO_BUS
> help
> Ethernet controllers are usually attached to PHY
> devices. This option provides infrastructure for
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 59ac3a9a3..7de69320a 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -6,27 +6,19 @@ libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \
> phy_package.o phy_caps.o mdio_bus_provider.o
> mdio-bus-y += mdio_bus.o mdio_device.o
>
> -ifdef CONFIG_MDIO_DEVICE
> -obj-y += mdio-boardinfo.o
> -endif
> -
> -# PHYLIB implies MDIO_DEVICE, in that case, we have a bunch of circular
> -# dependencies that does not make it possible to split mdio-bus objects into a
> -# dedicated loadable module, so we bundle them all together into libphy.ko
> ifdef CONFIG_PHYLIB
> -libphy-y += $(mdio-bus-y)
> -# the stubs are built-in whenever PHYLIB is built-in or module
> -obj-y += stubs.o
> -else
> -obj-$(CONFIG_MDIO_DEVICE) += mdio-bus.o
> +# built-in whenever PHYLIB is built-in or module
> +obj-y += stubs.o mdio-boardinfo.o
> endif
> -obj-$(CONFIG_PHYLIB) += mdio_devres.o
> +
> libphy-$(CONFIG_SWPHY) += swphy.o
> libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o
> libphy-$(CONFIG_OPEN_ALLIANCE_HELPERS) += open_alliance_helpers.o
>
> +obj-$(CONFIG_MDIO_BUS) += mdio-bus.o
> obj-$(CONFIG_PHYLINK) += phylink.o
> obj-$(CONFIG_PHYLIB) += libphy.o
> +obj-$(CONFIG_PHYLIB) += mdio_devres.o
>
> obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += mii_timestamper.o
>
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index f5ccbe33a..a6bcb0fee 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -988,7 +988,7 @@ const struct bus_type mdio_bus_type = {
> };
> EXPORT_SYMBOL(mdio_bus_type);
>
> -int __init mdio_bus_init(void)
> +static int __init mdio_bus_init(void)
> {
> int ret;
>
> @@ -1002,16 +1002,14 @@ int __init mdio_bus_init(void)
> return ret;
> }
>
> -#if IS_ENABLED(CONFIG_PHYLIB)
> -void mdio_bus_exit(void)
> +static void __exit mdio_bus_exit(void)
> {
> class_unregister(&mdio_bus_class);
> bus_unregister(&mdio_bus_type);
> }
> -EXPORT_SYMBOL_GPL(mdio_bus_exit);
> -#else
> -module_init(mdio_bus_init);
> -/* no module_exit, intentional */
> +
> +subsys_initcall(mdio_bus_init);
> +module_exit(mdio_bus_exit);
> +
> MODULE_LICENSE("GPL");
> MODULE_DESCRIPTION("MDIO bus/device layer");
> -#endif
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index f85c172c4..c06a1ff9b 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -3557,19 +3557,15 @@ static int __init phy_init(void)
> phylib_register_stubs();
> rtnl_unlock();
>
> - rc = mdio_bus_init();
> - if (rc)
> - goto err_ethtool_phy_ops;
> -
> rc = phy_caps_init();
> if (rc)
> - goto err_mdio_bus;
> + goto err_ethtool_phy_ops;
>
> features_init();
>
> rc = phy_driver_register(&genphy_c45_driver, THIS_MODULE);
> if (rc)
> - goto err_mdio_bus;
> + goto err_ethtool_phy_ops;
>
> rc = phy_driver_register(&genphy_driver, THIS_MODULE);
> if (rc)
> @@ -3579,8 +3575,6 @@ static int __init phy_init(void)
>
> err_c45:
> phy_driver_unregister(&genphy_c45_driver);
> -err_mdio_bus:
> - mdio_bus_exit();
> err_ethtool_phy_ops:
> rtnl_lock();
> phylib_unregister_stubs();
> @@ -3594,7 +3588,6 @@ static void __exit phy_exit(void)
> {
> phy_driver_unregister(&genphy_c45_driver);
> phy_driver_unregister(&genphy_driver);
> - mdio_bus_exit();
> rtnl_lock();
> phylib_unregister_stubs();
> ethtool_set_ethtool_phy_ops(NULL);
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 7c29d346d..92a88b5ce 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -2033,9 +2033,6 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev,
> const struct ethtool_link_ksettings *cmd);
> int phy_ethtool_nway_reset(struct net_device *ndev);
>
> -int __init mdio_bus_init(void);
> -void mdio_bus_exit(void);
> -
> int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);
> int phy_ethtool_get_sset_count(struct phy_device *phydev);
> int phy_ethtool_get_stats(struct phy_device *phydev,
Forgot to export mdio_device_bus_match.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: phy: make mdio consumer / device layer a separate module
2025-05-15 6:26 ` Heiner Kallweit
@ 2025-05-15 13:32 ` Jakub Kicinski
2025-05-15 17:58 ` Heiner Kallweit
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-05-15 13:32 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Andrew Lunn, Russell King - ARM Linux, Andrew Lunn, Paolo Abeni,
Eric Dumazet, David Miller, netdev@vger.kernel.org
On Thu, 15 May 2025 08:26:33 +0200 Heiner Kallweit wrote:
> > int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);
> > int phy_ethtool_get_sset_count(struct phy_device *phydev);
> > int phy_ethtool_get_stats(struct phy_device *phydev,
>
> Forgot to export mdio_device_bus_match.
What happened to waiting 24h with the reposts..
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: phy: make mdio consumer / device layer a separate module
2025-05-15 13:32 ` Jakub Kicinski
@ 2025-05-15 17:58 ` Heiner Kallweit
0 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2025-05-15 17:58 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Andrew Lunn, Russell King - ARM Linux, Andrew Lunn, Paolo Abeni,
Eric Dumazet, David Miller, netdev@vger.kernel.org
On 15.05.2025 15:32, Jakub Kicinski wrote:
> On Thu, 15 May 2025 08:26:33 +0200 Heiner Kallweit wrote:
>>> int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);
>>> int phy_ethtool_get_sset_count(struct phy_device *phydev);
>>> int phy_ethtool_get_stats(struct phy_device *phydev,
>>
>> Forgot to export mdio_device_bus_match.
>
> What happened to waiting 24h with the reposts..
I wanted to provide a version for review which at least passes the
automated tests. But right, will wait also in this case.
Thanks for the hint.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: phy: make mdio consumer / device layer a separate module
2025-05-15 5:48 [PATCH net-next] net: phy: make mdio consumer / device layer a separate module Heiner Kallweit
2025-05-15 6:26 ` Heiner Kallweit
@ 2025-05-16 9:31 ` kernel test robot
1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-05-16 9:31 UTC (permalink / raw)
To: Heiner Kallweit, Andrew Lunn, Russell King - ARM Linux,
Paolo Abeni, Eric Dumazet, Jakub Kicinski, David Miller
Cc: llvm, oe-kbuild-all, netdev
Hi Heiner,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heiner-Kallweit/net-phy-make-mdio-consumer-device-layer-a-separate-module/20250515-134852
base: net-next/main
patch link: https://lore.kernel.org/r/9a284c3d-73d4-402c-86ba-c82aabe9c44e%40gmail.com
patch subject: [PATCH net-next] net: phy: make mdio consumer / device layer a separate module
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250516/202505161753.e2B0R1Th-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250516/202505161753.e2B0R1Th-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505161753.e2B0R1Th-lkp@intel.com/
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "mdio_device_bus_match" [drivers/net/phy/libphy.ko] undefined!
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-16 9:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15 5:48 [PATCH net-next] net: phy: make mdio consumer / device layer a separate module Heiner Kallweit
2025-05-15 6:26 ` Heiner Kallweit
2025-05-15 13:32 ` Jakub Kicinski
2025-05-15 17:58 ` Heiner Kallweit
2025-05-16 9:31 ` kernel test robot
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).