Skip to contentSkip to conversation

Kconfig: Add dependencies of POWER_RESET for x86

PATCH Superseded Yuan Tan 2 participants 6 messages Sep 14, 2023 – Sep 15, 2023 x86

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Yuan Tan

author
#0 lore raw

v3 cover Kconfig: Add dependencies of POWER_RESET for x86

These patches are to add dependencies of POWER_RESET for x86.

I sent v1 and v2 to the wrong x86 repository and email list. Here is v3.

As I have to use "savedefconfig" on the latest branch of different architectures, I am sending separate patches for each architecture in v3.

To simplify the enablement of the poweroff support, selecting the required options for CONFIG_POWER_RESET=y may make many people happy especially when they are using a customized config (maybe tinyconfig based) for a target qemu board. Without normal poweroff support from the kernel side, qemu will simply hang[1] there after a 'poweroff' command, which is a very bad experience for the automatical tests.

However, CONFIG_POWER_RESET is ineffective if there are no dependencies that enable certain devices in Kconfig.

Currently, based on tinyconfig, it is very hard to find the exact poweroff related option[2]. Some architectures' poweroff works well without any dependence, the others' poweroff options are hidden deeply, which make things hard.

After multiple verifications, these options have been identified as the minimum dependencies required for poweroff to function normally. Additionally, 'make savedefconfig' simplifies the defconfig automatically.

Zhangjin and I invested a significant amount of time in searching for the current options on these devices. We hope that this set of patches will save time for others. If community like it, we will consider adding dependencies for POWER_RESET on other devices.

We hope every device's CONFIG_POWER_RESET will have proper dependencies. :)

---
[1]: https://lore.kernel.org/lkml/511b2f6009fb830b3f32b4be3dca99596c684fa3.1689759351.git.falcon@tinylab.org/
[2]: https://lore.kernel.org/all/983843582e52e83fba79ad45cea6c79e1f62ec6c.1690489039.git.falcon@tinylab.org/

v1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/

---
Changes in v2:
- Fix the mistake of using spaces instead of tabs in kconfig.

Changes in v3:
- Enable POWER_RESET and simplify the deconfig.

Yuan Tan (3):
x86/config: Cleanup i386_defconfig and x86_64_defconfig
Kconfig: Add dependencies of POWER_RESET for x86 x86/config: Simplify i386_defconfig and x86_64_defconfig

 arch/x86/Kconfig                  |  2 ++
 arch/x86/configs/i386_defconfig   | 31 ++++++++++---------------------
 arch/x86/configs/x86_64_defconfig |  9 ++-------
 3 files changed, 14 insertions(+), 28 deletions(-)

base-commit: 84b81a67e9cba5466178e47c20c0628359a242b0

Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 1/3 x86/config: Cleanup i386_defconfig and x86_64_defconfig

Use 'make savedefconfig' to cleanup i386_defconfig and x86_64_defconfig.

---
 arch/x86/configs/i386_defconfig   | 29 +++++++++--------------------
 arch/x86/configs/x86_64_defconfig |  7 +------
 2 files changed, 10 insertions(+), 26 deletions(-)
arch/x86/configs/i386_defconfig +9 -20
index 1b411bbf3cb0..babd91c8091a 100644
@@ -1,7 +1,6 @@
 CONFIG_WERROR=y
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
-CONFIG_USELIB=y
 CONFIG_AUDIT=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
@@ -28,21 +27,20 @@ CONFIG_CGROUP_DEBUG=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_KALLSYMS_ALL=y
 CONFIG_PROFILING=y
+CONFIG_CRASH_DUMP=y
 CONFIG_SMP=y
 CONFIG_HYPERVISOR_GUEST=y
 CONFIG_PARAVIRT=y
-CONFIG_NR_CPUS=8
 CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y
 CONFIG_X86_MSR=y
 CONFIG_X86_CPUID=y
