2023-03-31 03:01:33

by Huacai Chen

[permalink] [raw]
Subject: [PATCH] LoongArch: Fix build error if CONFIG_SUSPEND is not set

We can see the following build error on LoongArch if CONFIG_SUSPEND is
not set:

ld: drivers/acpi/sleep.o: in function 'acpi_pm_prepare':
sleep.c:(.text+0x2b8): undefined reference to 'loongarch_wakeup_start'

Here is the call trace:

acpi_pm_prepare()
__acpi_pm_prepare()
acpi_sleep_prepare()
acpi_get_wakeup_address()
loongarch_wakeup_start()

Root cause: loongarch_wakeup_start() is defined in arch/loongarch/power/
suspend_asm.S which is only built under CONFIG_SUSPEND. In order to fix
the build error, just let acpi_get_wakeup_address() return 0 if CONFIG_
SUSPEND is not set.

Fixes: 366bb35a8e48 ("LoongArch: Add suspend (ACPI S3) support")
Reported-by: Randy Dunlap <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Tiezhu Yang <[email protected]>
Signed-off-by: Huacai Chen <[email protected]>
---
arch/loongarch/include/asm/acpi.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
index 4198753aa1d0..976a810352c6 100644
--- a/arch/loongarch/include/asm/acpi.h
+++ b/arch/loongarch/include/asm/acpi.h
@@ -41,8 +41,11 @@ extern void loongarch_suspend_enter(void);

static inline unsigned long acpi_get_wakeup_address(void)
{
+#ifdef CONFIG_SUSPEND
extern void loongarch_wakeup_start(void);
return (unsigned long)loongarch_wakeup_start;
+#endif
+ return 0UL;
}

#endif /* _ASM_LOONGARCH_ACPI_H */
--
2.39.1


2023-03-31 03:30:55

by WANG Xuerui

[permalink] [raw]
Subject: Re: [PATCH] LoongArch: Fix build error if CONFIG_SUSPEND is not set

On 2023/3/31 10:53, Huacai Chen wrote:
> We can see the following build error on LoongArch if CONFIG_SUSPEND is
> not set:
>
> ld: drivers/acpi/sleep.o: in function 'acpi_pm_prepare':
> sleep.c:(.text+0x2b8): undefined reference to 'loongarch_wakeup_start'
>
> Here is the call trace:
>
> acpi_pm_prepare()
> __acpi_pm_prepare()
> acpi_sleep_prepare()
> acpi_get_wakeup_address()
> loongarch_wakeup_start()
>
> Root cause: loongarch_wakeup_start() is defined in arch/loongarch/power/
> suspend_asm.S which is only built under CONFIG_SUSPEND. In order to fix
> the build error, just let acpi_get_wakeup_address() return 0 if CONFIG_
> SUSPEND is not set.
>
> Fixes: 366bb35a8e48 ("LoongArch: Add suspend (ACPI S3) support")
> Reported-by: Randy Dunlap <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/
> Signed-off-by: Tiezhu Yang <[email protected]>
> Signed-off-by: Huacai Chen <[email protected]>
> ---
> arch/loongarch/include/asm/acpi.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
> index 4198753aa1d0..976a810352c6 100644
> --- a/arch/loongarch/include/asm/acpi.h
> +++ b/arch/loongarch/include/asm/acpi.h
> @@ -41,8 +41,11 @@ extern void loongarch_suspend_enter(void);
>
> static inline unsigned long acpi_get_wakeup_address(void)
> {
> +#ifdef CONFIG_SUSPEND
> extern void loongarch_wakeup_start(void);
> return (unsigned long)loongarch_wakeup_start;
> +#endif
> + return 0UL;
> }
>
> #endif /* _ASM_LOONGARCH_ACPI_H */

Reviewed-by: WANG Xuerui <[email protected]>

Thanks!

--
WANG "xen0n" Xuerui

Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/