Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethernet: ti: Remove TI_CPTS_MOD workaround

My recent commit b6d49cab44b5 ("net: Make PTP-specific drivers depend on
PTP_1588_CLOCK") exposes a missing dependency in defconfigs that select
TI_CPTS without selecting PTP_1588_CLOCK, leading to linker errors of the
form:

drivers/net/ethernet/ti/cpsw.o: in function `cpsw_ndo_stop':
cpsw.c:(.text+0x680): undefined reference to `cpts_unregister'
...

That's because TI_CPTS_MOD (which is the symbol gating the _compilation_ of
cpts.c) now depends on PTP_1588_CLOCK, and so is not enabled in these
configurations, but TI_CPTS (which is the symbol gating _calls_ to the cpts
functions) _is_ enabled. So we end up compiling calls to functions that
don't exist, resulting in the linker errors.

This patch fixes build errors and restores previous behavior by:
- ensure PTP_1588_CLOCK=y in TI specific configs and CPTS will be built
- remove TI_CPTS_MOD and, instead, add dependencies from CPTS in
TI_CPSW/TI_KEYSTONE_NETCP/TI_CPSW_SWITCHDEV as below:

config TI_CPSW_SWITCHDEV
...
depends on TI_CPTS || !TI_CPTS

which will ensure proper dependencies PTP_1588_CLOCK -> TI_CPTS ->
TI_CPSW/TI_KEYSTONE_NETCP/TI_CPSW_SWITCHDEV and build type selection.

Note. For NFS boot + CPTS all of above configs have to be built-in.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Fixes: b6d49cab44b5 ("net: Make PTP-specific drivers depend on PTP_1588_CLOCK")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Clay McClure <clay@daemons.net>
[grygorii.strashko@ti.com: rewording, add deps cpsw/netcp from cpts, drop IS_REACHABLE]
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Clay McClure and committed by
David S. Miller
92db978f d6718ccb

+9 -11
+1
arch/arm/configs/keystone_defconfig
··· 147 147 CONFIG_SPI=y 148 148 CONFIG_SPI_DAVINCI=y 149 149 CONFIG_SPI_SPIDEV=y 150 + CONFIG_PTP_1588_CLOCK=y 150 151 CONFIG_PINCTRL_SINGLE=y 151 152 CONFIG_GPIOLIB=y 152 153 CONFIG_GPIO_SYSFS=y
+1
arch/arm/configs/omap2plus_defconfig
··· 274 274 CONFIG_HSI=m 275 275 CONFIG_OMAP_SSI=m 276 276 CONFIG_SSI_PROTOCOL=m 277 + CONFIG_PTP_1588_CLOCK=y 277 278 CONFIG_PINCTRL_SINGLE=y 278 279 CONFIG_DEBUG_GPIO=y 279 280 CONFIG_GPIO_SYSFS=y
+6 -10
drivers/net/ethernet/ti/Kconfig
··· 49 49 config TI_CPSW 50 50 tristate "TI CPSW Switch Support" 51 51 depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || COMPILE_TEST 52 + depends on TI_CPTS || !TI_CPTS 52 53 select TI_DAVINCI_MDIO 53 54 select MFD_SYSCON 54 55 select PAGE_POOL ··· 65 64 tristate "TI CPSW Switch Support with switchdev" 66 65 depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || COMPILE_TEST 67 66 depends on NET_SWITCHDEV 67 + depends on TI_CPTS || !TI_CPTS 68 68 select PAGE_POOL 69 69 select TI_DAVINCI_MDIO 70 70 select MFD_SYSCON ··· 79 77 will be called cpsw_new. 80 78 81 79 config TI_CPTS 82 - bool "TI Common Platform Time Sync (CPTS) Support" 83 - depends on TI_CPSW || TI_KEYSTONE_NETCP || TI_CPSW_SWITCHDEV || COMPILE_TEST 80 + tristate "TI Common Platform Time Sync (CPTS) Support" 81 + depends on ARCH_OMAP2PLUS || ARCH_KEYSTONE || COMPILE_TEST 84 82 depends on COMMON_CLK 85 - depends on POSIX_TIMERS 83 + depends on PTP_1588_CLOCK 86 84 ---help--- 87 85 This driver supports the Common Platform Time Sync unit of 88 86 the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem. 89 87 The unit can time stamp PTP UDP/IPv4 and Layer 2 packets, and the 90 88 driver offers a PTP Hardware Clock. 91 - 92 - config TI_CPTS_MOD 93 - tristate 94 - depends on TI_CPTS 95 - depends on PTP_1588_CLOCK 96 - default y if TI_CPSW=y || TI_KEYSTONE_NETCP=y || TI_CPSW_SWITCHDEV=y 97 - default m 98 89 99 90 config TI_K3_AM65_CPSW_NUSS 100 91 tristate "TI K3 AM654x/J721E CPSW Ethernet driver" ··· 109 114 select TI_DAVINCI_MDIO 110 115 depends on OF 111 116 depends on KEYSTONE_NAVIGATOR_DMA && KEYSTONE_NAVIGATOR_QMSS 117 + depends on TI_CPTS || !TI_CPTS 112 118 ---help--- 113 119 This driver supports TI's Keystone NETCP Core. 114 120
+1 -1
drivers/net/ethernet/ti/Makefile
··· 13 13 ti_davinci_emac-y := davinci_emac.o davinci_cpdma.o 14 14 obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o 15 15 obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o 16 - obj-$(CONFIG_TI_CPTS_MOD) += cpts.o 16 + obj-$(CONFIG_TI_CPTS) += cpts.o 17 17 obj-$(CONFIG_TI_CPSW) += ti_cpsw.o 18 18 ti_cpsw-y := cpsw.o davinci_cpdma.o cpsw_ale.o cpsw_priv.o cpsw_sl.o cpsw_ethtool.o 19 19 obj-$(CONFIG_TI_CPSW_SWITCHDEV) += ti_cpsw_new.o