ethernet/intel: fix PTP_1588_CLOCK dependencies
Subsystems (3)
PATCH v2 1/1 ethernet/intel: fix PTP_1588_CLOCK dependencies
From: Arnd Bergmann <[email protected]>
The 'imply' keyword does not do what most people think it does, it only politely asks Kconfig to turn on another symbol, but does not prevent it from being disabled manually or built as a loadable module when the user is built-in. In the ICE driver, the latter now causes a link failure:
aarch64-linux-ld: drivers/net/ethernet/intel/ice/ice_main.o: in function `ice_eth_ioctl':
ice_main.c:(.text+0x13b0): undefined reference to `ice_ptp_get_ts_config'
ice_main.c:(.text+0x13b0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `ice_ptp_get_ts_config'
aarch64-linux-ld: ice_main.c:(.text+0x13bc): undefined reference to ice_ptp_set_ts_config' ice_main.c:(.text+0x13bc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol ice_ptp_set_ts_config'
aarch64-linux-ld: drivers/net/ethernet/intel/ice/ice_main.o: in function `ice_prepare_for_reset':
ice_main.c:(.text+0x31fc): undefined reference to `ice_ptp_release'
ice_main.c:(.text+0x31fc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `ice_ptp_release'
aarch64-linux-ld: drivers/net/ethernet/intel/ice/ice_main.o: in function `ice_rebuild':
For the other Intel network drivers, there is no link error when the drivers are built-in and PTP is a loadable module, because linux/ptp_clock_kernel.h contains an IS_REACHABLE() check, but this just changes the compile-time failure to a runtime failure, which is arguably worse.
Change all the Intel drivers to use the 'depends on PTP_1588_CLOCK || !PTP_1588_CLOCK' trick to prevent the broken configuration, as we already do for several other drivers. To avoid circular dependencies, this also requires changing the IGB driver back to using the normal 'depends on I2C' instead of 'select I2C'.
This is a recurring problem in many drivers, and we have discussed it several times befores, without reaching a consensus. I'm providing a link to the previous email thread for reference, which discusses some related problems, though I can't find what reasons there were against the approach with the extra Kconfig dependency.
---
Changes in v2:
- include a missing patch hunk
- link to a previous discussion with Richard Cochran
--- drivers/net/ethernet/intel/Kconfig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/Kconfig +7 -7
@@ -58,8 +58,8 @@ config E1000 config E1000E tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support" depends on PCI && (!SPARC32 || BROKEN) + depends on PTP_1588_CLOCK || !PTP_1588_CLOCK select CRC32 - imply PTP_1588_CLOCK help This driver supports the PCI-Express Intel(R) PRO/1000 gigabit ethernet family of adapters. For PCI or PCI-X e1000 adapters,
@@ -87,8 +87,8 @@ config E1000E_HWTS config IGB tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support" depends on PCI - imply PTP_1588_CLOCK - select I2C + depends on PTP_1588_CLOCK || !PTP_1588_CLOCK + depends on I2C select I2C_ALGOBIT help This driver supports Intel(R) 82575/82576 gigabit ethernet family of
@@ -159,9 +159,9 @@ config IXGB config IXGBE tristate "Intel(R) 10GbE PCI Express adapters support" depends on PCI + depends on PTP_1588_CLOCK || !PTP_1588_CLOCK select MDIO select PHYLIB - imply PTP_1588_CLOCK help This driver supports Intel(R) 10GbE PCI Express family of adapters. For more information on how to identify your adapter, go
@@ -239,7 +239,7 @@ config IXGBEVF_IPSEC config I40E tristate "Intel(R) Ethernet Controller XL710 Family support" - imply PTP_1588_CLOCK + depends on PTP_1588_CLOCK || !PTP_1588_CLOCK depends on PCI select AUXILIARY_BUS help
@@ -295,11 +295,11 @@ config ICE tristate "Intel(R) Ethernet Connection E800 Series Support" default n depends on PCI_MSI + depends on PTP_1588_CLOCK || !PTP_1588_CLOCK select AUXILIARY_BUS select DIMLIB select NET_DEVLINK select PLDMFW - imply PTP_1588_CLOCK help This driver supports Intel(R) Ethernet Connection E800 Series of devices. For more information on how to identify your adapter, go
@@ -317,7 +317,7 @@ config FM10K tristate "Intel(R) FM10000 Ethernet Switch Host Interface Support" default n depends on PCI_MSI - imply PTP_1588_CLOCK + depends on PTP_1588_CLOCK || !PTP_1588_CLOCK help This driver supports Intel(R) FM10000 Ethernet Switch Host Interface. For more information on how to identify your adapter,
Signature · 1 line
2.29.2
Quoted 5 lines · Arnd Bergmann
This is a recurring problem in many drivers, and we have discussed it several times befores, without reaching a consensus. I'm providing a link to the previous email thread for reference, which discusses some related problems, though I can't find what reasons there were against the approach with the extra
Kconfigdependency.
Quoting myself in the thread from 12 Nov 2020:
This whole "implies" thing turned out to be a colossal PITA.
I regret the fact that it got merged. It wasn't my idea.
This whole thing came about because Nicolas Pitre wanted to make PHC core support into a module and also to be able to remove dynamic posix clock support for tinification. It has proved to be a never ending source of confusion.
Let's restore the core functionality and remove "implies" for good.
Thanks,
Richard
Quoted 19 lines · Richard Cochran
Quoted 5 lines · Arnd Bergmann
This is a recurring problem in many drivers, and we have discussed it several times befores, without reaching a consensus. I'm providing a link to the previous email thread for reference, which discusses some related problems, though I can't find what reasons there were against the approach with the extra
Kconfigdependency.Quoting myself in the thread from 12 Nov 2020:
This whole "implies" thing turned out to be a colossal PITA.
I regret the fact that it got merged. It wasn't my idea.
This whole thing came about because Nicolas Pitre wanted to make PHC core support into a module and also to be able to remove dynamic posix clock support for tinification. It has proved to be a never ending source of confusion.
Quoted 5 lines
Let's restore the core functionality and remove "implies" for good.
Thanks,
Richard
So go back to "select"?
It looks like Arnd proposed in the thread a solution that did a sort of "please enable this" but still let you disable it.
An alternative (unfortunately per-driver...) solution was to setup the drivers so that they gracefully fall back to disabling PTP if the PTP core support is not reachable.. but that obviously requires that drivers do the right thing, and at least Intel drivers have not tested this properly.
I'm definitely in favor of removing "implies" entirely. The semantics are unclear, and the fact that it doesn't handle the case of "i'm builtin, so my implies can't be modules"...
I don't really like the syntax of the double "depends on A || !A".. I'd prefer if we had some keyword for this, since it would be more obvious and not run against the standard logic (A || !A is a tautology!)
Thanks,
Jake
Quoted 12 lines · Jacob E
So go back to "select"?
It looks like Arnd proposed in the thread a solution that did a sort of "please enable this" but still let you disable it.
An alternative (unfortunately per-driver...) solution was to setup the drivers so that they gracefully fall back to disabling PTP if the PTP core support is not reachable.. but that obviously requires that drivers do the right thing, and at least Intel drivers have not tested this properly.
Quoted 7 lines
I'm definitely in favor of removing "implies" entirely. The semantics are unclear, and the fact that it doesn't handle the case of "i'm builtin, so my implies can't be modules"...
I don't really like the syntax of the double "depends on A || !A".. I'd prefer if we had some keyword for this, since it would be more obvious and not run against the standard logic (A || !A is a tautology!)
I think the main reason we don't have a keyword for it is that nobody so far has come up with an English word that expresses what it is supposed to mean.
You can do something like it for a particular symbol though, such as
config MAY_USE_PTP_1588_CLOCK
def_tristate PTP_1588_CLOCK || !PTP_1588_CLOCK
config E1000E
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support" depends on PCI && (!SPARC32 || BROKEN)
+ depends on MAY_USE_PTP_1588_CLOCK
select CRC32
- imply PTP_1588_CLOCK
Arnd
Quoted 35 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Monday, August 02, 2021 1:32 PM
To: Keller, Jacob E <[email protected]>
Cc: Richard Cochran <[email protected]>; Nicolas Pitre <[email protected]>; Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Arnd Bergmann <[email protected]>; Kurt Kanzenbach <[email protected]>; Saleem, Shiraz <[email protected]>; Ertman, David M <[email protected]>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux- kernel at vger.kernel.org
Subject: Re: [PATCH net-next v2] ethernet/intel: fixPTP_1588_CLOCKdependenciesQuoted 16 lines · Jacob E
So go back to "select"?
It looks like Arnd proposed in the thread a solution that did a sort of "please enable this" but still let you disable it.
An alternative (unfortunately per-driver...) solution was to setup the drivers so that they gracefully fall back to disabling PTP if the PTP core support is not reachable.. but that obviously requires that drivers do the right thing, and at least Intel drivers have not tested this properly.
I'm definitely in favor of removing "implies" entirely. The semantics are unclear, and the fact that it doesn't handle the case of "i'm builtin, so my implies can't be modules"...
Quoted 8 lines
Quoted 3 lines
I don't really like the syntax of the double "depends on A || !A".. I'd prefer if we had some keyword for this, since it would be more obvious and not run against the standard logic (A || !A is a tautology!)
I think the main reason we don't have a keyword for it is that nobody so far has come up with an English word that expresses what it is supposed to mean.
Right. I don't have a great example that's a single word either.
drivers/net/ethernet/intel/Kconfig config E1000 · line 62
Quoted 11 lines
You can do something like it for a particular symbol though, such as
config
MAY_USE_PTP_1588_CLOCKdef_tristate PTP_1588_CLOCK || !PTP_1588_CLOCKconfig E1000E
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support" depends on PCI && (!SPARC32 || BROKEN)drivers/net/ethernet/intel/Kconfig +1
-1+ depends on MAY_USE_PTP_1588_CLOCK select CRC32 - imply PTP_1588_CLOCK
What about "integrates"?
Or.. what if we just changed "implies" to also include the dependencies automatically? i.e. "implies PTP_1588_CLOCK" also means the depends trick which ensures that you can't have it as module if this is built-in.
I.e. we still get the nice "this will turn on automatically in the menu if you enable this" and we enforce that you can't have it as a module since it would be a dependency if it's on"?
Quoted 3 lines
Arnd
Quoted 5 lines · Jacob E
Quoted 5 lines
You can do something like it for a particular symbol though, such as
config
MAY_USE_PTP_1588_CLOCKdef_tristate PTP_1588_CLOCK || !PTP_1588_CLOCK
Quoted 8 lines
drivers/net/ethernet/intel/Kconfig config E1000 · line 62
Quoted 6 lines
config E1000E
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support" depends on PCI && (!SPARC32 || BROKEN)drivers/net/ethernet/intel/Kconfig +1
-1+ depends on MAY_USE_PTP_1588_CLOCK select CRC32 - imply PTP_1588_CLOCKWhat about "integrates"?
Maybe, we'd need to look at whether that fits for the other users of the "A || !A" trick.
Quoted 7 lines
Or.. what if we just changed "implies" to also include the dependencies automatically? i.e. "implies
PTP_1588_CLOCK" also means the depends trick which ensures that you can't have it as module if this is built-in.I.e. we still get the nice "this will turn on automatically in the menu if you enable this" and we enforce that you can't have it as a module since it would be a dependency if it's on"?
I don't want to mess with the semantics of the keyword any further. The original meaning was meant to avoid circular dependencies by making it a softer version of 'select' that would not try to select anything that has unmet dependencies. The current version made it even softer by only having an effect during 'make defconfig' and 'make oldconfig' but not preventing it from being soft-disabled any more. Changing it yet again is guarantee to break lots of the existing users, while probably also bringing back the original problem of the circular dependencies.
Arnd
Quoted 27 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Monday, August 02, 2021 1:59 PM
To: Keller, Jacob E <[email protected]>
Cc: Richard Cochran <[email protected]>; Nicolas Pitre <[email protected]>; Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Arnd Bergmann <[email protected]>; Kurt Kanzenbach <[email protected]>; Saleem, Shiraz <[email protected]>; Ertman, David M <[email protected]>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux- kernel at vger.kernel.org
Subject: Re: [PATCH net-next v2] ethernet/intel: fixPTP_1588_CLOCKdependenciesI don't want to mess with the semantics of the keyword any further. The original meaning was meant to avoid circular dependencies by making it a softer version of 'select' that would not try to select anything that has unmet dependencies. The current version made it even softer by only having an effect during 'make defconfig' and 'make oldconfig' but not preventing it from being soft-disabled any more. Changing it yet again is guarantee to break lots of the existing users, while probably also bringing back the original problem of the circular dependencies.
Quoted 1 line
Arnd
Yea ok that makes sense. Better to use a new keyword if we do at all.
Quoted 32 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Monday, August 02, 2021 1:59 PM
To: Keller, Jacob E <[email protected]>
Cc: Richard Cochran <[email protected]>; Nicolas Pitre <[email protected]>; Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Arnd Bergmann <[email protected]>; Kurt Kanzenbach <[email protected]>; Saleem, Shiraz <[email protected]>; Ertman, David M <[email protected]>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux- kernel at vger.kernel.org
Subject: Re: [PATCH net-next v2] ethernet/intel: fixPTP_1588_CLOCKdependenciesQuoted 12 lines · Jacob E
Quoted 11 lines
You can do something like it for a particular symbol though, such as
config
MAY_USE_PTP_1588_CLOCKdef_tristate PTP_1588_CLOCK || !PTP_1588_CLOCKconfig E1000E
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support" depends on PCI && (!SPARC32 || BROKEN)drivers/net/ethernet/intel/Kconfig +1
-1+ depends on MAY_USE_PTP_1588_CLOCK select CRC32 - imply PTP_1588_CLOCK
Quoted 5 lines
Quoted 1 line
What about "integrates"?
Maybe, we'd need to look at whether that fits for the other users of the "A || !A" trick.
Sure. I just know from reading it other places it really causes a "huh?" reaction.
Quoted 15 lines · Arnd Bergmann
Quoted 12 lines · Jacob E
Quoted 11 lines
You can do something like it for a particular symbol though, such as
config
MAY_USE_PTP_1588_CLOCKdef_tristate PTP_1588_CLOCK || !PTP_1588_CLOCKconfig E1000E
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support" depends on PCI && (!SPARC32 || BROKEN)drivers/net/ethernet/intel/Kconfig +1
-1+ depends on MAY_USE_PTP_1588_CLOCK select CRC32 - imply PTP_1588_CLOCK
Quoted 4 lines
Quoted 1 line
What about "integrates"?
Maybe, we'd need to look at whether that fits for the other users of the "A || !A" trick.
I implemented "conditional dependencies" at the time, which is syntactic sugar to express the above as:
depends on A if A != n depends on A if A
etc.
http://lkml.iu.edu/hypermail/linux/kernel/2004.2/09783.html
But Masahiro shut it down.
Nicolas
drivers/net/ethernet/intel/Kconfig config E1000 · line 62
Quoted 9 lines · Arnd Bergmann
config
MAY_USE_PTP_1588_CLOCKdef_tristate PTP_1588_CLOCK || !PTP_1588_CLOCKconfig E1000E
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support" depends on PCI && (!SPARC32 || BROKEN)drivers/net/ethernet/intel/Kconfig +1
-1+ depends on MAY_USE_PTP_1588_CLOCK select CRC32 - imply PTP_1588_CLOCK
I've written up the patch to do this all over the kernel now, and started an overnight randconfig build session with this applied:
Arnd
Quoted 1 line · Jacob E
So go back to "select"?
Why not keep it simple?
PTP core:
Boolean PTP_1588_CLOCK
drivers:
depends on PTP_1588_CLOCK
Also, make Posix timers always part of the core. Tinification is a lost cause.
Thanks,
Richard
Quoted 22 lines
-----Original Message-----
From: Richard Cochran <[email protected]>
Sent: Monday, August 02, 2021 4:09 PM
To: Keller, Jacob E <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Nicolas Pitre <[email protected]>; Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Arnd Bergmann <[email protected]>; Kurt Kanzenbach <[email protected]>; Saleem, Shiraz <[email protected]>; Ertman, David M <[email protected]>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux-kernel at vger.kernel.org
Subject: Re: [PATCH net-next v2] ethernet/intel: fixPTP_1588_CLOCKdependenciesQuoted 1 line · Jacob E
So go back to "select"?
Why not keep it simple?
PTP core:
Boolean PTP_1588_CLOCK
Quoted 8 lines
drivers:
depends onPTP_1588_CLOCKAlso, make Posix timers always part of the core. Tinification is a lost cause.
Thanks,
Richard
Ok, so basically: if any driver that needs PTP core is on, PTP core is on, with no way to disable it.
Thanks,
Jake
Quoted 1 line · Jacob E
Ok, so basically: if any driver that needs PTP core is on, PTP core is on, with no way to disable it.
Right. Some MAC drivers keep the PTP stuff under a second Kconfig option.
IIRC, we (davem and netdev) decided not to do that going forwards. If a MAC has PTP features, then users will sure want it enabled.
So, let the MACs use "depends" or "select" PTP core. I guess that "select" is more user friendly.
And Posix timers: never disable this. After all, who wants an embedded system without timer_create()? Seriously?
Thanks,
Richard
Quoted 6 lines · Richard Cochran
Quoted 1 line · Jacob E
So go back to "select"?
Why not keep it simple?
Quoted 8 lines
PTP core:
Boolean PTP_1588_CLOCKdrivers:
depends onPTP_1588_CLOCKAlso, make Posix timers always part of the core. Tinification is a lost cause.
It may well be a lost cause, but a build fix is not the time to nail down that decision. The fix I proposed (with the added MAY_USE_PTP_1588_CLOCK symbol) is only two extra lines and leaves everything else working for the moment. I would suggest we merge that first and then raise the question about whether to give up on tinyfication on the summit list, there are a few other things that have come up that would also benefit from trying less hard, but if we overdo this, we can get to the point of hurting even systems that are otherwise still well supported (64MB MIPS/ARMv5 SoCs, small boot partitions, etc.).
Arnd
Quoted 4 lines · Arnd Bergmann
It may well be a lost cause, but a build fix is not the time to nail down that decision. The fix I proposed (with the added
MAY_USE_PTP_1588_CLOCKsymbol) is only two extra lines and leaves everything else working for the moment.
Well, then we'll have TWO ugly and incomprehensible Kconfig hacks, imply and MAY_USE.
Can't we fix this once and for all?
Seriously, "imply" has been nothing but a major PITA since day one, and all to save 22 kb. I can't think of another subsystem which tolerates so much pain for so little gain.
Thanks,
Richard
Quoted 8 lines
I would suggest we merge that first and then raise the question about whether to give up on tinyfication on the summit list, there are a few other things that have come up that would also benefit from trying less hard, but if we overdo this, we can get to the point of hurting even systems that are otherwise still well supported (64MB MIPS/ARMv5 SoCs, small boot partitions, etc.).
Arnd
Quoted 6 lines · Richard Cochran
Quoted 4 lines · Arnd Bergmann
It may well be a lost cause, but a build fix is not the time to nail down that decision. The fix I proposed (with the added
MAY_USE_PTP_1588_CLOCKsymbol) is only two extra lines and leaves everything else working for the moment.
Quoted 8 lines
Well, then we'll have TWO ugly and incomprehensible
Kconfighacks, imply andMAY_USE.Can't we fix this once and for all?
Seriously, "imply" has been nothing but a major PITA since day one, and all to save 22 kb. I can't think of another subsystem which tolerates so much pain for so little gain.
Here is what I want to have, in accordance with the KISS principle:
config PTP_1588_CLOCK
bool "PTP clock support"
select NET
select POSIX_TIMERS
select PPS
select NET_PTP_CLASSIFY
# driver variant 1:
config ACME_MAC
select PTP_1588_CLOCK
# driver variant 2:
config ACME_MAC
config ACME_MAC_PTP
depends on ACME_MAC select PTP_1588_CLOCK
Hm?
Thanks,
Richard
Quoted 9 lines · Richard Cochran
Quoted 8 lines · Richard Cochran
Quoted 4 lines · Arnd Bergmann
It may well be a lost cause, but a build fix is not the time to nail down that decision. The fix I proposed (with the added
MAY_USE_PTP_1588_CLOCKsymbol) is only two extra lines and leaves everything else working for the moment.Well, then we'll have TWO ugly and incomprehensible
Kconfighacks, imply andMAY_USE.
I'm all in favor of removing imply elsewhere as well, but that needs much broader consensus than removing it from PTP_1588_CLOCK.
It has already crept into cryto/ and sound/soc/codecs/, and at least in the latter case it does seem to even make sense, so they are less likely to remove it.
Quoted 22 lines
Quoted 5 lines
Can't we fix this once and for all?
Seriously, "imply" has been nothing but a major PITA since day one, and all to save 22 kb. I can't think of another subsystem which tolerates so much pain for so little gain.
Here is what I want to have, in accordance with the KISS principle:
config
PTP_1588_CLOCK
bool "PTP clock support"
select NET
selectPOSIX_TIMERS
select PPS
selectNET_PTP_CLASSIFY# driver variant 1:config
ACME_MACselect PTP_1588_CLOCK# driver variant 2:
Quoted 7 lines
config
ACME_MACconfig
ACME_MAC_PTP
depends onACME_MAC
selectPTP_1588_CLOCKHm?
Selecting a subsystem (NET, POSIX_TIMES, PPS, NET_PTP_CLASSIFY) from a device driver is the nightmare that 'imply' was meant to solve (but did not): this causes dependency loops, and unintended behavior where you end up accidentally enabling a lot more drivers than you actually need (when other symbols depend on the selected ones, and default to y).
If you turn all those 'select' lines into 'depends on', this will work, but it's not actually much different from what I'm suggesting. Maybe we can do it in two steps: first fix the build failure by replacing all the 'imply' statements
with the correct dependencies, and then you send a patch on top that turns PPS and PTP_1588_CLOCK into bool options.
Arnd
Quoted 72 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Tuesday, August 03, 2021 10:01 AM
To: Richard Cochran <[email protected]>
Cc: Nicolas Pitre <[email protected]>; Keller, Jacob E <[email protected]>; Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Arnd Bergmann <[email protected]>; Kurt Kanzenbach <[email protected]>; Saleem, Shiraz <[email protected]>; Ertman, David M <[email protected]>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux-kernel at vger.kernel.org
Subject: Re: [PATCH net-next v2] ethernet/intel: fixPTP_1588_CLOCKdependenciesQuoted 4 lines · Richard Cochran
Quoted 3 lines · Richard Cochran
Quoted 2 lines · Arnd Bergmann
It may well be a lost cause, but a build fix is not the time to nail down that decision. The fix I proposed (with the added
MAY_USE_PTP_1588_CLOCKQuoted 5 lines
Quoted 5 lines
Quoted 2 lines
symbol) is only two extra lines and leaves everything else working for the moment.
Well, then we'll have TWO ugly and incomprehensible
Kconfighacks, imply andMAY_USE.I'm all in favor of removing imply elsewhere as well, but that needs much broader consensus than removing it from
PTP_1588_CLOCK.It has already crept into cryto/ and
sound/soc/codecs/, and at least in the latter case it does seem to even make sense, so they are less likely to remove it.Quoted 22 lines
Quoted 5 lines
Can't we fix this once and for all?
Seriously, "imply" has been nothing but a major PITA since day one, and all to save 22 kb. I can't think of another subsystem which tolerates so much pain for so little gain.
Here is what I want to have, in accordance with the KISS principle:
config
PTP_1588_CLOCK
bool "PTP clock support"
select NET
selectPOSIX_TIMERS
select PPS
selectNET_PTP_CLASSIFY# driver variant 1:config
ACME_MACselect PTP_1588_CLOCK# driver variant 2:Quoted 7 lines
config
ACME_MACconfig
ACME_MAC_PTP
depends onACME_MAC
selectPTP_1588_CLOCKHm?
Selecting a subsystem (NET,
POSIX_TIMES, PPS,NET_PTP_CLASSIFY) from a device driver is the nightmare that 'imply' was meant to solve (but did not): this causes dependency loops, and unintended behavior where you end up accidentally enabling a lot more drivers than you actually need (when other symbols depend on the selected ones, and default to y).
Quoted 8 lines
If you turn all those 'select' lines into 'depends on', this will work, but it's not actually much different from what I'm suggesting. Maybe we can do it in two steps: first fix the build failure by replacing all the 'imply' statements
with the correct dependencies, and then you send a patch on top that turns PPS andPTP_1588_CLOCKinto bool options.Arnd
There is an alternative solution to fixing the imply keyword:
Make the drivers use it properly by *actually* conditionally enabling the feature only when IS_REACHABLE, i.e. fix ice so that it uses IS_REACHABLE instead of IS_ENABLED, and so that its stub implementation in ice_ptp.h actually just silently does nothing but returns 0 to tell the rest of the driver things are fine.
This would make it work correctly for users who want tinification, *and* it would make there be no strong dependency between anything, while still allowing optionally defaulting to yes.
That being said, I don't think saving 22kb is worth the chance to get things wrong (as we've seen).
Thanks,
Jake
Quoted 5 lines · Jacob E
Quoted 1 line · Richard Cochran
There is an alternative solution to fixing the imply keyword:
Make the drivers use it properly by *actually* conditionally enabling the feature only when
IS_REACHABLE, i.e. fix ice so that it usesIS_REACHABLEinstead ofIS_ENABLED, and so that its stub implementation inice_ptp.hactually just silently does nothing but returns 0 to tell the rest of the driver things are fine.
I would consider IS_REACHABLE() part of the problem, not the solution, it makes things magically build, but then surprises users at runtime when they do not get the intended behavior.
Arnd
Quoted 28 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Tuesday, August 03, 2021 11:27 AM
To: Keller, Jacob E <[email protected]>
Cc: Richard Cochran <[email protected]>; Nicolas Pitre <[email protected]>; Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Arnd Bergmann <[email protected]>; Kurt Kanzenbach <[email protected]>; Saleem, Shiraz <[email protected]>; Ertman, David M <[email protected]>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux- kernel at vger.kernel.org
Subject: Re: [PATCH net-next v2] ethernet/intel: fixPTP_1588_CLOCKdependenciesQuoted 1 line · Jacob E
Quoted 1 line
On Tue, Aug 3, 2021 at 6:14 PM Richard Cochran
Quoted 3 lines · <[email protected]> wrote:
There is an alternative solution to fixing the imply keyword:
Make the drivers use it properly by *actually* conditionally enabling the feature
only when
IS_REACHABLE, i.e. fix ice so that it usesIS_REACHABLEinstead ofIS_ENABLED, and so that its stub implementation inice_ptp.hactually just silently does nothing but returns 0 to tell the rest of the driver things are fine.
Quoted 5 lines
I would consider
IS_REACHABLE()part of the problem, not the solution, it makes things magically build, but then surprises users at runtime when they do not get the intended behavior.Arnd
Fair enough. I am also fine with just "depends". We can make most of the drivers simply always enable it, and if a specific driver is used in some embedded setup that has requirements on minimizing things that driver can be setup to use a 2nd config symbol, and all of the other drivers that aren't used can be disabled (as that minimizer is probably already doing!)
I think we've found the best route to go then!
Thanks,
Jake
Quoted 11 lines · Arnd Bergmann
Quoted 5 lines · Jacob E
Quoted 1 line · Richard Cochran
There is an alternative solution to fixing the imply keyword:
Make the drivers use it properly by *actually* conditionally enabling the feature only when
IS_REACHABLE, i.e. fix ice so that it usesIS_REACHABLEinstead ofIS_ENABLED, and so that its stub implementation inice_ptp.hactually just silently does nothing but returns 0 to tell the rest of the driver things are fine.I would consider
IS_REACHABLE()part of the problem, not the solution, it makes things magically build, but then surprises users at runtime when they do not get the intended behavior.
Case in point: two patches from Yangbo Lu that call into the ptp core from built-in
network code look like they could never have worked with CONFIG_PTP_1588_CLOCK, but did not cause a link failure because of the IS_REACHABLE() check, see commit d7c088265588 ("net: socket: support hardware timestamp conversion to PHC bound") and c156174a6707 ("ethtool: add a new command for getting PHC virtual clocks").
I found that by testing my patch that turns the IS_REACHABLE() back into IS_ENABLED() and got
aarch64-linux-ld: net/socket.o: in function `__sock_recv_timestamp':
socket.c:(.text+0x1f20): undefined reference to `ptp_convert_timestamp'
aarch64-linux-ld: net/ethtool/common.o: in function `ethtool_get_phc_vclocks':
common.c:(.text+0x35c): undefined reference to `ptp_get_vclocks_index'
I added a workaround to my patch now to keep it working as before, but this needs to be fixed properly. The easiest way would be to no longer support modular PTP at all as Richard would like to do anyway, but I have not attempted other fixes.
Arnd
Quoted 2 lines · Arnd Bergmann
If you turn all those 'select' lines into 'depends on', this will work, but it's not actually much different from what I'm suggesting.
"depends" instead of "select" works for me. I just want it simple and clear.
Quoted 5 lines
Maybe we can do it
in two steps: first fix the build failure by replacing all the 'imply' statements
with the correct dependencies, and then you send a patch on top that turns PPS andPTP_1588_CLOCKinto bool options.
Sounds good.
Thanks,
Richard
Quoted 30 lines
-----Original Message-----
From: Richard Cochran <[email protected]>
Sent: Tuesday, August 03, 2021 1:55 PM
To: Arnd Bergmann <[email protected]>
Cc: Nicolas Pitre <[email protected]>; Keller, Jacob E <[email protected]>; Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Arnd Bergmann <[email protected]>; Kurt Kanzenbach <[email protected]>; Saleem, Shiraz <[email protected]>; Ertman, David M <[email protected]>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux-kernel at vger.kernel.org
Subject: Re: [PATCH net-next v2] ethernet/intel: fixPTP_1588_CLOCKdependenciesQuoted 2 lines · Arnd Bergmann
If you turn all those 'select' lines into 'depends on', this will work, but it's not actually much different from what I'm suggesting.
"depends" instead of "select" works for me. I just want it simple and clear.
Quoted 5 lines
Maybe we can do it
in two steps: first fix the build failure by replacing all the 'imply' statements
with the correct dependencies, and then you send a patch on top that turns PPS andPTP_1588_CLOCKinto bool options.
Quoted 4 lines
Sounds good.
Thanks,
Richard
Works for me too.
Thanks,
Jake