+CONFIG_NUMA=y
 CONFIG_X86_CHECK_BIOS_CORRUPTION=y
 # CONFIG_MTRR_SANITIZER is not set
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
+CONFIG_EFI_MIXED=y
 CONFIG_HZ_1000=y
-CONFIG_KEXEC=y
-CONFIG_CRASH_DUMP=y
-# CONFIG_RETHUNK is not set
 CONFIG_HIBERNATION=y
 CONFIG_PM_DEBUG=y
 CONFIG_PM_TRACE_RTC=y
@@ -51,9 +49,9 @@ CONFIG_ACPI_BGRT=y
 CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
 CONFIG_X86_ACPI_CPUFREQ=y
+CONFIG_IA32_EMULATION=y
 CONFIG_KPROBES=y
 CONFIG_JUMP_LABEL=y
-CONFIG_COMPAT_32BIT_TIME=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
@@ -64,9 +62,7 @@ CONFIG_BINFMT_MISC=y
 # CONFIG_COMPAT_BRK is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
-CONFIG_UNIX=y
 CONFIG_XFRM_USER=y
-CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 CONFIG_IP_ADVANCED_ROUTER=y
 CONFIG_IP_MULTIPLE_TABLES=y
@@ -127,7 +123,6 @@ CONFIG_NET_9P=y
 CONFIG_NET_9P_VIRTIO=y
 CONFIG_PCI=y
 CONFIG_PCIEPORTBUS=y
-CONFIG_PCI_MSI=y
 CONFIG_HOTPLUG_PCI=y
 CONFIG_PCCARD=y
 CONFIG_YENTA=y
@@ -135,7 +130,6 @@ CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_DEBUG_DEVRES=y
 CONFIG_CONNECTOR=y
-CONFIG_EFI_CAPSULE_LOADER=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_VIRTIO_BLK=y
 CONFIG_BLK_DEV_SD=y
@@ -150,8 +144,6 @@ CONFIG_ATA_PIIX=y
 CONFIG_PATA_AMD=y
 CONFIG_PATA_OLDPIIX=y
 CONFIG_PATA_SCH=y
-CONFIG_PATA_MPIIX=y
-CONFIG_ATA_GENERIC=y
 CONFIG_MD=y
 CONFIG_BLK_DEV_MD=y
 CONFIG_BLK_DEV_DM=y
@@ -162,17 +154,14 @@ CONFIG_MAC_EMUMOUSEBTN=y
 CONFIG_NETDEVICES=y
 CONFIG_NETCONSOLE=y
 CONFIG_VIRTIO_NET=y
-CONFIG_BNX2=y
 CONFIG_TIGON3=y
 CONFIG_NET_TULIP=y
 CONFIG_E100=y
 CONFIG_E1000=y
 CONFIG_E1000E=y
 CONFIG_SKY2=y
-CONFIG_NE2K_PCI=y
 CONFIG_FORCEDETH=y
 CONFIG_8139TOO=y
-# CONFIG_8139TOO_PIO is not set
 CONFIG_R8169=y
 CONFIG_INPUT_EVDEV=y
 CONFIG_INPUT_JOYSTICK=y
@@ -191,6 +180,8 @@ CONFIG_SERIAL_8250_RSA=y
 CONFIG_SERIAL_NONSTANDARD=y
 CONFIG_VIRTIO_CONSOLE=y
 CONFIG_HW_RANDOM=y
+# CONFIG_HW_RANDOM_INTEL is not set
+# CONFIG_HW_RANDOM_AMD is not set
 CONFIG_NVRAM=y
 CONFIG_HPET=y
 # CONFIG_HPET_MMAP is not set
@@ -237,12 +228,14 @@ CONFIG_DMADEVICES=y
 CONFIG_VIRTIO_PCI=y
 CONFIG_VIRTIO_INPUT=y
 CONFIG_EEEPC_LAPTOP=y
