diff mbox series

drivers: acpi: Fix platform profile driver on !acpi platforms

Message ID 20250522141410.31315-1-alexghiti@rivosinc.com
State New
Headers show
Series drivers: acpi: Fix platform profile driver on !acpi platforms | expand

Commit Message

Alexandre Ghiti May 22, 2025, 2:13 p.m. UTC
The platform profile driver is loaded even on platforms that do not have
acpi enabled. The initialization of the sysfs entries was recently moved
from platform_profile_register() to the module init call, and those
entries need acpi_kobj to be initialized which is not the case when acpi
is disabled.

This results in the following warning:

 WARNING: CPU: 5 PID: 1 at fs/sysfs/group.c:131 internal_create_group+0xa22/0xdd8
 Modules linked in:
 CPU: 5 UID: 0 PID: 1 Comm: swapper/0 Tainted: G        W           6.15.0-rc7-dirty #6 PREEMPT
 Tainted: [W]=WARN
 Hardware name: riscv-virtio,qemu (DT)
 epc : internal_create_group+0xa22/0xdd8
  ra : internal_create_group+0xa22/0xdd8

 Call Trace:

 internal_create_group+0xa22/0xdd8
 sysfs_create_group+0x22/0x2e
 platform_profile_init+0x74/0xb2
 do_one_initcall+0x198/0xa9e
 kernel_init_freeable+0x6d8/0x780
 kernel_init+0x28/0x24c
 ret_from_fork+0xe/0x18

Fix this by checking if acpi is enabled before trying to create sysfs
entries.

Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI platform profile")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
 drivers/acpi/platform_profile.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Arnd Bergmann May 22, 2025, 2:18 p.m. UTC | #1
On Thu, May 22, 2025, at 16:13, Alexandre Ghiti wrote:

> Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI 
> platform profile")
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Arnd Bergmann May 23, 2025, 10:44 a.m. UTC | #2
On Thu, May 22, 2025, at 22:04, Armin Wolf wrote:
> Am 22.05.25 um 16:13 schrieb Alexandre Ghiti:
>
> I already submitted a patch for this problem (see 
> https://lore.kernel.org/linux-acpi/a6d92cdd-4dc3-4080-9ed9-5b1f02f247e0@gmx.de/T/)
> that only disables the legacy sysfs interface while keeping the 
> class-based interface functional
> as it does not depend on ACPI at all.

Just for my understanding: what users of the platform profile are
there that work without ACPI? I see that CONFIG_ACPI_PLATFORM_PROFILE
is hidden under CONFIG_ACPI and cannot be selected in configurations
that turn off ACPI, so if that is an intended usecase, there is
probably still something wrong in Kconfig.

Should the driver be moved out of drivers/acpi to drivers/platform
in order to let non-ACPI platforms use it?

     Arnd
diff mbox series

Patch

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index ffbfd32f4cf1..b43f4459a4f6 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -688,6 +688,9 @@  static int __init platform_profile_init(void)
 {
 	int err;
 
+	if (acpi_disabled)
+		return -EOPNOTSUPP;
+
 	err = class_register(&platform_profile_class);
 	if (err)
 		return err;