Skip to contentSkip to conversation

kbuild: Disable compile testing if HAVE_LEGACY_CLK enabled

PATCH In review Dmitry Osipenko 5 participants 9 messages May 23, 2021 – May 28, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: Disable compile testing if HAVE_LEGACY_CLK enabled

There are couple older platforms that can't be compile-tested because they partially implement CLK API. It causes build failure of kernel drivers due to the missing symbols of the unimplemented part of CLK API.

These platforms are: ARM EP93XX, ARM OMAP1, m68k ColdFire, MIPS AR7,
MIPS Ralink.

Disable compile-testing for HAVE_LEGACY_CLK=y.

---
 init/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/Kconfig +1 -1
index 173a474012d7..42701b04be00 100644
@@ -131,7 +131,7 @@ config INIT_ENV_ARG_LIMIT
 
 config COMPILE_TEST
 	bool "Compile also drivers which will not load"
-	depends on HAS_IOMEM
+	depends on HAS_IOMEM && !HAVE_LEGACY_CLK
 	help
 	  Some drivers can be compiled on a different platform than they are
 	  intended to be run on. Despite they cannot be loaded there (or even
Signature · 1 line
2.30.2
#1 lore raw

Hi Dmitry,

Quoted 11 lines · Dmitry Osipenko

There are couple older platforms that can't be compile-tested because they partially implement CLK API. It causes build failure of kernel drivers due to the missing symbols of the unimplemented part of CLK API.

These platforms are: ARM EP93XX, ARM OMAP1, m68k ColdFire, MIPS AR7,
MIPS Ralink.

Disable compile-testing for HAVE_LEGACY_CLK=y.

Thanks for your patch!

init/Kconfig config INIT_ENV_ARG_LIMIT · line 134

Quoted 8 lines
init/Kconfig +1 -1
@@ -131,7 +131,7 @@ config INIT_ENV_ARG_LIMIT
 
 config COMPILE_TEST
        bool "Compile also drivers which will not load"
-       depends on HAS_IOMEM
+       depends on HAS_IOMEM && !HAVE_LEGACY_CLK

That sounds a bit drastic to me. Usually we just try to implement the missing functionality, or provide stubs.
Which functions are missing?

init/Kconfig config INIT_ENV_ARG_LIMIT · line 137

Quoted 3 lines
init/Kconfig +0 -0
        help
          Some drivers can be compiled on a different platform than they are
          intended to be run on. Despite they cannot be loaded there (or even

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#2 lore raw

24.05.2021 11:54, Geert Uytterhoeven пишет:

Quoted 21 lines

Hi Dmitry,

Quoted 11 lines · Dmitry Osipenko

There are couple older platforms that can't be compile-tested because they partially implement CLK API. It causes build failure of kernel drivers due to the missing symbols of the unimplemented part of CLK API.

These platforms are: ARM EP93XX, ARM OMAP1, m68k ColdFire, MIPS AR7,
MIPS Ralink.

Disable compile-testing for HAVE_LEGACY_CLK=y.

Thanks for your patch!

Quoted 4 lines
init/Kconfig +0 -0
@@ -131,7 +131,7 @@ config INIT_ENV_ARG_LIMIT
 
Quoted 8 lines

init/Kconfig config INIT_ENV_ARG_LIMIT · line 134

Quoted 4 lines
init/Kconfig +1 -1
 config COMPILE_TEST
        bool "Compile also drivers which will not load"
-       depends on HAS_IOMEM
+       depends on HAS_IOMEM && !HAVE_LEGACY_CLK

That sounds a bit drastic to me. Usually we just try to implement the missing functionality, or provide stubs.
Which functions are missing?

Everything that belongs to CONFIG_COMMON_CLK needs stubs.

That is everything under CONFIG_HAVE_CLK [1], excluding functions belonging to clk-devres.o and clk-bulk.o [2]. The HAVE_LEGACY_CLK selects HAVE_CLK, but the COMMON_CLK is under HAVE_CLK too.

[1]
https://elixir.bootlin.com/linux/v5.13-rc3/source/include/linux/clk.h#L786
[2]
https://elixir.bootlin.com/linux/v5.13-rc3/source/drivers/clk/Makefile#L3

This problem is repeated over and over again for the past years. Some maintainers are adding "depends on COMMON_CLK" for COMPILE_TEST of each driver, but this doesn't solve the root of the problem, and thus, it's constantly reoccurring.

Recently Krzysztof Kozlowski added couple more clk stubs for MIPS, but still lots of stubs are missing. Some platforms don't have any stubs at all and apparently nobody cares to fix them.

There 3 possible solutions:

1. Factor out COMMON_CLK from HAVE_LEGACY_CLK, if this is possible
2. Build stubs universally, maybe using weak functions.
3. Disable compile-testing for HAVE_LEGACY_CLK

The third option is the simplest. If anyone will care to fix those legacy platforms properly, then compile-testing could be re-enabled for them. This is my proposal.

#3 lore raw
Quoted 47 lines · Dmitry Osipenko

24.05.2021 11:54, Geert Uytterhoeven пишет:

Quoted 21 lines

Hi Dmitry,

Quoted 11 lines · Dmitry Osipenko

There are couple older platforms that can't be compile-tested because they partially implement CLK API. It causes build failure of kernel drivers due to the missing symbols of the unimplemented part of CLK API.

These platforms are: ARM EP93XX, ARM OMAP1, m68k ColdFire, MIPS AR7,
MIPS Ralink.

Disable compile-testing for HAVE_LEGACY_CLK=y.

Thanks for your patch!

Quoted 4 lines
init/Kconfig +0 -0
@@ -131,7 +131,7 @@ config INIT_ENV_ARG_LIMIT
 
Quoted 8 lines

init/Kconfig config INIT_ENV_ARG_LIMIT · line 134

Quoted 4 lines
init/Kconfig +1 -1
 config COMPILE_TEST
        bool "Compile also drivers which will not load"
-       depends on HAS_IOMEM
+       depends on HAS_IOMEM && !HAVE_LEGACY_CLK

That sounds a bit drastic to me. Usually we just try to implement the missing functionality, or provide stubs.
Which functions are missing?

Everything that belongs to CONFIG_COMMON_CLK needs stubs.

That is everything under CONFIG_HAVE_CLK [1], excluding functions belonging to clk-devres.o and clk-bulk.o [2]. The HAVE_LEGACY_CLK selects HAVE_CLK, but the COMMON_CLK is under HAVE_CLK too.

[1]
https://elixir.bootlin.com/linux/v5.13-rc3/source/include/linux/clk.h#L786
[2]
https://elixir.bootlin.com/linux/v5.13-rc3/source/drivers/clk/Makefile#L3

This problem is repeated over and over again for the past years. Some maintainers are adding "depends on COMMON_CLK" for COMPILE_TEST of each driver, but this doesn't solve the root of the problem, and thus, it's constantly reoccurring.

Quoted 8 lines

Recently Krzysztof Kozlowski added couple more clk stubs for MIPS, but still lots of stubs are missing. Some platforms don't have any stubs at all and apparently nobody cares to fix them.

There 3 possible solutions:

1. Factor out COMMON_CLK from HAVE_LEGACY_CLK, if this is possible
2. Build stubs universally, maybe using weak functions.

I vote for this one - global stubs.

Or for a new one:
4. Disable COMPILE_TEST for specific platforms (mentioned in commit msg). Eventually could be like:
config RALINK

	depends !COMPILE_TEST || (COMPILE_TEST && COMMON_CLK)

Why? Because it is expected that a driver requiring/using missing clock stubs won't run on such legacy platform. Currently it cannot run because simply missing stubs will break build. Option (2) would make them compileable but not runnable, which is fine. However having a build time failure is better, so maybe let's just isolate platforms which are very poor in compile testing and don't enable them for most of the configs.

Best regards,
Krzysztof

#4 lore raw

Hi Krzysztof,

Quoted 50 lines · Krzysztof Kozlowski
Quoted 49 lines · Dmitry Osipenko

24.05.2021 11:54, Geert Uytterhoeven пишет:

Quoted 19 lines · Dmitry Osipenko
Quoted 11 lines

There are couple older platforms that can't be compile-tested because they partially implement CLK API. It causes build failure of kernel drivers due to the missing symbols of the unimplemented part of CLK API.

These platforms are: ARM EP93XX, ARM OMAP1, m68k ColdFire, MIPS AR7,
MIPS Ralink.

Disable compile-testing for HAVE_LEGACY_CLK=y.

Thanks for your patch!

Quoted 4 lines
init/Kconfig +0 -0
@@ -131,7 +131,7 @@ config INIT_ENV_ARG_LIMIT
 
Quoted 8 lines

init/Kconfig config INIT_ENV_ARG_LIMIT · line 134

Quoted 4 lines
init/Kconfig +1 -1
 config COMPILE_TEST
        bool "Compile also drivers which will not load"
-       depends on HAS_IOMEM
+       depends on HAS_IOMEM && !HAVE_LEGACY_CLK

That sounds a bit drastic to me. Usually we just try to implement the missing functionality, or provide stubs.
Which functions are missing?

Everything that belongs to CONFIG_COMMON_CLK needs stubs.

That is everything under CONFIG_HAVE_CLK [1], excluding functions belonging to clk-devres.o and clk-bulk.o [2]. The HAVE_LEGACY_CLK selects HAVE_CLK, but the COMMON_CLK is under HAVE_CLK too.

[1]
https://elixir.bootlin.com/linux/v5.13-rc3/source/include/linux/clk.h#L786
[2]
https://elixir.bootlin.com/linux/v5.13-rc3/source/drivers/clk/Makefile#L3

This problem is repeated over and over again for the past years. Some maintainers are adding "depends on COMMON_CLK" for COMPILE_TEST of each driver, but this doesn't solve the root of the problem, and thus, it's constantly reoccurring.

Recently Krzysztof Kozlowski added couple more clk stubs for MIPS, but still lots of stubs are missing. Some platforms don't have any stubs at all and apparently nobody cares to fix them.

Quoted 6 lines
Quoted 4 lines

There 3 possible solutions:

1. Factor out COMMON_CLK from HAVE_LEGACY_CLK, if this is possible
2. Build stubs universally, maybe using weak functions.

I vote for this one - global stubs.

Yep.

Quoted 5 lines

Or for a new one:
4. Disable COMPILE_TEST for specific platforms (mentioned in commit msg). Eventually could be like:
config RALINK

        depends !COMPILE_TEST || (COMPILE_TEST && COMMON_CLK)

That's a neat idea!

Of course there's a fifth option:

5. Convert legacy platforms to COMMON_CLK.

Which is already happening for ARM EP93XX.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#5 lore raw

25.05.2021 15:19, Geert Uytterhoeven пишет:
...

Quoted 15 lines
Quoted 6 lines
Quoted 4 lines

There 3 possible solutions:

1. Factor out COMMON_CLK from HAVE_LEGACY_CLK, if this is possible
2. Build stubs universally, maybe using weak functions.

I vote for this one - global stubs.

Yep.

Quoted 5 lines

Or for a new one:
4. Disable COMPILE_TEST for specific platforms (mentioned in commit msg). Eventually could be like:
config RALINK

        depends !COMPILE_TEST || (COMPILE_TEST && COMMON_CLK)
Quoted 7 lines

That's a neat idea!

Of course there's a fifth option:

5. Convert legacy platforms to COMMON_CLK.

Which is already happening for ARM EP93XX.

I'll try to take a closer look at alternative options, thank you for yours input.

#6 lore raw
Quoted 19 lines · Dmitry Osipenko

25.05.2021 15:19, Geert Uytterhoeven пишет:
...

Quoted 17 lines
Quoted 6 lines
Quoted 4 lines

There 3 possible solutions:

1. Factor out COMMON_CLK from HAVE_LEGACY_CLK, if this is possible
2. Build stubs universally, maybe using weak functions.

I vote for this one - global stubs.

Yep.

Quoted 5 lines

Or for a new one:
4. Disable COMPILE_TEST for specific platforms (mentioned in commit msg). Eventually could be like:
config RALINK

        depends !COMPILE_TEST || (COMPILE_TEST && COMMON_CLK)

That's a neat idea!

Quoted 8 lines
Quoted 5 lines

Of course there's a fifth option:

5. Convert legacy platforms to COMMON_CLK.

Which is already happening for ARM EP93XX.

I'll try to take a closer look at alternative options, thank you for yours input.

Hi,

If you are messing around with HAVE_LEGACY_CLK and COMMON_CLK and don't mind, please have a look at this report from 'kernel test robot':
https://lore.kernel.org/lkml/[email protected]/

Maybe this one is more MIPS-specific. I dunno. I tried to come up with a patch for it and failed.

I will be happy to built-test any patches that you come up with.

Maybe I have just looked at this too long...

thanks.

Signature · 1 line
~Randy
#7 lore raw
Quoted 8 lines · Randy Dunlap
Quoted 1 line · Dmitry Osipenko

25.05.2021 15:19, Geert Uytterhoeven пишет:

If you are messing around with HAVE_LEGACY_CLK and COMMON_CLK and don't mind, please have a look at this report from 'kernel test robot':
https://lore.kernel.org/lkml/[email protected]/

Quoted 6 lines

Maybe this one is more MIPS-specific. I dunno. I tried to come up with a patch for it and failed.

I will be happy to built-test any patches that you come up with.

Maybe I have just looked at this too long...

This is exactly the case that Dmitry is trying to solve. The problem is that bcm63xx
and lantiq set CONFIG_HAVE_LEGACY_CLK but lack the clk_set_parent() and clk_get_parent() functions. We could add the same stubs for these two that we have for the other legacy clk implementations, or rework the handling of legacy clocks completely.

Arnd

#8 lore raw
In reply to Dmitry Osipenko
Quoted 10 lines · Dmitry Osipenko

24.05.2021 11:54, Geert Uytterhoeven пишет:

Quoted 9 lines

Hi Dmitry,

Quoted 6 lines · Dmitry Osipenko

There are couple older platforms that can't be compile-tested because they partially implement CLK API. It causes build failure of kernel drivers due to the missing symbols of the unimplemented part of CLK API.

These platforms are: ARM EP93XX, ARM OMAP1, m68k ColdFire, MIPS AR7,
MIPS Ralink.

There is also most of arch/sh/, with the one exception of J2.

On MIPS, I see BCM63XX and Lantiq in addition to AR7 and Ralink.

I think the patches to convert ep93xx are under discussion at the moment, and I have previously done an implementation for omap1 that I have meant to dig out for a while.

Both of the Arm platforms should work fine with compile testing, as I have previously added the stubs as necessary.

Quoted 22 lines
Quoted 10 lines

init/Kconfig config INIT_ENV_ARG_LIMIT · line 134

Quoted 6 lines
init/Kconfig +1 -1
@@ -131,7 +131,7 @@ config INIT_ENV_ARG_LIMIT
 
 config COMPILE_TEST
        bool "Compile also drivers which will not load"
-       depends on HAS_IOMEM
+       depends on HAS_IOMEM && !HAVE_LEGACY_CLK

That sounds a bit drastic to me. Usually we just try to implement the missing functionality, or provide stubs.
Which functions are missing?

Everything that belongs to CONFIG_COMMON_CLK needs stubs.

That is everything under CONFIG_HAVE_CLK [1], excluding functions belonging to clk-devres.o and clk-bulk.o [2]. The HAVE_LEGACY_CLK selects HAVE_CLK, but the COMMON_CLK is under HAVE_CLK too.

[1]
https://elixir.bootlin.com/linux/v5.13-rc3/source/include/linux/clk.h#L786
[2]
https://elixir.bootlin.com/linux/v5.13-rc3/source/drivers/clk/Makefile#L3

Quoted 4 lines

This problem is repeated over and over again for the past years. Some maintainers are adding "depends on COMMON_CLK" for COMPILE_TEST of each driver, but this doesn't solve the root of the problem, and thus, it's constantly reoccurring.

These dependencies tend to reflect the actual requirements though: if a driver calls the clk interfaces, it is likely to require them at runtime as well.

If a driver that calls clk_get_rate() does not have a fallback to deal with '0' getting returned, this means that building it without CONFIG_COMMON_CLK gives you a driver that can't work on any hardware at all. In this case

  depends on COMMON_CLK || COMPILE_TEST

does reflect what we want.depends onb

Quoted 6 lines

Recently Krzysztof Kozlowski added couple more clk stubs for MIPS, but still lots of stubs are missing. Some platforms don't have any stubs at all and apparently nobody cares to fix them.

There 3 possible solutions:

Quoted 7 lines

1. Factor out COMMON_CLK from HAVE_LEGACY_CLK, if this is possible
2. Build stubs universally, maybe using weak functions.
3. Disable compile-testing for HAVE_LEGACY_CLK

The third option is the simplest. If anyone will care to fix those legacy platforms properly, then compile-testing could be re-enabled for them. This is my proposal.

It is pretty much a given that arch/sh won't be converted to common clk at this point, and I think disabling COMPILE_TEST on arch/sh globabally makes sense.

Converting coldfire and ar7/lantiq/bcm63xx/ralink to common_clk shouldn't actually be too hard, but I don't think it's a priority for anyone at the moment.

One other idea I can think of is to redefine CONFIG_HAVE_CLK. At the moment, this is defined as (COMMON_CLK || HAVE_LEGACY_CLK), not literally, but for all practical purposes. If HAVE_CLK is disabled, we get the stubs, so the build failures you saw happen very rarely on drivers that use clk interfaces but have no such Kconfig dependency.

If we change this to define it as

config HAVE_CLK

        def_bool COMMON_CLK || COMPILE_TEST

while annotating the sh/coldfire/ar7/bcm63xx/lantiq/ralink specific drivers as 'depends on HAVE_CLK || HAVE_LEGACY_CLK', then we can compile test any driver, but actually get the build failures for drivers that lack a 'depends on COMMON_CLK' and can fix them up more easily. This probably requires adding a ton of missing dependencies first that happened to get ignored in the past.

If we don't do this, another approach would be to provide global stubs for anything that isn't already provided by the platforms. Here is a list of which interfaces each version actually has implemented (Y), stubbed out (S) or lacks (N):

                omap1   ep93xx  ar7     bcm63xx lantiq  ralink  coldf   sh
clk_enable      Y       Y       S       Y       Y       S       Y       Y
clk_disable     Y       Y       S       Y       Y       S       Y       Y
clk_get_rate    Y       Y       Y       Y       Y       Y       S       Y
clk_round_rate  Y       S       S       S       Y       S       S       Y
clk_set_rate    Y       Y       S       S       Y       S       S       Y
clk_set_parent  S       S       S       N       N       S       S       Y
clk_get_parent  S       Y       S       N       N       S       S       Y
clk_get         N       N       Y       N       N       N       Y       N
clk_put         N       N       S       N       N       N       S       N

- ar7 and coldfire are the only ones that lack the generic clkdev lookup but instead provide their own clk_get/clk_put functions. This can probably get addressed easily.

- The clk_get_parent/set_parent functions are only provided on ep93xx and sh. Once ep93xx is out of the way, we could remove the private stubs and always provide the global ones, except for sh.

- The remaining five functions (enable/disable/get_rate/set_rate/round_rate) have a consistent interface across all eight platforms, they are always exported in that case.

Arnd