+CONFIG_AMD_IOMMU=y
+CONFIG_INTEL_IOMMU=y
+# CONFIG_INTEL_IOMMU_DEFAULT_ON is not set
 CONFIG_EXT4_FS=y
 CONFIG_EXT4_FS_POSIX_ACL=y
 CONFIG_EXT4_FS_SECURITY=y
 CONFIG_QUOTA=y
 CONFIG_QUOTA_NETLINK_INTERFACE=y
-# CONFIG_PRINT_QUOTA_WARNING is not set
 CONFIG_QFMT_V2=y
 CONFIG_AUTOFS_FS=y
 CONFIG_ISO9660_FS=y
@@ -267,10 +260,8 @@ CONFIG_SECURITY=y
 CONFIG_SECURITY_NETWORK=y
 CONFIG_SECURITY_SELINUX=y
 CONFIG_SECURITY_SELINUX_BOOTPARAM=y
-CONFIG_SECURITY_SELINUX_DISABLE=y
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_KERNEL=y
-CONFIG_FRAME_WARN=1024
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_WX=y
 CONFIG_DEBUG_STACK_USAGE=y
@@ -280,5 +271,3 @@ CONFIG_BLK_DEV_IO_TRACE=y
 CONFIG_PROVIDE_OHCI1394_DMA_INIT=y
 CONFIG_EARLY_PRINTK_DBGP=y
 CONFIG_DEBUG_BOOT_PARAMS=y
-CONFIG_UNWINDER_FRAME_POINTER=y
-# CONFIG_64BIT is not set
arch/x86/configs/x86_64_defconfig +1 -6
index 409e9182bd29..babd91c8091a 100644
@@ -27,6 +27,7 @@ CONFIG_CGROUP_DEBUG=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_KALLSYMS_ALL=y
 CONFIG_PROFILING=y
+CONFIG_CRASH_DUMP=y
 CONFIG_SMP=y
 CONFIG_HYPERVISOR_GUEST=y
 CONFIG_PARAVIRT=y
@@ -40,8 +41,6 @@ CONFIG_EFI=y
 CONFIG_EFI_STUB=y
 CONFIG_EFI_MIXED=y
 CONFIG_HZ_1000=y
-CONFIG_KEXEC=y
-CONFIG_CRASH_DUMP=y
 CONFIG_HIBERNATION=y
 CONFIG_PM_DEBUG=y
 CONFIG_PM_TRACE_RTC=y
@@ -63,9 +62,7 @@ CONFIG_BINFMT_MISC=y
 # CONFIG_COMPAT_BRK is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
-CONFIG_UNIX=y
 CONFIG_XFRM_USER=y
-CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 CONFIG_IP_ADVANCED_ROUTER=y
 CONFIG_IP_MULTIPLE_TABLES=y
@@ -239,7 +236,6 @@ CONFIG_EXT4_FS_POSIX_ACL=y
 CONFIG_EXT4_FS_SECURITY=y
 CONFIG_QUOTA=y
 CONFIG_QUOTA_NETLINK_INTERFACE=y
-# CONFIG_PRINT_QUOTA_WARNING is not set
 CONFIG_QFMT_V2=y
 CONFIG_AUTOFS_FS=y
 CONFIG_ISO9660_FS=y
@@ -264,7 +260,6 @@ CONFIG_SECURITY=y
 CONFIG_SECURITY_NETWORK=y
 CONFIG_SECURITY_SELINUX=y
 CONFIG_SECURITY_SELINUX_BOOTPARAM=y
-CONFIG_SECURITY_SELINUX_DISABLE=y
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v3 2/3 Kconfig: Add dependencies of POWER_RESET for x86

In reply to Yuan Tan

x86 and x86_64's power off depends on ACPI and PCI to work. Enable them when POWER_RESET is set for convenience.

---
 arch/x86/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/Kconfig +2 -0
index 3b3594f96330..9571507ad40f 100644
@@ -58,6 +58,7 @@ config X86
 	#
 	# Note: keep this list sorted alphabetically
 	#
