Skip to contentSkip to conversation

m68knommu: fix undefined reference to `mach_get_rtc_pll'

PATCH In review Greg Ungerer 3 participants 8 messages May 13, 2022 – May 17, 2022 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68knommu: fix undefined reference to `mach_get_rtc_pll'

Configuring for a nommu classic m68k target and enabling the generic rtc driver (CONFIG_RTC_DRV_GENERIC) will result in the following compile error:

m68k-linux-ld: arch/m68k/kernel/time.o: in function `rtc_ioctl':
time.c:(.text+0x82): undefined reference to `mach_get_rtc_pll'
m68k-linux-ld: time.c:(.text+0xbc): undefined reference to `mach_set_rtc_pll'
m68k-linux-ld: time.c:(.text+0xf4): undefined reference to `mach_set_rtc_pll'

"mach_set_rtc_pll" and "mach_get_rtc_pll" are only defined in the common MMU setup code, and are really only implemented in any meaningful way on classic M68K MMU enabled machines. So conditionally limit their use to MMU enabled classic M68K systems.

---
 arch/m68k/kernel/time.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/kernel/time.c +2 -2
index 340ffeea0a9d..c8b70b425ada 100644
@@ -62,7 +62,7 @@ void timer_heartbeat(void)
 }
 #endif /* CONFIG_HEARTBEAT */
 
