Skip to content

Commit 90502d5

Browse files
Merge patch series "Add basic ACPI support for RISC-V"
Sunil V L <[email protected]> says: This patch series enables the basic ACPI infrastructure for RISC-V. Supporting external interrupt controllers is in progress and hence it is tested using poll based HVC SBI console and RAM disk. The first patch in this series is one of the patch from Jisheng's series [1] which is not merged yet. This patch is required to support ACPI since efi_init() which gets called before sbi_init() can enable static branches and hits a panic. Below are two ECRs approved by ASWG. RINTC - https://drive.google.com/file/d/1R6k4MshhN3WTT-hwqAquu5nX6xSEqK2l/view RHCT - https://drive.google.com/file/d/1nP3nFiH4jkPMp6COOxP6123DCZKR-tia/view Testing: 1) Build latest Qemu 2) Build EDK2 as per instructions in https://github.com/vlsunil/riscv-uefi-edk2-docs/wiki/RISC-V-Qemu-Virt-support 3) Build Linux after enabling SBI HVC and SBI earlycon CONFIG_RISCV_SBI_V01=y CONFIG_SERIAL_EARLYCON_RISCV_SBI=y CONFIG_HVC_RISCV_SBI=y 4) Build buildroot. Run with below command. qemu-system-riscv64 -nographic \ -drive file=Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT.fd,if=pflash,format=raw,unit=1 \ -machine virt -smp 16 -m 2G \ -kernel arch/riscv/boot/Image \ -initrd buildroot/output/images/rootfs.cpio \ -append "root=/dev/ram ro console=hvc0 earlycon=sbi" * b4-shazam-merge: RISC-V: Enable ACPI in defconfig RISC-V: time.c: Add ACPI support for time_init() clocksource/timer-riscv: Add ACPI support clocksource/timer-riscv: Refactor riscv_timer_init_dt() irqchip/riscv-intc: Add ACPI support RISC-V: cpu: Enable cpuinfo for ACPI systems RISC-V: cpufeature: Add ACPI support in riscv_fill_hwcap() RISC-V: only iterate over possible CPUs in ISA string parser RISC-V: smpboot: Add ACPI support in setup_smp() RISC-V: smpboot: Create wrapper setup_smp() drivers/acpi: RISC-V: Add RHCT related code RISC-V: ACPI: Cache and retrieve the RINTC structure RISC-V: Add ACPI initialization in setup_arch() ACPI: processor_core: RISC-V: Enable mapping processor to the hartid RISC-V: Add support to build the ACPI core ACPI: OSL: Make should_use_kmap() 0 for RISC-V ACPI: tables: Print RINTC information when MADT is parsed crypto: hisilicon/qm: Fix to enable build with RISC-V clang platform/surface: Disable for RISC-V riscv: move sbi_init() earlier before jump_label_init() Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents ac9a786 + cc9e654 commit 90502d5

File tree

24 files changed

+772
-86
lines changed

24 files changed

+772
-86
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
acpi= [HW,ACPI,X86,ARM64]
1+
acpi= [HW,ACPI,X86,ARM64,RISCV64]
22
Advanced Configuration and Power Interface
33
Format: { force | on | off | strict | noirq | rsdt |
44
copy_dsdt }
55
force -- enable ACPI if default was off
6-
on -- enable ACPI but allow fallback to DT [arm64]
6+
on -- enable ACPI but allow fallback to DT [arm64,riscv64]
77
off -- disable ACPI if default was on
88
noirq -- do not use ACPI for IRQ routing
99
strict -- Be less tolerant of platforms that are not
1010
strictly ACPI specification compliant.
1111
rsdt -- prefer RSDT over (default) XSDT
1212
copy_dsdt -- copy DSDT to memory
13-
For ARM64, ONLY "acpi=off", "acpi=on" or "acpi=force"
14-
are available
13+
For ARM64 and RISCV64, ONLY "acpi=off", "acpi=on" or
14+
"acpi=force" are available
1515

1616
See also Documentation/power/runtime_pm.rst, pci=noacpi
1717

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@ L: [email protected]
412412
S: Maintained
413413
F: drivers/platform/x86/serial-multi-instantiate.c
414414

415+
ACPI FOR RISC-V (ACPI/riscv)
416+
M: Sunil V L <[email protected]>
417+
418+
419+
S: Maintained
420+
F: drivers/acpi/riscv/
421+
415422
ACPI PCC(Platform Communication Channel) MAILBOX DRIVER
416423
M: Sudeep Holla <[email protected]>
417424

arch/riscv/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ config 32BIT
1212

