Re: [RFC PATCH] powerpc: udbg: export udbg_putc
From: Pali Rohár
Date: Sat May 13 2023 - 05:14:06 EST
On Friday 12 May 2023 22:58:04 Randy Dunlap wrote:
> In a randconfig with CONFIG_SERIAL_CPM=m and
> CONFIG_PPC_EARLY_DEBUG_CPM=y, there is a build error:
> ERROR: modpost: "udbg_putc" [drivers/tty/serial/cpm_uart/cpm_uart.ko] undefined!
>
> The build can be fixed by exporting "udbg_putc" in udbg.c.
>
> OTOH, maybe something like this is more appropriate in
> arch/powerpc/Kconfig.debug?
>
> config PPC_EARLY_DEBUG_CPM
> bool "Early serial debugging for Freescale CPM-based serial ports"
> - depends on SERIAL_CPM
> + depends on SERIAL_CPM=y
>
> Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
> Cc: Nicholas Piggin <npiggin@xxxxxxxxx>
> Cc: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
> Cc: linuxppc-dev@xxxxxxxxxxxxxxxx
> Cc: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: "Pali Rohár" <pali@xxxxxxxxxx>
> ---
> arch/powerpc/kernel/udbg.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff -- a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
> --- a/arch/powerpc/kernel/udbg.c
> +++ b/arch/powerpc/kernel/udbg.c
> @@ -14,6 +14,7 @@
> #include <asm/udbg.h>
>
> void (*udbg_putc)(char c);
> +EXPORT_SYMBOL(udbg_putc);
> void (*udbg_flush)(void);
> int (*udbg_getc)(void);
> int (*udbg_getc_poll)(void);
Hello! I do not think that it is a good idea to export udbg functions
for kernel modules. I have quickly looked at the cpm_uart driver file
drivers/tty/serial/cpm_uart/cpm_uart_core.c and it looks like that once
udbg from it is registered then there is no code for unregistering it.
So I have feeling that compiling cpm_uart driver as module should not be
allowed when CONFIG_SERIAL_CPM_CONSOLE is enabled, and early debug
should depend on CONFIG_CONSOLE_POLL || CONFIG_SERIAL_CPM_CONSOLE.
Any other opinion?