-#ifdef CONFIG_M68KCLASSIC
+#if defined(CONFIG_M68KCLASSIC) && defined(CONFIG_MMU)
 #if !IS_BUILTIN(CONFIG_RTC_DRV_GENERIC)
 void read_persistent_clock64(struct timespec64 *ts)
 {
@@ -140,7 +140,7 @@ static int __init rtc_init(void)
 
 module_init(rtc_init);
 #endif /* CONFIG_RTC_DRV_GENERIC */
-#endif /* CONFIG M68KCLASSIC */
+#endif /* CONFIG M68KCLASSIC && CONFIG_MMU */
 
 void __init time_init(void)
 {
Signature · 1 line
2.25.1
#1 lore raw

Hi Greg,

Quoted 4 lines · Greg Ungerer

Configuring for a nommu classic m68k target and enabling the generic rtc driver (CONFIG_RTC_DRV_GENERIC) will result in the following compile error:

Quoted 8 lines
   m68k-linux-ld: arch/m68k/kernel/time.o: in function `rtc_ioctl':
   time.c:(.text+0x82): undefined reference to `mach_get_rtc_pll'
   m68k-linux-ld: time.c:(.text+0xbc): undefined reference to `mach_set_rtc_pll'
   m68k-linux-ld: time.c:(.text+0xf4): undefined reference to `mach_set_rtc_pll'

"mach_set_rtc_pll" and "mach_get_rtc_pll" are only defined in the common MMU setup code, and are really only implemented in any meaningful way on classic M68K MMU enabled machines. So conditionally limit their use to

And only on Q40/Q60.

Quoted 4 lines

MMU enabled classic M68K systems.

Thanks for your patch!

arch/m68k/kernel/time.c void timer_heartbeat(void) · line 68

Quoted 11 lines
arch/m68k/kernel/time.c +1 -1
@@ -62,7 +62,7 @@ void timer_heartbeat(void)
 }
 #endif /* CONFIG_HEARTBEAT */
 
-#ifdef CONFIG_M68KCLASSIC
+#if defined(CONFIG_M68KCLASSIC) && defined(CONFIG_MMU)
 #if !IS_BUILTIN(CONFIG_RTC_DRV_GENERIC)
 void read_persistent_clock64(struct timespec64 *ts)
 {

read_persistent_clock64() uses mach_hwclk(), which is provided by both setup_mm.c and setup_no.c, so it's always available? Albeit not populated by coldfire or nommu platform code, so I see the point in depending on MMU (no nommu Amiga support yet ;-).

Perhaps rtc_ioctl() should depend on CONFIG_Q40?

arch/m68k/kernel/time.c static int __init rtc_init(void) · line 146

Quoted 9 lines
arch/m68k/kernel/time.c +1 -1
@@ -140,7 +140,7 @@ static int __init rtc_init(void)
 
 module_init(rtc_init);
 #endif /* CONFIG_RTC_DRV_GENERIC */
-#endif /* CONFIG M68KCLASSIC */
+#endif /* CONFIG M68KCLASSIC && CONFIG_MMU */
 
 void __init time_init(void)
 {

Gr{oetje,eeting}s,

Geert

--
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
Quoted 12 lines · Geert Uytterhoeven

arch/m68k/kernel/time.c void timer_heartbeat(void) · line 68

Quoted 6 lines
arch/m68k/kernel/time.c +1 -1
-#ifdef CONFIG_M68KCLASSIC
+#if defined(CONFIG_M68KCLASSIC) && defined(CONFIG_MMU)
 #if !IS_BUILTIN(CONFIG_RTC_DRV_GENERIC)
 void read_persistent_clock64(struct timespec64 *ts)
 {

read_persistent_clock64() uses mach_hwclk(), which is provided by both setup_mm.c and setup_no.c, so it's always available? Albeit not populated by coldfire or nommu platform code, so I see the point in depending on MMU (no nommu Amiga support yet ;-).

Quoted 1 line

Perhaps rtc_ioctl() should depend on CONFIG_Q40?

I think the best cleanup would be to turn the q40 rtc support into a standalone driver using rtc_register_device(), and completely detaching it from the rtc_generic support in arch/m68k/kernel/time.c.

Arnd

#3 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 31 lines · Geert Uytterhoeven

Hi Greg,

Quoted 4 lines · Greg Ungerer

Configuring for a nommu classic m68k target and enabling the generic rtc driver (CONFIG_RTC_DRV_GENERIC) will result in the following compile error:

Quoted 8 lines
    m68k-linux-ld: arch/m68k/kernel/time.o: in function `rtc_ioctl':
    time.c:(.text+0x82): undefined reference to `mach_get_rtc_pll'
    m68k-linux-ld: time.c:(.text+0xbc): undefined reference to `mach_set_rtc_pll'
    m68k-linux-ld: time.c:(.text+0xf4): undefined reference to `mach_set_rtc_pll'

"mach_set_rtc_pll" and "mach_get_rtc_pll" are only defined in the common MMU setup code, and are really only implemented in any meaningful way on classic M68K MMU enabled machines. So conditionally limit their use to

And only on Q40/Q60.

Quoted 4 lines

MMU enabled classic M68K systems.

Thanks for your patch!

Quoted 6 lines
arch/m68k/kernel/time.c +0 -0
@@ -62,7 +62,7 @@ void timer_heartbeat(void)
  }
  #endif /* CONFIG_HEARTBEAT */
 
Quoted 9 lines

arch/m68k/kernel/time.c void timer_heartbeat(void) · line 68

Quoted 5 lines
arch/m68k/kernel/time.c +1 -1
-#ifdef CONFIG_M68KCLASSIC
+#if defined(CONFIG_M68KCLASSIC) && defined(CONFIG_MMU)
  #if !IS_BUILTIN(CONFIG_RTC_DRV_GENERIC)
  void read_persistent_clock64(struct timespec64 *ts)
  {

read_persistent_clock64() uses mach_hwclk(), which is provided by
both setup_mm.c and setup_no.c, so it's always available?> Albeit not populated by coldfire or nommu platform code, so I see the point in depending on MMU (no nommu Amiga support yet ;-).

Yes, exactly. And even worse is that on ColdFire platforms it is never set, so will be the startup value of NULL. It is called without checking for NULL in both of rtc_generic_get_time() and rtc_generic_set_time().

I figured if nommu mode is ever supported on any of the classic MMU m68k then this could be revisited.

Quoted 1 line

Perhaps rtc_ioctl() should depend on CONFIG_Q40?

That is probably reasonable too. Using CONFIG_MMU was a good fit for the way mach_set_rtc_pll and mach_get_rtc_pll are currently defined - as in setup_mm.c which is CONFIG_MMU only, which is why I went that way.

But if you prefer I can re-factor further based on CONFIG_Q40?

Regards
Greg

Quoted 20 lines

arch/m68k/kernel/time.c static int __init rtc_init(void) · line 146

Quoted 9 lines
arch/m68k/kernel/time.c +1 -1
@@ -140,7 +140,7 @@ static int __init rtc_init(void)
 
  module_init(rtc_init);
  #endif /* CONFIG_RTC_DRV_GENERIC */
-#endif /* CONFIG M68KCLASSIC */
+#endif /* CONFIG M68KCLASSIC && CONFIG_MMU */
 
  void __init time_init(void)
  {

Gr{oetje,eeting}s,

Geert

--
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

#4 lore raw
Quoted 9 lines · Greg Ungerer
Quoted 3 lines · Geert Uytterhoeven

read_persistent_clock64() uses mach_hwclk(), which is provided by
both setup_mm.c and setup_no.c, so it's always available?> Albeit not populated by coldfire or nommu platform code, so I see the point in depending on MMU (no nommu Amiga support yet ;-).

Yes, exactly. And even worse is that on ColdFire platforms it is never set, so will be the startup value of NULL. It is called without checking for NULL in both of rtc_generic_get_time() and rtc_generic_set_time().

I think that's ok because rtc_generic_{get,set}_time is only called from the rtc_generic driver, but that is not registered when mach_hwclk() is NULL.

With your patch to add the CONFIG_MMU check, you can actually remove the mach_hwclk() symbol from setup_no.c, and move the remaining RTC related symbols from setup_mm.c into the #ifdef.

Arnd

#5 lore raw

Hi Arnd,

Quoted 11 lines · Arnd Bergmann
Quoted 9 lines · Greg Ungerer
Quoted 3 lines · Geert Uytterhoeven

read_persistent_clock64() uses mach_hwclk(), which is provided by
both setup_mm.c and setup_no.c, so it's always available?> Albeit not populated by coldfire or nommu platform code, so I see the point in depending on MMU (no nommu Amiga support yet ;-).

Yes, exactly. And even worse is that on ColdFire platforms it is never set, so will be the startup value of NULL. It is called without checking for NULL in both of rtc_generic_get_time() and rtc_generic_set_time().

Quoted 7 lines

I think that's ok because rtc_generic_{get,set}_time is only called from the rtc_generic driver, but that is not registered when mach_hwclk() is NULL.

With your patch to add the CONFIG_MMU check, you can actually remove the mach_hwclk() symbol from setup_no.c, and move the remaining RTC related symbols from setup_mm.c into the #ifdef.

Yes, I think that would be a good idea.
Tidies thins up a little.

Regards
Greg

maintainer Reviewed-by Acked-by
#6 lore raw
Quoted 16 lines · Greg Ungerer
Quoted 15 lines · Arnd Bergmann
Quoted 9 lines · Greg Ungerer
Quoted 3 lines · Geert Uytterhoeven

read_persistent_clock64() uses mach_hwclk(), which is provided by
both setup_mm.c and setup_no.c, so it's always available?> Albeit not populated by coldfire or nommu platform code, so I see the point in depending on MMU (no nommu Amiga support yet ;-).

Yes, exactly. And even worse is that on ColdFire platforms it is never set, so will be the startup value of NULL. It is called without checking for NULL in both of rtc_generic_get_time() and rtc_generic_set_time().

I think that's ok because rtc_generic_{get,set}_time is only called from the rtc_generic driver, but that is not registered when mach_hwclk() is NULL.

Quoted 6 lines
Quoted 3 lines

With your patch to add the CONFIG_MMU check, you can actually remove the mach_hwclk() symbol from setup_no.c, and move the remaining RTC related symbols from setup_mm.c into the #ifdef.

Yes, I think that would be a good idea.
Tidies thins up a little.

Let's fix the build error first.

Gr{oetje,eeting}s,

Geert

--
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

#7 lore raw

Hi Geert,

Quoted 21 lines · Geert Uytterhoeven
Quoted 20 lines · Greg Ungerer
Quoted 18 lines · Arnd Bergmann
Quoted 9 lines · Greg Ungerer
Quoted 3 lines · Geert Uytterhoeven

read_persistent_clock64() uses mach_hwclk(), which is provided by
both setup_mm.c and setup_no.c, so it's always available?> Albeit not populated by coldfire or nommu platform code, so I see the point in depending on MMU (no nommu Amiga support yet ;-).

Yes, exactly. And even worse is that on ColdFire platforms it is never set, so will be the startup value of NULL. It is called without checking for NULL in both of rtc_generic_get_time() and rtc_generic_set_time().

I think that's ok because rtc_generic_{get,set}_time is only called from the rtc_generic driver, but that is not registered when mach_hwclk() is NULL.

With your patch to add the CONFIG_MMU check, you can actually remove the mach_hwclk() symbol from setup_no.c, and move the remaining RTC related symbols from setup_mm.c into the #ifdef.

Quoted 7 lines
Quoted 2 lines

Yes, I think that would be a good idea.
Tidies thins up a little.

Let's fix the build error first.

I am re-thinking this fix at the moment. I think I missed the fact that the 68328 has underlying mach_hwclk support, and so can use be used by rtc_generic_{get,set}_time. So in other words classic m68k nommu config should be able to use this code too. CONFIG_MMU blocking it is probably not right here.

New patch coming.

Regards
Greg

Quoted 10 lines

Gr{oetje,eeting}s,

Geert

--
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