1313
config RISCV
1414
def_bool y
15+
select ACPI_GENERIC_GSI if ACPI
16+
select ACPI_REDUCED_HARDWARE_ONLY if ACPI
1517
select ARCH_DMA_DEFAULT_COHERENT
1618
select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
1719
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
@@ -707,6 +709,7 @@ config EFI
707709
depends on OF && !XIP_KERNEL
708710
depends on MMU
709711
default y
712+
select ARCH_SUPPORTS_ACPI if 64BIT
710713
select EFI_GENERIC_STUB
711714
select EFI_PARAMS_FROM_FDT
712715
select EFI_RUNTIME_WRAPPERS
@@ -816,3 +819,5 @@ source "drivers/cpufreq/Kconfig"
816819
endmenu # "CPU Power Management"
817820

818821
source "arch/riscv/kvm/Kconfig"
822+
823+
source "drivers/acpi/Kconfig"

arch/riscv/configs/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CONFIG_PM=y
3737
CONFIG_CPU_IDLE=y
3838
CONFIG_VIRTUALIZATION=y
3939
CONFIG_KVM=m
40+
CONFIG_ACPI=y
4041
CONFIG_JUMP_LABEL=y
4142
CONFIG_MODULES=y
4243
CONFIG_MODULE_UNLOAD=y

arch/riscv/include/asm/acenv.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* RISC-V specific ACPICA environments and implementation
4+
*/
5+
6+
#ifndef _ASM_ACENV_H
7+
#define _ASM_ACENV_H
8+
9+
/* This header is required unconditionally by the ACPI core */
10+
11+
#endif /* _ASM_ACENV_H */

arch/riscv/include/asm/acpi.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2013-2014, Linaro Ltd.
4+
* Author: Al Stone <[email protected]>
5+
* Author: Graeme Gregory <[email protected]>
6+
* Author: Hanjun Guo <[email protected]>
7+
*
8+
* Copyright (C) 2021-2023, Ventana Micro Systems Inc.
9+
* Author: Sunil V L <[email protected]>
10+
*/
11+
12+
#ifndef _ASM_ACPI_H
13+
#define _ASM_ACPI_H
14+
15+
/* Basic configuration for ACPI */
16+
#ifdef CONFIG_ACPI
17+
18+
typedef u64 phys_cpuid_t;
19+
#define PHYS_CPUID_INVALID INVALID_HARTID
20+
21+
/* ACPI table mapping after acpi_permanent_mmap is set */
22+
void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
23+
#define acpi_os_ioremap acpi_os_ioremap
24+
25+
#define acpi_strict 1 /* No out-of-spec workarounds on RISC-V */
26+
extern int acpi_disabled;
27+
extern int acpi_noirq;
28+
extern int acpi_pci_disabled;
29+
30+
static inline void disable_acpi(void)
31+
{
32+
acpi_disabled = 1;
33+
acpi_pci_disabled = 1;
34+
acpi_noirq = 1;
35+
}
36+
37+
static inline void enable_acpi(void)
38+
{
39+
acpi_disabled = 0;
40+
acpi_pci_disabled = 0;
41+
acpi_noirq = 0;
42+
}
43+
44+
/*
45+
* The ACPI processor driver for ACPI core code needs this macro
46+
* to find out whether this cpu was already mapped (mapping from CPU hardware
47+
* ID to CPU logical ID) or not.
48+
*/
49+
#define cpu_physical_id(cpu) cpuid_to_hartid_map(cpu)
50+
51+
/*
52+
* Since MADT must provide at least one RINTC structure, the
53+
* CPU will be always available in MADT on RISC-V.
54+
*/
55+
static inline bool acpi_has_cpu_in_madt(void)
56+
{
57+
return true;
58+
}
59+
60+
static inline void arch_fix_phys_package_id(int num, u32 slot) { }
61+
62+
void acpi_init_rintc_map(void);
63+
struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu);
64+
u32 get_acpi_id_for_cpu(int cpu);
65+
int acpi_get_riscv_isa(struct acpi_table_header *table,
66+
unsigned int cpu, const char **isa);
67+
68+
static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; }
69+
#else
70+
static inline void acpi_init_rintc_map(void) { }
71+
static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu)
72+
{
73+
return NULL;
74+
}
75+
76+
static inline int acpi_get_riscv_isa(struct acpi_table_header *table,
77+
unsigned int cpu, const char **isa)
78+
{
79+
return -EINVAL;
80+
}
81+
82+
#endif /* CONFIG_ACPI */
83+
84+
#endif /*_ASM_ACPI_H*/

arch/riscv/include/asm/cpu.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
3+
#ifndef _ASM_CPU_H
4+
#define _ASM_CPU_H
5+
6+
/* This header is required unconditionally by the ACPI core */
7+
8+
#endif /* _ASM_CPU_H */

arch/riscv/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ obj-$(CONFIG_COMPAT) += compat_signal.o
9292
obj-$(CONFIG_COMPAT) += compat_vdso/
9393

9494
obj-$(CONFIG_64BIT) += pi/
95+
obj-$(CONFIG_ACPI) += acpi.o

0 commit comments

Comments
 (0)