net: phy: mediatek: permit to compile test GE SOC PHY driver
Subsystems (5)
PATCH v2 1/2 net: phy: mediatek: permit to compile test GE SOC PHY driver
When commit 462a3daad679 ("net: phy: mediatek: fix compile-test dependencies") fixed the dependency, it should have also introduced an or on COMPILE_TEST to permit this driver to be compile-tested even if NVMEM_MTK_EFUSE wasn't selected. The driver makes use of NVMEM API that are always compiled (return error) so the driver can actually be compiled even without that config.
Fix and simplify the dependency condition of this kernel config.
---
Changes v2:
- Add Ack and Reviewed-by tag
- Address suggested dependency from Russell
drivers/net/phy/mediatek/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/phy/mediatek/Kconfig +1 -2
@@ -15,8 +15,7 @@ config MEDIATEK_GE_PHY config MEDIATEK_GE_SOC_PHY tristate "MediaTek SoC Ethernet PHYs" - depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST - depends on NVMEM_MTK_EFUSE + depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST select MTK_NET_PHYLIB help Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
Signature · 1 line
2.48.1
PATCH v2 2/2 net: phy: mediatek: add Airoha PHY ID to SoC driver
Airoha AN7581 SoC ship with a Switch based on the MT753x Switch embedded in other SoC like the MT7581 and the MT7988. Similar to these they require configuring some pin to enable LED PHYs.
Add support for the PHY ID for the Airoha embedded Switch and define a simple probe function to toggle these pins. Also fill the LED functions and add dedicated function to define LED polarity.
---
Changes v2:
- Add Reviewed-by tag
- Address suggested dependency from Russell
drivers/net/phy/mediatek/Kconfig | 4 +- drivers/net/phy/mediatek/mtk-ge-soc.c | 62 +++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-)
drivers/net/phy/mediatek/Kconfig +3 -1
@@ -15,7 +15,9 @@ config MEDIATEK_GE_PHY config MEDIATEK_GE_SOC_PHY tristate "MediaTek SoC Ethernet PHYs" - depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST + depends on ARM64 || COMPILE_TEST + depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \ + COMPILE_TEST select MTK_NET_PHYLIB help Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
drivers/net/phy/mediatek/mtk-ge-soc.c +62 -0
88 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [net-next PATCH v2 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver
drivers/net/phy/mediatek/Kconfig config MEDIATEK_GE_PHY · line 23
Quoted 10 lines · Christian Marangi
config
MEDIATEK_GE_SOC_PHYdrivers/net/phy/mediatek/Kconfig +3
-1tristate "MediaTek SoC Ethernet PHYs" - depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST + depends on ARM64 || COMPILE_TEST + depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \ + COMPILE_TEST select MTK_NET_PHYLIB help Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
This now also fails for non-compile-test builds with NVMEM=m, ARCH_MEDIATEK=n, ARCH_AIROHA=y and MEDIATEK_GE_SOC_PHY=y.
Arnd
Simon Horman
reviewerRe: [net-next PATCH v2 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver
In reply to Christian MarangiQuoted 10 lines · Christian Marangi
Airoha AN7581 SoC ship with a Switch based on the MT753x Switch embedded in other SoC like the MT7581 and the MT7988. Similar to these they require configuring some pin to enable LED PHYs.
Add support for the PHY ID for the Airoha embedded Switch and define a simple probe function to toggle these pins. Also fill the LED functions and add dedicated function to define LED polarity.
Reviewed-by Andrew Lunn <[email protected]>Signed-off-by Christian Marangi <[email protected]>
...
Quoted 1 line
drivers/net/phy/mediatek/mtk-ge-soc.c +0
-0
...
Quoted 15 lines
drivers/net/phy/mediatek/mtk-ge-soc.c +15
-0+static int an7581_phy_led_polarity_set (struct phy_device *phydev,int index, +unsigned long modes) +{ +u32 mode; +u16 val; + +if (index >=MTK_PHY_MAX_LEDS ) +return -EINVAL ; + +for_each_set_bit (mode, &modes, __PHY_LED_MODES_NUM) { +switch (mode) { +case PHY_LED_ACTIVE_LOW : + val =MTK_PHY_LED_ON_POLARITY ; +break ; +case PHY_LED_ACTIVE_HIGH :
drivers/net/phy/mediatek/mtk-ge-soc.c static int mt7981_phy_probe(struct phy_device *phydev) · line 1456
Quoted 10 lines
drivers/net/phy/mediatek/mtk-ge-soc.c +10
-0+ val =0 ; +break ; +default : +return -EINVAL ; + } + } + +return phy_modify_mmd (phydev,MDIO_MMD_VEND2 , index ? +MTK_PHY_LED1_ON_CTRL :MTK_PHY_LED0_ON_CTRL , +MTK_PHY_LED_ON_POLARITY , val);
Hi Christian,
Perhaps this cannot occur in practice, but if the for_each_set_bit loop iterates zero times then val will be used uninitialised here.
Flagged by Smatch.
Quoted 1 line
+}
...
Re: [net-next PATCH v2 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver
Quoted 46 lines · Simon Horman
Quoted 10 lines · Christian Marangi
Airoha AN7581 SoC ship with a Switch based on the MT753x Switch embedded in other SoC like the MT7581 and the MT7988. Similar to these they require configuring some pin to enable LED PHYs.
Add support for the PHY ID for the Airoha embedded Switch and define a simple probe function to toggle these pins. Also fill the LED functions and add dedicated function to define LED polarity.
Reviewed-by Andrew Lunn <[email protected]>Signed-off-by Christian Marangi <[email protected]>...
Quoted 1 line
drivers/net/phy/mediatek/mtk-ge-soc.c +0
-0...
Quoted 15 lines
drivers/net/phy/mediatek/mtk-ge-soc.c +15
-0+static int an7581_phy_led_polarity_set (struct phy_device *phydev,int index, +unsigned long modes) +{ +u32 mode; +u16 val; + +if (index >=MTK_PHY_MAX_LEDS ) +return -EINVAL ; + +for_each_set_bit (mode, &modes, __PHY_LED_MODES_NUM) { +switch (mode) { +case PHY_LED_ACTIVE_LOW : + val =MTK_PHY_LED_ON_POLARITY ; +break ; +case PHY_LED_ACTIVE_HIGH :drivers/net/phy/mediatek/mtk-ge-soc.c static int mt7981_phy_probe(struct phy_device *phydev) · line 1456
Quoted 10 lines
drivers/net/phy/mediatek/mtk-ge-soc.c +10
-0+ val =0 ; +break ; +default : +return -EINVAL ; + } + } + +return phy_modify_mmd (phydev,MDIO_MMD_VEND2 , index ? +MTK_PHY_LED1_ON_CTRL :MTK_PHY_LED0_ON_CTRL , +MTK_PHY_LED_ON_POLARITY , val);Hi Christian,
Quoted 8 lines
Perhaps this cannot occur in practice, but if the
for_each_set_bitloop iterates zero times then val will be used uninitialised here.Flagged by Smatch.
Quoted 1 line
+}
...
Almost impossible but yes I will post a follow-up patch fixing this!
Signature · 1 line
Ansuel
Quoted 4 lines · Christian Marangi
When commit
462a3daad679("net: phy: mediatek: fix compile-test dependencies") fixed the dependency, it should have also introduced an or onCOMPILE_TESTto permit this driver to be compile-tested even ifNVMEM_MTK_EFUSEwasn't selected
Why does this matter? NVMEM_MTK_EFUSE can be enabled for both allmodconfig and randconfig builds on any architecture, so you get build coverage either way, it's just a little less likely to be enabled in randconfig I guess?
Quoted 6 lines
drivers/net/phy/mediatek/Kconfig +0
-0
drivers/net/phy/mediatek/Kconfig config MEDIATEK_GE_PHY · line 21
Quoted 9 lines
drivers/net/phy/mediatek/Kconfig +1
-2@@ -15,8 +15,7 @@ config MEDIATEK_GE_PHY config MEDIATEK_GE_SOC_PHY tristate "MediaTek SoC Ethernet PHYs" - depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST - depends on NVMEM_MTK_EFUSE + depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST select MTK_NET_PHYLIB help Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
I would expect this to break the build with CONFIG_NVMEM=m and MEDIATEK_GE_SOC_PHY=y.
The normal thing here would be to have a dependency on CONFIG_NVMEM in place of the NVMEM_MTK_EFUSE dependency, or possible on 'NVMEM || !NVMEM' if you want to make it more likely to be enabled in randconfig builds.
Arnd
Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · Christian Marangi
When commit
462a3daad679("net: phy: mediatek: fix compile-test dependencies") fixed the dependency, it should have also introduced an or onCOMPILE_TESTto permit this driver to be compile-tested even ifNVMEM_MTK_EFUSEwasn't selectedWhy does this matter?
NVMEM_MTK_EFUSEcan be enabled for both allmodconfig and randconfig builds on any architecture, so you get build coverage either way, it's just a little less likely to be enabled in randconfig I guess?
If we base stuff on the fact that everything is selected or that a random config by luck selects it, then COMPILE_TEST doesn't make sense at all.
For my personal test, I wanted to test the driver on a simple x86 build without having to depend on ARCH or having to cross compile. Won't happen on real world scenario? Totally. I should be able to compile it? Yes.
Quoted 19 lines
Quoted 6 lines
drivers/net/phy/mediatek/Kconfig +0
-0drivers/net/phy/mediatek/Kconfig config MEDIATEK_GE_PHY · line 21
Quoted 9 lines
drivers/net/phy/mediatek/Kconfig +1
-2@@ -15,8 +15,7 @@ config MEDIATEK_GE_PHY config MEDIATEK_GE_SOC_PHY tristate "MediaTek SoC Ethernet PHYs" - depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST - depends on NVMEM_MTK_EFUSE + depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST select MTK_NET_PHYLIB help Supports MediaTek SoC built-in Gigabit Ethernet PHYs.I would expect this to break the build with
CONFIG_NVMEM=mand MEDIATEK_GE_SOC_PHY=y.
Quoted 5 lines
The normal thing here would be to have a dependency on
CONFIG_NVMEMin place of theNVMEM_MTK_EFUSEdependency, or possible on 'NVMEM || !NVMEM' if you want to make it more likely to be enabled in randconfig builds.
The big idea of these dependency is that... In MTK the internal PHY of the switch needs calibration or it won't work hence it doesn't make sense to select the PHY as it won't ever work without the NVMEM driver.
But from a compile test view where we only evaluate if the driver have compilation error or other kind of warning, we should not care...
Signature · 1 line
Ansuel
Quoted 47 lines · Christian Marangi
Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · Christian Marangi
When commit
462a3daad679("net: phy: mediatek: fix compile-test dependencies") fixed the dependency, it should have also introduced an or onCOMPILE_TESTto permit this driver to be compile-tested even ifNVMEM_MTK_EFUSEwasn't selectedWhy does this matter?
NVMEM_MTK_EFUSEcan be enabled for both allmodconfig and randconfig builds on any architecture, so you get build coverage either way, it's just a little less likely to be enabled in randconfig I guess?If we base stuff on the fact that everything is selected or that a random config by luck selects it, then
COMPILE_TESTdoesn't make sense at all.For my personal test, I wanted to test the driver on a simple x86 build without having to depend on ARCH or having to cross compile. Won't happen on real world scenario? Totally. I should be able to compile it? Yes.
Quoted 19 lines
Quoted 6 lines
drivers/net/phy/mediatek/Kconfig +0
-0drivers/net/phy/mediatek/Kconfig config MEDIATEK_GE_PHY · line 21
Quoted 9 lines
drivers/net/phy/mediatek/Kconfig +1
-2@@ -15,8 +15,7 @@ config MEDIATEK_GE_PHY config MEDIATEK_GE_SOC_PHY tristate "MediaTek SoC Ethernet PHYs" - depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST - depends on NVMEM_MTK_EFUSE + depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST select MTK_NET_PHYLIB help Supports MediaTek SoC built-in Gigabit Ethernet PHYs.I would expect this to break the build with
CONFIG_NVMEM=mand MEDIATEK_GE_SOC_PHY=y.Quoted 5 lines
The normal thing here would be to have a dependency on
CONFIG_NVMEMin place of theNVMEM_MTK_EFUSEdependency, or possible on 'NVMEM || !NVMEM' if you want to make it more likely to be enabled in randconfig builds.
Quoted 7 lines
The big idea of these dependency is that... In MTK the internal PHY of the switch needs calibration or it won't work hence it doesn't make sense to select the PHY as it won't ever work without the NVMEM driver.
But from a compile test view where we only evaluate if the driver have compilation error or other kind of warning, we should not care...
Also 99% I could be wrong but from what I can see in NVMEM kconfig, NVMEM is not tristate but only bool? So NVMEM=m is not a thing?
Signature · 1 line
Ansuel
Arnd Bergmann
Acked-byQuoted 4 lines · Christian Marangi
On Thu, Apr 10, 2025 at 12:40:15PM +0200, Christian Marangi wrote:
Also 99% I could be wrong but from what I can see in NVMEM kconfig, NVMEM is not tristate but only bool? So NVMEM=m is not a thing?
Ah, I missed that. In this case your patches are both fine.
Quoted 13 lines · Christian Marangi
Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · Christian Marangi
When commit
462a3daad679("net: phy: mediatek: fix compile-test dependencies") fixed the dependency, it should have also introduced an or onCOMPILE_TESTto permit this driver to be compile-tested even ifNVMEM_MTK_EFUSEwasn't selectedWhy does this matter?
NVMEM_MTK_EFUSEcan be enabled for both allmodconfig and randconfig builds on any architecture, so you get build coverage either way, it's just a little less likely to be enabled in randconfig I guess?
Quoted 8 lines
If we base stuff on the fact that everything is selected or that a random config by luck selects it, then
COMPILE_TESTdoesn't make sense at all.For my personal test, I wanted to test the driver on a simple x86 build without having to depend on ARCH or having to cross compile. Won't happen on real world scenario? Totally. I should be able to compile it? Yes.
Being able to compile test the driver yourself is clearly a good idea, I just don't think that requires the dependency to be conditional here.
Quoted 9 lines
Quoted 8 lines
I would expect this to break the build with
CONFIG_NVMEM=mand MEDIATEK_GE_SOC_PHY=y.The normal thing here would be to have a dependency on
CONFIG_NVMEMin place of theNVMEM_MTK_EFUSEdependency, or possible on 'NVMEM || !NVMEM' if you want to make it more likely to be enabled in randconfig builds.
Quoted 3 lines
The big idea of these dependency is that... In MTK the internal PHY of the switch needs calibration or it won't work hence it doesn't make sense to select the PHY as it won't ever work without the NVMEM driver.
That's not how dependencies normally work: the driver also fails to work correctly if you are missing the correct pinctrl or led driver, or the syscon, yet you don't list them explicitly because you just need them for the machine to work correctly.
The driver dependencies should just list what you need to build, regardless of whether you are compile-testing or building a driver that is going to be used.
Arnd
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 10 Apr 2025 12:04:03 +0200 you wrote:
When commit
462a3daad679("net: phy: mediatek: fix compile-test dependencies") fixed the dependency, it should have also introduced an or onCOMPILE_TESTto permit this driver to be compile-tested even ifNVMEM_MTK_EFUSEwasn't selected. The driver makes use of NVMEM API that are always compiled (return error) so the driver can actually be compiled even without that config.[...]
Here is the summary with links:
- [net-next,v2,1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver
https://git.kernel.org/netdev/net-next/c/e5566162af8b - [net-next,v2,2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver https://git.kernel.org/netdev/net-next/c/6a325aed130b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html