+	select ACPI		if POWER_RESET
 	select ACPI_LEGACY_TABLES_LOOKUP	if ACPI
 	select ACPI_SYSTEM_POWER_STATES_SUPPORT	if ACPI
 	select ARCH_32BIT_OFF_T			if X86_32
@@ -286,6 +287,7 @@ config X86
 	select NEED_PER_CPU_EMBED_FIRST_CHUNK
 	select NEED_PER_CPU_PAGE_FIRST_CHUNK
 	select NEED_SG_DMA_LENGTH
+	select PCI		if POWER_RESET
 	select PCI_DOMAINS			if PCI
 	select PCI_LOCKLESS_CONFIG		if PCI
 	select PERF_EVENTS
Signature · 1 line
2.34.1
#3 lore raw
Quoted 2 lines · Yuan Tan

x86 and x86_64's power off depends on ACPI and PCI to work. Enable them when POWER_RESET is set for convenience.

I'm a bit confused by this.

Which code is this referring to, exactly? Are you saying that no x86 system can power off or reset unless it supports ACPI or PCI?

author
#4 lore raw
Quoted 7 lines · Dave Hansen
Quoted 2 lines · Yuan Tan

x86 and x86_64's power off depends on ACPI and PCI to work. Enable them when POWER_RESET is set for convenience.

I'm a bit confused by this.

Which code is this referring to, exactly? Are you saying that no x86 system can power off or reset unless it supports ACPI or PCI?

Yes, after testing on qemu-system-x86_64 and qemu-system-i386, I found that x86 can only power off when it enable ACPI and PCI.

I wanted to test nolibc based on tinyconfig and found it hard to find the dependence to enable poweroff.

author
#5 lore raw

PATCH v3 3/3 x86/config: Simplify i386_defconfig and x86_64_defconfig

In reply to Yuan Tan

Simplify i386_defconfig and x86_64_defconfig with POWER_RESET dependences.

Regenerate i386_defconfig and x86_64_defconfig with 'make savedefconfig'.

---
 arch/x86/configs/i386_defconfig   | 2 +-
 arch/x86/configs/x86_64_defconfig | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/configs/i386_defconfig +1 -1
index babd91c8091a..470ce962eb58 100644
@@ -121,7 +121,6 @@ CONFIG_MAC80211_LEDS=y
 CONFIG_RFKILL=y
 CONFIG_NET_9P=y
 CONFIG_NET_9P_VIRTIO=y
-CONFIG_PCI=y
 CONFIG_PCIEPORTBUS=y
 CONFIG_HOTPLUG_PCI=y
 CONFIG_PCCARD=y
@@ -186,6 +185,7 @@ CONFIG_NVRAM=y
 CONFIG_HPET=y
 # CONFIG_HPET_MMAP is not set
 CONFIG_I2C_I801=y
+CONFIG_POWER_RESET=y
 CONFIG_WATCHDOG=y
 CONFIG_AGP=y
 CONFIG_AGP_AMD64=y
arch/x86/configs/x86_64_defconfig +1 -1
index babd91c8091a..470ce962eb58 100644
@@ -121,7 +121,6 @@ CONFIG_MAC80211_LEDS=y
 CONFIG_RFKILL=y
 CONFIG_NET_9P=y
 CONFIG_NET_9P_VIRTIO=y
-CONFIG_PCI=y
 CONFIG_PCIEPORTBUS=y
 CONFIG_HOTPLUG_PCI=y
 CONFIG_PCCARD=y
@@ -186,6 +185,7 @@ CONFIG_NVRAM=y
 CONFIG_HPET=y
 # CONFIG_HPET_MMAP is not set
 CONFIG_I2C_I801=y
+CONFIG_POWER_RESET=y
 CONFIG_WATCHDOG=y
 CONFIG_AGP=y
 CONFIG_AGP_AMD64=y
Signature · 1 line
2.34.1