diff mbox

ACPI: processor: fix LPI when built as module

Message ID 20170519092837.30991-1-yousaf.kaukab@suse.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Mian Yousaf Kaukab May 19, 2017, 9:28 a.m. UTC
Low Power Idle(LPI) support added acpi_processor_ffh_lpi_probe() and
acpi_processor_ffh_lpi_enter() as __weak functions and arch code is
supposed to provide the actual callbacks. This breaks if
ACPI_PROCESSOR is configured as a module.

Add CONFIG_ARCH_HAS_ACPI_LPI configuration option to fix this.

Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
---
 arch/arm64/Kconfig            | 1 +
 arch/arm64/kernel/cpuidle.c   | 2 ++
 drivers/acpi/Kconfig          | 3 +++
 drivers/acpi/processor_idle.c | 9 +++++++--
 4 files changed, 13 insertions(+), 2 deletions(-)

Comments

Sudeep Holla May 23, 2017, 1:08 p.m. UTC | #1
On 19/05/17 10:28, Mian Yousaf Kaukab wrote:
> Low Power Idle(LPI) support added acpi_processor_ffh_lpi_probe() and
> acpi_processor_ffh_lpi_enter() as __weak functions and arch code is
> supposed to provide the actual callbacks. This breaks if
> ACPI_PROCESSOR is configured as a module.
> 
> Add CONFIG_ARCH_HAS_ACPI_LPI configuration option to fix this.
> 

Rafael didn't like the extra Kconfig option when I first posted
LPI patches.

> Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
> ---
>  arch/arm64/Kconfig            | 1 +
>  arch/arm64/kernel/cpuidle.c   | 2 ++
>  drivers/acpi/Kconfig          | 3 +++
>  drivers/acpi/processor_idle.c | 9 +++++++--
>  4 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 848a34116c67..de2f2779cdf5 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -10,6 +10,7 @@ config ARM64
>  	select ARCH_HAS_DEBUG_VIRTUAL
>  	select ARCH_HAS_DEVMEM_IS_ALLOWED
>  	select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
> +	select ARCH_HAS_ACPI_LPI if ACPI
>  	select ARCH_HAS_ELF_RANDOMIZE
>  	select ARCH_HAS_GCOV_PROFILE_ALL
>  	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
> diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c
> index fd691087dc9a..002d9cb890bd 100644
> --- a/arch/arm64/kernel/cpuidle.c
> +++ b/arch/arm64/kernel/cpuidle.c
> @@ -51,9 +51,11 @@ int acpi_processor_ffh_lpi_probe(unsigned int cpu)
>  {
>  	return arm_cpuidle_init(cpu);
>  }
> +EXPORT_SYMBOL(acpi_processor_ffh_lpi_probe);
>  
>  int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
>  {
>  	return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, lpi->index);
>  }
> +EXPORT_SYMBOL(acpi_processor_ffh_lpi_enter);

Won't these 2 export suffice ? I am just curious why that won't work.
Will weak function definitions be still picked when built as modules ?
Mian Yousaf Kaukab May 26, 2017, 10:21 a.m. UTC | #2
On 5/23/17 3:08 PM, Sudeep Holla wrote:
> 
> 
> On 19/05/17 10:28, Mian Yousaf Kaukab wrote:
>> Low Power Idle(LPI) support added acpi_processor_ffh_lpi_probe() and
>> acpi_processor_ffh_lpi_enter() as __weak functions and arch code is
>> supposed to provide the actual callbacks. This breaks if
>> ACPI_PROCESSOR is configured as a module.
>>
>> Add CONFIG_ARCH_HAS_ACPI_LPI configuration option to fix this.
>>
> 
> Rafael didn't like the extra Kconfig option when I first posted
> LPI patches.
> 
>> Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
>> ---
>>   arch/arm64/Kconfig            | 1 +
>>   arch/arm64/kernel/cpuidle.c   | 2 ++
>>   drivers/acpi/Kconfig          | 3 +++
>>   drivers/acpi/processor_idle.c | 9 +++++++--
>>   4 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 848a34116c67..de2f2779cdf5 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -10,6 +10,7 @@ config ARM64
>>   	select ARCH_HAS_DEBUG_VIRTUAL
>>   	select ARCH_HAS_DEVMEM_IS_ALLOWED
>>   	select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
>> +	select ARCH_HAS_ACPI_LPI if ACPI
>>   	select ARCH_HAS_ELF_RANDOMIZE
>>   	select ARCH_HAS_GCOV_PROFILE_ALL
>>   	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
>> diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c
>> index fd691087dc9a..002d9cb890bd 100644
>> --- a/arch/arm64/kernel/cpuidle.c
>> +++ b/arch/arm64/kernel/cpuidle.c
>> @@ -51,9 +51,11 @@ int acpi_processor_ffh_lpi_probe(unsigned int cpu)
>>   {
>>   	return arm_cpuidle_init(cpu);
>>   }
>> +EXPORT_SYMBOL(acpi_processor_ffh_lpi_probe);
>>   
>>   int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
>>   {
>>   	return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, lpi->index);
>>   }
>> +EXPORT_SYMBOL(acpi_processor_ffh_lpi_enter);
> 
> Won't these 2 export suffice ? [...]
No, they don't suffice.

