Message ID | 20230216182043.1946553-1-sunilvl@ventanamicro.com |
---|---|
Headers | show |
Series | Add basic ACPI support for RISC-V | expand |
On Thu, Feb 16, 2023 at 11:50:27PM +0530, Sunil V L wrote: > Enable the ACPI processor driver for RISC-V. > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > drivers/acpi/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig > index ccbeab9500ec..b44ac8e55b54 100644 > --- a/drivers/acpi/Kconfig > +++ b/drivers/acpi/Kconfig > @@ -281,7 +281,7 @@ config ACPI_CPPC_LIB > > config ACPI_PROCESSOR > tristate "Processor" > - depends on X86 || IA64 || ARM64 || LOONGARCH > + depends on X86 || IA64 || ARM64 || LOONGARCH || RISCV > select ACPI_PROCESSOR_IDLE > select ACPI_CPU_FREQ_PSS if X86 || IA64 || LOONGARCH > select THERMAL > -- > 2.34.1 > The commit message doesn't tell me if this is a premature config enablement or if it's already necessary for this series. I think if it's already necessary, then it should point out what requires it in the commit message or be squashed into whatever patch requires it (and also point out in that commit message why it's required). Thanks, drew
On Thu, Feb 16, 2023 at 11:50:29PM +0530, Sunil V L wrote: > processor_core needs arch-specific functions to map the ACPI ID > to the physical ID. In RISC-V platforms, hartid is the physical id > and RINTC structure in MADT provides this mapping. Add arch-specific > function to get this mapping from RINTC. > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > arch/riscv/include/asm/acpi.h | 3 +++ > drivers/acpi/processor_core.c | 29 +++++++++++++++++++++++++++++ > 2 files changed, 32 insertions(+) > > diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h > index 7f9dce3c39d0..4a3622b38159 100644 > --- a/arch/riscv/include/asm/acpi.h > +++ b/arch/riscv/include/asm/acpi.h > @@ -15,6 +15,9 @@ > /* Basic configuration for ACPI */ > #ifdef CONFIG_ACPI > > +typedef u64 phys_cpuid_t; > +#define PHYS_CPUID_INVALID INVALID_HARTID > + > /* ACPI table mapping after acpi_permanent_mmap is set */ > void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size); > #define acpi_os_ioremap acpi_os_ioremap > diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c > index 2ac48cda5b20..d6606a9f2da6 100644 > --- a/drivers/acpi/processor_core.c > +++ b/drivers/acpi/processor_core.c > @@ -106,6 +106,32 @@ static int map_gicc_mpidr(struct acpi_subtable_header *entry, > return -EINVAL; > } > > +/* > + * Retrieve the RISC-V hartid for the processor > + */ > +static int map_rintc_hartid(struct acpi_subtable_header *entry, > + int device_declaration, u32 acpi_id, > + phys_cpuid_t *hartid) > +{ > + struct acpi_madt_rintc *rintc = > + container_of(entry, struct acpi_madt_rintc, header); > + > + if (!(rintc->flags & ACPI_MADT_ENABLED)) > + return -ENODEV; > + > + /* device_declaration means Device object in DSDT, in the > + * RISC-V, logical processors are required to > + * have a Processor Device object in the DSDT, so we should > + * check device_declaration here > + */ > + if (device_declaration && rintc->uid == acpi_id) { > + *hartid = rintc->hart_id; > + return 0; > + } > + > + return -EINVAL; > +} > + > static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, > int type, u32 acpi_id) > { > @@ -136,6 +162,9 @@ static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, > } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { > if (!map_gicc_mpidr(header, type, acpi_id, &phys_id)) > break; > + } else if (header->type == ACPI_MADT_TYPE_RINTC) { > + if (!map_rintc_hartid(header, type, acpi_id, &phys_id)) > + break; > } > entry += header->length; > } > -- > 2.34.1 > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Thanks, drew
On Thu, Feb 16, 2023 at 11:50:31PM +0530, Sunil V L wrote: > smp_setup() currently assumes DT-based platforms. To enable ACPI, > first make this a wrapper function and move existing code to > a separate DT-specific function. > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > --- > arch/riscv/kernel/smpboot.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c > index 00b53913d4c6..26214ddefaa4 100644 > --- a/arch/riscv/kernel/smpboot.c > +++ b/arch/riscv/kernel/smpboot.c > @@ -70,7 +70,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) > } > } > > -void __init setup_smp(void) > +static void __init of_parse_and_init_cpus(void) > { > struct device_node *dn; > unsigned long hart; > @@ -116,6 +116,11 @@ void __init setup_smp(void) > } > } > > +void __init setup_smp(void) > +{ > + of_parse_and_init_cpus(); > +} > + > static int start_secondary_cpu(int cpu, struct task_struct *tidle) > { > if (cpu_ops[cpu]->cpu_start) > -- > 2.34.1 > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
On Thu, Feb 16, 2023 at 11:50:33PM +0530, Sunil V L wrote: > The hartid is in the RINTC structure of the MADT table. Instead of > parsing the ACPI table every time, cache it and provide a function > to read it. > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > arch/riscv/include/asm/acpi.h | 8 +++++ > arch/riscv/kernel/acpi.c | 55 +++++++++++++++++++++++++++++++++++ > 2 files changed, 63 insertions(+) > > diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h > index 3c3a8ac3b37a..b9d7b713fb43 100644 > --- a/arch/riscv/include/asm/acpi.h > +++ b/arch/riscv/include/asm/acpi.h > @@ -67,6 +67,9 @@ int acpi_numa_get_nid(unsigned int cpu); > static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } > #endif /* CONFIG_ACPI_NUMA */ > > +struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu); > + > +u32 get_acpi_id_for_cpu(int cpu); > #else > static inline int acpi_get_riscv_isa(struct acpi_table_header *table, > unsigned int cpu, const char **isa) > @@ -74,6 +77,11 @@ static inline int acpi_get_riscv_isa(struct acpi_table_header *table, > return -EINVAL; > } > > +static inline u32 get_acpi_id_for_cpu(int cpu) > +{ > + return -1; > +} > + > #endif /* CONFIG_ACPI */ > > #endif /*_ASM_ACPI_H*/ > diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c > index 81d448c41714..13b26c87c136 100644 > --- a/arch/riscv/kernel/acpi.c > +++ b/arch/riscv/kernel/acpi.c > @@ -24,6 +24,61 @@ EXPORT_SYMBOL(acpi_disabled); > int acpi_pci_disabled = 1; /* skip ACPI PCI scan and IRQ initialization */ > EXPORT_SYMBOL(acpi_pci_disabled); > > +static unsigned int intc_count; > +static struct acpi_madt_rintc cpu_madt_rintc[NR_CPUS]; > + > +static int acpi_parse_madt_rintc(union acpi_subtable_headers *header, const unsigned long end) > +{ > + struct acpi_madt_rintc *rintc = (struct acpi_madt_rintc *)header; > + > + if (!(rintc->flags & ACPI_MADT_ENABLED)) > + return 0; > + > + cpu_madt_rintc[intc_count++] = *rintc; > + > + return 0; > +} > + > +static int acpi_init_rintc_array(void) > +{ > + if (acpi_table_parse_madt(ACPI_MADT_TYPE_RINTC, acpi_parse_madt_rintc, 0) > 0) > + return 0; > + > + pr_info("No valid RINTC entries exist\n"); This pr_info() could be dropped or turned into a comment and the pr_err() below moved up here. > + return -ENODEV; > +} > + > +struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) > +{ > + static bool rintc_init_done; > + unsigned int i; > + > + if (!rintc_init_done) { > + if (acpi_init_rintc_array()) { > + pr_err("Failed to initialize RINTC array\n"); > + return NULL; > + } > + rintc_init_done = true; > + } > + > + for (i = 0; i < intc_count; i++) { > + if (cpu_madt_rintc[i].hart_id == cpuid_to_hartid_map(cpu)) > + return &cpu_madt_rintc[i]; > + } Maybe I'll see the reason in later patches, but it seems odd that this patch says we want to cache the cpuid to acpi_processor_id mapping, but then we cache each RINTC instead and still have to do a linear search of them to determine which one to use. > + > + return NULL; > +} > + > +u32 get_acpi_id_for_cpu(int cpu) > +{ > + struct acpi_madt_rintc *rintc = acpi_cpu_get_madt_rintc(cpu); > + > + if (!rintc) > + return -1; > + > + return rintc->uid; ^ extra blank here > +} > + > /* > * __acpi_map_table() will be called before paging_init(), so early_ioremap() > * or early_memremap() should be called here to for ACPI table mapping. > -- > 2.34.1 > Thanks, drew
On Thu, Feb 16, 2023 at 11:50:35PM +0530, Sunil V L wrote: > On ACPI based platforms, few details like ISA need to be read > from the ACPI table. Enable cpuinfo on ACPI based systems. > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > arch/riscv/kernel/cpu.c | 31 ++++++++++++++++++++++++------- > 1 file changed, 24 insertions(+), 7 deletions(-) > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > index 1b9a5a66e55a..a227c0661b19 100644 > --- a/arch/riscv/kernel/cpu.c > +++ b/arch/riscv/kernel/cpu.c > @@ -3,10 +3,12 @@ > * Copyright (C) 2012 Regents of the University of California > */ > > +#include <linux/acpi.h> > #include <linux/cpu.h> > #include <linux/init.h> > #include <linux/seq_file.h> > #include <linux/of.h> > +#include <asm/acpi.h> > #include <asm/csr.h> > #include <asm/hwcap.h> > #include <asm/sbi.h> > @@ -256,26 +258,41 @@ static void c_stop(struct seq_file *m, void *v) > { > } > > +static void acpi_print_hart_info(struct seq_file *m, unsigned long cpu) > +{ > + const char *isa; > + > + if (!acpi_get_riscv_isa(NULL, get_acpi_id_for_cpu(cpu), &isa)) > + print_isa(m, isa); > +} > + > static int c_show(struct seq_file *m, void *v) > { > unsigned long cpu_id = (unsigned long)v - 1; > - struct device_node *node = of_get_cpu_node(cpu_id, NULL); > struct riscv_cpuinfo *ci = per_cpu_ptr(&riscv_cpuinfo, cpu_id); > + struct device_node *node; > const char *compat, *isa; > > seq_printf(m, "processor\t: %lu\n", cpu_id); > seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id)); > - if (!of_property_read_string(node, "riscv,isa", &isa)) > - print_isa(m, isa); > + > + if (acpi_disabled) { > + node = of_get_cpu_node(cpu_id, NULL); > + if (!of_property_read_string(node, "riscv,isa", &isa)) > + print_isa(m, isa); > + if (!of_property_read_string(node, "compatible", &compat) && > + strcmp(compat, "riscv")) > + seq_printf(m, "uarch\t\t: %s\n", compat); > + of_node_put(node); > + } else { > + acpi_print_hart_info(m, cpu_id); I don't think we need the helper function for the two lines which would otherwise nicely complement the two similar DT lines above. > + } > + > print_mmu(m); > - if (!of_property_read_string(node, "compatible", &compat) > - && strcmp(compat, "riscv")) > - seq_printf(m, "uarch\t\t: %s\n", compat); This will now print uarch before mmu for DT systems. > seq_printf(m, "mvendorid\t: 0x%lx\n", ci->mvendorid); > seq_printf(m, "marchid\t\t: 0x%lx\n", ci->marchid); > seq_printf(m, "mimpid\t\t: 0x%lx\n", ci->mimpid); > seq_puts(m, "\n"); > - of_node_put(node); > > return 0; > } > -- > 2.34.1 > Thanks, drew
On Thu, Feb 16, 2023 at 11:50:37PM +0530, Sunil V L wrote: > Refactor the timer init function such that few things can be > shared by both DT and ACPI based platforms. > > Co-developed-by: Anup Patel <apatel@ventanamicro.com> > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > drivers/clocksource/timer-riscv.c | 82 +++++++++++++++---------------- > 1 file changed, 40 insertions(+), 42 deletions(-) > > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > index 1b4b36df5484..2ae8e300d303 100644 > --- a/drivers/clocksource/timer-riscv.c > +++ b/drivers/clocksource/timer-riscv.c > @@ -119,61 +119,28 @@ static irqreturn_t riscv_timer_interrupt(int irq, void *dev_id) > return IRQ_HANDLED; > } > > -static int __init riscv_timer_init_dt(struct device_node *n) > +static int __init riscv_timer_init_common(void) > { > - int cpuid, error; > - unsigned long hartid; > - struct device_node *child; > - struct irq_domain *domain; > + int error; > + struct irq_domain *domain = NULL; domain is always assigned below, so we don't need to set it NULL here. > + struct fwnode_handle *intc_fwnode = riscv_get_intc_hwnode(); > > - error = riscv_of_processor_hartid(n, &hartid); > - if (error < 0) { > - pr_warn("Not valid hartid for node [%pOF] error = [%lu]\n", > - n, hartid); > - return error; > - } > - > - cpuid = riscv_hartid_to_cpuid(hartid); > - if (cpuid < 0) { > - pr_warn("Invalid cpuid for hartid [%lu]\n", hartid); > - return cpuid; > - } > - > - if (cpuid != smp_processor_id()) > - return 0; > - > - child = of_find_compatible_node(NULL, NULL, "riscv,timer"); > - if (child) { > - riscv_timer_cannot_wake_cpu = of_property_read_bool(child, > - "riscv,timer-cannot-wake-cpu"); > - of_node_put(child); > - } > - > - domain = NULL; > - child = of_get_compatible_child(n, "riscv,cpu-intc"); > - if (!child) { > - pr_err("Failed to find INTC node [%pOF]\n", n); > - return -ENODEV; > - } > - domain = irq_find_host(child); > - of_node_put(child); > + domain = irq_find_matching_fwnode(intc_fwnode, DOMAIN_BUS_ANY); > if (!domain) { > - pr_err("Failed to find IRQ domain for node [%pOF]\n", n); > + pr_err("Failed to find irq_domain for INTC node [%pfwP]\n", > + intc_fwnode); > return -ENODEV; > } > > riscv_clock_event_irq = irq_create_mapping(domain, RV_IRQ_TIMER); > if (!riscv_clock_event_irq) { > - pr_err("Failed to map timer interrupt for node [%pOF]\n", n); > + pr_err("Failed to map timer interrupt for node [%pfwP]\n", intc_fwnode); > return -ENODEV; > } > > - pr_info("%s: Registering clocksource cpuid [%d] hartid [%lu]\n", > - __func__, cpuid, hartid); > error = clocksource_register_hz(&riscv_clocksource, riscv_timebase); > if (error) { > - pr_err("RISCV timer register failed [%d] for cpu = [%d]\n", > - error, cpuid); > + pr_err("RISCV timer registration failed [%d]\n", error); > return error; > } > > @@ -202,4 +169,35 @@ static int __init riscv_timer_init_dt(struct device_node *n) > return error; > } > > +static int __init riscv_timer_init_dt(struct device_node *n) > +{ > + int cpuid, error; > + unsigned long hartid; > + struct device_node *child; > + > + error = riscv_of_processor_hartid(n, &hartid); > + if (error < 0) { > + pr_warn("Invalid hartid for node [%pOF] error = [%lu]\n", > + n, hartid); > + return error; > + } > + > + cpuid = riscv_hartid_to_cpuid(hartid); > + if (cpuid < 0) { > + pr_warn("Invalid cpuid for hartid [%lu]\n", hartid); > + return cpuid; > + } > + > + if (cpuid != smp_processor_id()) > + return 0; > + > + child = of_find_compatible_node(NULL, NULL, "riscv,timer"); > + if (child) { > + riscv_timer_cannot_wake_cpu = of_property_read_bool(child, > + "riscv,timer-cannot-wake-cpu"); > + of_node_put(child); > + } need blank line here > + return riscv_timer_init_common(); > +} > + > TIMER_OF_DECLARE(riscv_timer, "riscv", riscv_timer_init_dt); > -- > 2.34.1 > Otherwise, Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
On Thu, Feb 16, 2023 at 11:50:39PM +0530, Sunil V L wrote: > On ACPI based platforms, timer related information is > available in RHCT. Add ACPI based probe support to the > timer initialization. > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > arch/riscv/kernel/time.c | 25 +++++++++++++++++++------ > 1 file changed, 19 insertions(+), 6 deletions(-) > > diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c > index 1cf21db4fcc7..e49b897fc657 100644 > --- a/arch/riscv/kernel/time.c > +++ b/arch/riscv/kernel/time.c > @@ -4,6 +4,7 @@ > * Copyright (C) 2017 SiFive > */ > > +#include <linux/acpi.h> > #include <linux/of_clk.h> > #include <linux/clockchips.h> > #include <linux/clocksource.h> > @@ -18,17 +19,29 @@ EXPORT_SYMBOL_GPL(riscv_timebase); > void __init time_init(void) > { > struct device_node *cpu; > + struct acpi_table_rhct *rhct; > + acpi_status status; > u32 prop; > > - cpu = of_find_node_by_path("/cpus"); > - if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop)) > - panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n"); > - of_node_put(cpu); > - riscv_timebase = prop; > + if (acpi_disabled) { > + cpu = of_find_node_by_path("/cpus"); > + if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop)) > + panic("RISC-V system with no 'timebase-frequency' in DTS\n"); > + of_node_put(cpu); > + riscv_timebase = prop; > + } else { > + status = acpi_get_table(ACPI_SIG_RHCT, 0, (struct acpi_table_header **)&rhct); > + if (ACPI_FAILURE(status)) > + panic("RISC-V ACPI system with no RHCT table\n"); > + riscv_timebase = rhct->time_base_freq; > + acpi_put_table((struct acpi_table_header *)rhct); > + } > > lpj_fine = riscv_timebase / HZ; > > - of_clk_init(NULL); > + if (acpi_disabled) > + of_clk_init(NULL); I think we should be able to move of_clk_init() up into the acpi_disabled arm rather than add another if here. > + > timer_probe(); > > tick_setup_hrtimer_broadcast(); > -- > 2.34.1 > Otherwise, Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
On Thu, Feb 16, 2023 at 11:50:41PM +0530, Sunil V L wrote: > Add support to build ACPI subsystem in defconfig. > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > arch/riscv/configs/defconfig | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig > index 128dcf4c0814..f89f79294b34 100644 > --- a/arch/riscv/configs/defconfig > +++ b/arch/riscv/configs/defconfig > @@ -218,3 +218,5 @@ CONFIG_RCU_EQS_DEBUG=y > # CONFIG_FTRACE is not set > # CONFIG_RUNTIME_TESTING_MENU is not set > CONFIG_MEMTEST=y > +CONFIG_ACPI=y > +# CONFIG_PCI_QUIRKS is not set I'm guessing the addition of the CONFIG_PCI_QUIRKS line wasn't intentional? > -- > 2.34.1 > Thanks, drew
On Thu, Feb 16, 2023 at 11:50:43PM +0530, Sunil V L wrote: > With ACPI support added for RISC-V, this kernel parameter is also > supported on RISC-V. Hence, update the documentation. > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > Documentation/admin-guide/kernel-parameters.txt | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 6cfa6e3996cf..b3a5a5844daa 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -1,17 +1,17 @@ > - acpi= [HW,ACPI,X86,ARM64] > + acpi= [HW,ACPI,X86,ARM64,RISC-V] > Advanced Configuration and Power Interface > Format: { force | on | off | strict | noirq | rsdt | > copy_dsdt } > force -- enable ACPI if default was off > - on -- enable ACPI but allow fallback to DT [arm64] > + on -- enable ACPI but allow fallback to DT [arm64,riscv] > off -- disable ACPI if default was on > noirq -- do not use ACPI for IRQ routing > strict -- Be less tolerant of platforms that are not > strictly ACPI specification compliant. > rsdt -- prefer RSDT over (default) XSDT > copy_dsdt -- copy DSDT to memory > - For ARM64, ONLY "acpi=off", "acpi=on" or "acpi=force" > - are available > + For ARM64 and RISC-V, ONLY "acpi=off", "acpi=on" or > + "acpi=force" are available > > See also Documentation/power/runtime_pm.rst, pci=noacpi > > -- > 2.34.1 > I'd squash this into patch 18, "RISC-V: Add ACPI initialization in setup_arch()" Thanks, drew
On Mon, Feb 20, 2023 at 05:05:18PM +0100, Andrew Jones wrote: > On Thu, Feb 16, 2023 at 11:50:27PM +0530, Sunil V L wrote: > > Enable the ACPI processor driver for RISC-V. > > > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > drivers/acpi/Kconfig | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig > > index ccbeab9500ec..b44ac8e55b54 100644 > > --- a/drivers/acpi/Kconfig > > +++ b/drivers/acpi/Kconfig > > @@ -281,7 +281,7 @@ config ACPI_CPPC_LIB > > > > config ACPI_PROCESSOR > > tristate "Processor" > > - depends on X86 || IA64 || ARM64 || LOONGARCH > > + depends on X86 || IA64 || ARM64 || LOONGARCH || RISCV > > select ACPI_PROCESSOR_IDLE > > select ACPI_CPU_FREQ_PSS if X86 || IA64 || LOONGARCH > > select THERMAL > > -- > > 2.34.1 > > > > The commit message doesn't tell me if this is a premature config > enablement or if it's already necessary for this series. I think > if it's already necessary, then it should point out what requires > it in the commit message or be squashed into whatever patch > requires it (and also point out in that commit message why it's > required). > Thanks Drew. Let me drop this patch. We will need it in future when we need to enable LPI/CPPC etc. Thanks, Sunil
On Mon, Feb 20, 2023 at 09:09:09PM +0100, Andrew Jones wrote: > On Thu, Feb 16, 2023 at 11:50:41PM +0530, Sunil V L wrote: > > Add support to build ACPI subsystem in defconfig. > > > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > arch/riscv/configs/defconfig | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig > > index 128dcf4c0814..f89f79294b34 100644 > > --- a/arch/riscv/configs/defconfig > > +++ b/arch/riscv/configs/defconfig > > @@ -218,3 +218,5 @@ CONFIG_RCU_EQS_DEBUG=y > > # CONFIG_FTRACE is not set > > # CONFIG_RUNTIME_TESTING_MENU is not set > > CONFIG_MEMTEST=y > > +CONFIG_ACPI=y > > +# CONFIG_PCI_QUIRKS is not set > > I'm guessing the addition of the CONFIG_PCI_QUIRKS line wasn't > intentional? > Yes, I realized after sending the series. Will remove it in next revision. Thanks, Sunil
On Mon, Feb 20, 2023 at 06:54:29PM +0100, Andrew Jones wrote: > On Thu, Feb 16, 2023 at 11:50:35PM +0530, Sunil V L wrote: > > On ACPI based platforms, few details like ISA need to be read > > from the ACPI table. Enable cpuinfo on ACPI based systems. > > > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > arch/riscv/kernel/cpu.c | 31 ++++++++++++++++++++++++------- > > 1 file changed, 24 insertions(+), 7 deletions(-) > > > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > > index 1b9a5a66e55a..a227c0661b19 100644 > > --- a/arch/riscv/kernel/cpu.c > > +++ b/arch/riscv/kernel/cpu.c > > @@ -3,10 +3,12 @@ > > * Copyright (C) 2012 Regents of the University of California > > */ > > > > +#include <linux/acpi.h> > > #include <linux/cpu.h> > > #include <linux/init.h> > > #include <linux/seq_file.h> > > #include <linux/of.h> > > +#include <asm/acpi.h> > > #include <asm/csr.h> > > #include <asm/hwcap.h> > > #include <asm/sbi.h> > > @@ -256,26 +258,41 @@ static void c_stop(struct seq_file *m, void *v) > > { > > } > > > > +static void acpi_print_hart_info(struct seq_file *m, unsigned long cpu) > > +{ > > + const char *isa; > > + > > + if (!acpi_get_riscv_isa(NULL, get_acpi_id_for_cpu(cpu), &isa)) > > + print_isa(m, isa); > > +} > > + > > static int c_show(struct seq_file *m, void *v) > > { > > unsigned long cpu_id = (unsigned long)v - 1; > > - struct device_node *node = of_get_cpu_node(cpu_id, NULL); > > struct riscv_cpuinfo *ci = per_cpu_ptr(&riscv_cpuinfo, cpu_id); > > + struct device_node *node; > > const char *compat, *isa; > > > > seq_printf(m, "processor\t: %lu\n", cpu_id); > > seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id)); > > - if (!of_property_read_string(node, "riscv,isa", &isa)) > > - print_isa(m, isa); > > + > > + if (acpi_disabled) { > > + node = of_get_cpu_node(cpu_id, NULL); > > + if (!of_property_read_string(node, "riscv,isa", &isa)) > > + print_isa(m, isa); > > + if (!of_property_read_string(node, "compatible", &compat) && > > + strcmp(compat, "riscv")) > > + seq_printf(m, "uarch\t\t: %s\n", compat); > > + of_node_put(node); > > + } else { > > + acpi_print_hart_info(m, cpu_id); > > I don't think we need the helper function for the two lines which would > otherwise nicely complement the two similar DT lines above. > Agree. Let me remove it. > > + } > > + > > print_mmu(m); > > - if (!of_property_read_string(node, "compatible", &compat) > > - && strcmp(compat, "riscv")) > > - seq_printf(m, "uarch\t\t: %s\n", compat); > > This will now print uarch before mmu for DT systems. > Yeah. Let me fix it. Thanks, Sunil
On Mon, Feb 20, 2023 at 08:58:08PM +0100, Andrew Jones wrote: > On Thu, Feb 16, 2023 at 11:50:39PM +0530, Sunil V L wrote: > > On ACPI based platforms, timer related information is > > available in RHCT. Add ACPI based probe support to the > > timer initialization. > > > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > arch/riscv/kernel/time.c | 25 +++++++++++++++++++------ > > 1 file changed, 19 insertions(+), 6 deletions(-) > > > > diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c > > index 1cf21db4fcc7..e49b897fc657 100644 > > --- a/arch/riscv/kernel/time.c > > +++ b/arch/riscv/kernel/time.c > > @@ -4,6 +4,7 @@ > > * Copyright (C) 2017 SiFive > > */ > > > > +#include <linux/acpi.h> > > #include <linux/of_clk.h> > > #include <linux/clockchips.h> > > #include <linux/clocksource.h> > > @@ -18,17 +19,29 @@ EXPORT_SYMBOL_GPL(riscv_timebase); > > void __init time_init(void) > > { > > struct device_node *cpu; > > + struct acpi_table_rhct *rhct; > > + acpi_status status; > > u32 prop; > > > > - cpu = of_find_node_by_path("/cpus"); > > - if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop)) > > - panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n"); > > - of_node_put(cpu); > > - riscv_timebase = prop; > > + if (acpi_disabled) { > > + cpu = of_find_node_by_path("/cpus"); > > + if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop)) > > + panic("RISC-V system with no 'timebase-frequency' in DTS\n"); > > + of_node_put(cpu); > > + riscv_timebase = prop; > > + } else { > > + status = acpi_get_table(ACPI_SIG_RHCT, 0, (struct acpi_table_header **)&rhct); > > + if (ACPI_FAILURE(status)) > > + panic("RISC-V ACPI system with no RHCT table\n"); > > + riscv_timebase = rhct->time_base_freq; > > + acpi_put_table((struct acpi_table_header *)rhct); > > + } > > > > lpj_fine = riscv_timebase / HZ; > > > > - of_clk_init(NULL); > > + if (acpi_disabled) > > + of_clk_init(NULL); > > I think we should be able to move of_clk_init() up into the acpi_disabled > arm rather than add another if here. Yes, will update. Thanks, Sunil
On Mon, Feb 20, 2023 at 09:15:56PM +0100, Andrew Jones wrote: > On Thu, Feb 16, 2023 at 11:50:43PM +0530, Sunil V L wrote: > > With ACPI support added for RISC-V, this kernel parameter is also > > supported on RISC-V. Hence, update the documentation. > > > > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > Documentation/admin-guide/kernel-parameters.txt | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > > index 6cfa6e3996cf..b3a5a5844daa 100644 > > --- a/Documentation/admin-guide/kernel-parameters.txt > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > @@ -1,17 +1,17 @@ > > - acpi= [HW,ACPI,X86,ARM64] > > + acpi= [HW,ACPI,X86,ARM64,RISC-V] > > Advanced Configuration and Power Interface > > Format: { force | on | off | strict | noirq | rsdt | > > copy_dsdt } > > force -- enable ACPI if default was off > > - on -- enable ACPI but allow fallback to DT [arm64] > > + on -- enable ACPI but allow fallback to DT [arm64,riscv] > > off -- disable ACPI if default was on > > noirq -- do not use ACPI for IRQ routing > > strict -- Be less tolerant of platforms that are not > > strictly ACPI specification compliant. > > rsdt -- prefer RSDT over (default) XSDT > > copy_dsdt -- copy DSDT to memory > > - For ARM64, ONLY "acpi=off", "acpi=on" or "acpi=force" > > - are available > > + For ARM64 and RISC-V, ONLY "acpi=off", "acpi=on" or > > + "acpi=force" are available > > > > See also Documentation/power/runtime_pm.rst, pci=noacpi > > > > -- > > 2.34.1 > > > > I'd squash this into patch 18, "RISC-V: Add ACPI initialization in > setup_arch()" > Sure. Let me squash in the next revision. Thanks, Sunil