Skip to content

Commit 2511e0c

Browse files
sipragadavem330
authored andcommitted
net: dsa: realtek: fix Kconfig to assure consistent driver linkage
The kernel test robot reported a build failure: or1k-linux-ld: drivers/net/dsa/realtek/realtek-smi.o:(.rodata+0x16c): undefined reference to `rtl8366rb_variant' ... with the following build configuration: CONFIG_NET_DSA_REALTEK=y CONFIG_NET_DSA_REALTEK_SMI=y CONFIG_NET_DSA_REALTEK_RTL8365MB=y CONFIG_NET_DSA_REALTEK_RTL8366RB=m The problem here is that the realtek-smi interface driver gets built-in, while the rtl8366rb switch subdriver gets built as a module, hence the symbol rtl8366rb_variant is not reachable when defining the OF device table in the interface driver. The Kconfig dependencies don't help in this scenario because they just say that the subdriver(s) depend on at least one interface driver. In fact, the subdrivers don't depend on the interface drivers at all, and can even be built even in their absence. Somewhat strangely, the interface drivers can also be built in the absence of any subdriver, BUT, if a subdriver IS enabled, then it must be reachable according to the linkage of the interface driver: effectively what the IS_REACHABLE() macro achieves. If it is not reachable, the above kind of linker error will be observed. Rather than papering over the above build error by simply using IS_REACHABLE(), we can do a little better and admit that it is actually the interface drivers that have a dependency on the subdrivers. So this patch does exactly that. Specifically, we ensure that: 1. The interface drivers' Kconfig symbols must have a value no greater than the value of any subdriver Kconfig symbols. 2. The subdrivers should by default enable both interface drivers, since most users probably want at least one of them; those interface drivers can be explicitly disabled however. What this doesn't do is prevent a user from building only a subdriver, without any interface driver. To that end, add an additional line of help in the menu to guide users in the right direction. Link: https://lore.kernel.org/all/202204110757.XIafvVnj-lkp@intel.com/ Reported-by: kernel test robot <lkp@intel.com> Fixes: aac9400 ("net: dsa: realtek: add new mdio interface for drivers") Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dad32cf commit 2511e0c

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

drivers/net/dsa/realtek/Kconfig

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,46 @@ menuconfig NET_DSA_REALTEK
99
help
1010
Select to enable support for Realtek Ethernet switch chips.
1111

12+
Note that at least one interface driver must be enabled for the
13+
subdrivers to be loaded. Moreover, an interface driver cannot achieve
14+
anything without at least one subdriver enabled.
15+
16+
if NET_DSA_REALTEK
17+
1218
config NET_DSA_REALTEK_MDIO
13-
tristate "Realtek MDIO connected switch driver"
14-
depends on NET_DSA_REALTEK
19+
tristate "Realtek MDIO interface driver"
1520
depends on OF
21+
depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB
22+
depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB
23+
depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB
1624
help
1725
Select to enable support for registering switches configured
1826
through MDIO.
1927

2028
config NET_DSA_REALTEK_SMI
21-
tristate "Realtek SMI connected switch driver"
22-
depends on NET_DSA_REALTEK
29+
tristate "Realtek SMI interface driver"
2330
depends on OF
31+
depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB
32+
depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB
33+
depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB
2434
help
2535
Select to enable support for registering switches connected
2636
through SMI.
2737

2838
config NET_DSA_REALTEK_RTL8365MB
2939
tristate "Realtek RTL8365MB switch subdriver"
30-
depends on NET_DSA_REALTEK
31-
depends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO
40+
imply NET_DSA_REALTEK_SMI
41+
imply NET_DSA_REALTEK_MDIO
3242
select NET_DSA_TAG_RTL8_4
3343
help
3444
Select to enable support for Realtek RTL8365MB-VC and RTL8367S.
3545

3646
config NET_DSA_REALTEK_RTL8366RB
3747
tristate "Realtek RTL8366RB switch subdriver"
38-
depends on NET_DSA_REALTEK
39-
depends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO
48+
imply NET_DSA_REALTEK_SMI
49+
imply NET_DSA_REALTEK_MDIO
4050
select NET_DSA_TAG_RTL4_A
4151
help
42-
Select to enable support for Realtek RTL8366RB
52+
Select to enable support for Realtek RTL8366RB.
53+
54+
endif

0 commit comments

Comments
 (0)