> [...] I am just curious why that won't work.
I am not really sure. System.map shows the exported symbols as following:
ffff000008095898 T acpi_processor_ffh_lpi_probe
ffff0000080958f8 T acpi_processor_ffh_lpi_enter
ffff000008c19160 R __ksymtab_acpi_processor_ffh_lpi_enter
ffff000008c19170 R __ksymtab_acpi_processor_ffh_lpi_probe
ffff000008c357f0 r __kcrctab_acpi_processor_ffh_lpi_enter
ffff000008c357f8 r __kcrctab_acpi_processor_ffh_lpi_probe
ffff000008c4361b r __kstrtab_acpi_processor_ffh_lpi_enter
ffff000008c43638 r __kstrtab_acpi_processor_ffh_lpi_probe

and 'nm processor.ko' shows that they are defined as weak:

0000000000000d68 W acpi_processor_ffh_lpi_enter
0000000000000cc8 W acpi_processor_ffh_lpi_probe

But still weak symbols are happily used when the module is inserted.

> Will weak function definitions be still picked when built as modules ?
Yes.

BR,
Yousaf
diff mbox

Patch

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 848a34116c67..de2f2779cdf5 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -10,6 +10,7 @@  config ARM64
 	select ARCH_HAS_DEBUG_VIRTUAL
 	select ARCH_HAS_DEVMEM_IS_ALLOWED
 	select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
+	select ARCH_HAS_ACPI_LPI if ACPI
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c
index fd691087dc9a..002d9cb890bd 100644
--- a/arch/arm64/kernel/cpuidle.c
+++ b/arch/arm64/kernel/cpuidle.c
@@ -51,9 +51,11 @@  int acpi_processor_ffh_lpi_probe(unsigned int cpu)
 {
 	return arm_cpuidle_init(cpu);
 }
+EXPORT_SYMBOL(acpi_processor_ffh_lpi_probe);
 
 int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
 {
 	return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, lpi->index);
 }
+EXPORT_SYMBOL(acpi_processor_ffh_lpi_enter);
 #endif
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 1ce52f84dc23..7e5a7bce9d72 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -224,6 +224,9 @@  config ACPI_PROCESSOR_IDLE
 	bool
 	select CPU_IDLE
 
+config ARCH_HAS_ACPI_LPI
+	def_bool n
+
 config ACPI_MCFG
 	bool
 
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 5c8aa9cf62d7..321fe9acd8e8 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -1211,15 +1211,20 @@  static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
 	return 0;
 }
 
-int __weak acpi_processor_ffh_lpi_probe(unsigned int cpu)
+#ifdef CONFIG_ARCH_HAS_ACPI_LPI
+int acpi_processor_ffh_lpi_probe(unsigned int cpu);
+int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi);
+#else
+static int acpi_processor_ffh_lpi_probe(unsigned int cpu)
 {
 	return -ENODEV;
 }
 
-int __weak acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
+static int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
 {
 	return -ENODEV;
 }
+#endif /* CONFIG_ARCH_HAS_ACPI_LPI */
 
 /**
  * acpi_idle_lpi_enter - enters an ACPI any LPI state